1# Run Powrshell as admin
2
3Copy Paste this
4
5Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
1# COPY AND PASTE THIS COMMAND
2
3# using cmd as admin
4@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
5
6#or
7
8#using powershell as admin
9Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
1@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
1Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
1@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
2
1#Install Chocolatey
2#region
3echo "Setting up Chocolatey software package manager"
4New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
5
6Get-PackageProvider -Name chocolatey -Force
7
8echo "Setting up Full Chocolatey Install"
9Install-Package -Name Chocolatey -Force -ProviderName chocolatey
10$chocopath = (Get-Package chocolatey |
11 ?{$_.Name -eq "chocolatey"} |
12 Select @{N="Source";E={((($a=($_.Source -split "\\"))[0..($a.length - 2)]) -join "\"),"Tools\chocolateyInstall" -join "\"}} |
13 Select -ExpandProperty Source)
14& $chocopath "upgrade all -y"
15choco install chocolatey-core.extension --force
16
17echo "Creating daily task to automatically upgrade Chocolatey packages"
18# adapted from https://blogs.technet.microsoft.com/heyscriptingguy/2013/11/23/using-scheduled-tasks-and-scheduled-jobs-in-powershell/
19$ScheduledJob = @{
20 Name = "Chocolatey Daily Upgrade"
21 ScriptBlock = {choco upgrade all -y}
22 Trigger = New-JobTrigger -Daily -at 2am
23 ScheduledJobOption = New-ScheduledJobOption -RunElevated -MultipleInstancePolicy StopExisting -RequireNetwork
24}
25Register-ScheduledJob @ScheduledJob
26#endregion
27
28#Update Powershell
29#region
30$ErrorActionPreference = "silentlycontinue"
31
32$PSVersionTable.PSVersion
33choco install powershell -y
34choco upgrade powershell -y
35
36$ErrorActionPreference = "continue"
37#endregion
38