-
Notifications
You must be signed in to change notification settings - Fork 12
/
Fix-PowerShell.ps1
31 lines (25 loc) · 1014 Bytes
/
Fix-PowerShell.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Kill FIPS so bootstrapping NuGet doesn't fail.
$SetItemPropertyArgs = @{
Path = 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy'
Name = 'Enabled'
Value = '0'
Force = $true
}
Set-ItemProperty @SetItemPropertyArgs | Out-Null
# Build the ScriptBlock
$ScriptBlock = [scriptblock]::Create({
Install-PackageProvider -Name NuGet -ForceBootstrap -Force | Out-Null
Set-PackageSource -Name PSGallery -Trusted -ForceBootstrap -Force | Out-Null
Install-Module -Name PowerShellGet,PSReadline,PSWindowsUpdate -Scope AllUsers -SkipPublisherCheck -Force | Out-Null
})
# Run it
$StartProcArgs = @{
FilePath = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
ArgumentList = "-NoProfile -ExecutionPolicy Bypass -Command $ScriptBlock"
Wait = $true
NoNewWindow = $true
}
$ProgPrefBak = $ProgressPreference
$ProgressPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue
Start-Process @StartProcArgs | Out-Null
$ProgressPreference = $ProgPrefBak