Files
runner-images/images/windows/scripts/build/Configure-PowerShell.ps1
Vasilii Polikarpov 5ed2615017 [Windows] Cleanup various scripts (#8942)
* Use Resolve-GithubReleaseAssetUrl more widely

* Add the Get-ChecksumFromUrl function

* Sort exported functions and add docs

* Remove alias and fix typo

* Fix kind checksum url and syntax

* Fix checksums url for gh cli and msys2

* [Windows] Cleanup various scripts

* Add spaces after type specifications

* Rename the Take-Part function
2023-12-04 10:50:53 +01:00

39 lines
1.3 KiB
PowerShell

################################################################################
## File: Configure-Powershell.ps1
## Desc: Manage PowerShell configuration
################################################################################
#region System
Write-Host "Setup PowerShellGet"
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
# Specifies the installation policy
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
Write-Host 'Warmup PSModuleAnalysisCachePath (speedup first powershell invocation by 20s)'
$PSModuleAnalysisCachePath = 'C:\PSModuleAnalysisCachePath\ModuleAnalysisCache'
[Environment]::SetEnvironmentVariable('PSModuleAnalysisCachePath', $PSModuleAnalysisCachePath, "Machine")
# make variable to be available in the current session
${env:PSModuleAnalysisCachePath} = $PSModuleAnalysisCachePath
$null = New-Item -Path $PSModuleAnalysisCachePath -ItemType 'File' -Force
#endregion
#region User (current user, image generation only)
if (-not (Test-Path $profile)) {
New-Item $profile -ItemType File -Force
}
@"
if ( -not(Get-Module -ListAvailable -Name PowerHTML)) {
Install-Module PowerHTML -Scope CurrentUser
}
if ( -not(Get-Module -Name PowerHTML)) {
Import-Module PowerHTML
}
"@ | Add-Content -Path $profile -Force
#endregion