You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#Powershell 7+ ship with help included, but 5.1 does not on Windows Servers and CI. The secure devops pipeline also does not allow internet access, so we must update help from our local repository source.
196
+
#Some CI do not ship with help included, and the secure devops pipeline also does not allow internet access, so we must update help from our local repository source.
197
197
198
198
# Only commands in Microsoft.PowerShell.Utility can be tested for help so as to minimize the repository storage.
199
-
# This requires admin rights
199
+
# This requires admin rights for PS5.1
200
200
201
-
#NOTE: You can run this task once as admin or update help separately, and continue to run tests as non-admin, if for instance developing locally.
201
+
#NOTE: You can run this task once as admin or update help separately, and continue to run tests as non-admin, if for instance developing locally. Also this help is for PS5.1 so tests should be written for that even if PS7. For instance, don't write tests for new Invoke-RestMethod parameters.
202
202
203
203
$installHelpScript= {
204
+
param(
205
+
[Parameter(Mandatory)][string]$helpPath
206
+
)
207
+
$PSVersion=$PSVersionTable.PSVersion
204
208
$ErrorActionPreference='Stop'
209
+
$helpPath=Resolve-Path$helpPath
210
+
if ($PSEdition-ne'Desktop') {
211
+
$helpPath=Join-Path$helpPath'7'
212
+
}
213
+
205
214
if ((Get-HelpInvoke-RestMethod).remarks -notlike'Get-Help cannot find the Help files*') {
206
-
Write-Host-Fore Green 'Powershell 5.1 Utility Help is already installed'
215
+
Write-Host-Fore Green "PowerShell $PSVersion Utility Help is already installed"
207
216
return
208
217
}
209
218
210
-
# Cant use requires RunAsAdministrator because PS isn't smart enough to know this is a subscript.
211
-
if (-not [Security.Principal.WindowsPrincipal]::new([Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
212
-
throw'Windows PowerShell Update-Help requires admin rights. Please re-run the script in an elevated powershell session.'
219
+
if ($PSEdition-eq'Desktop') {
220
+
# Cant use requires RunAsAdministrator because PS isn't smart enough to know this is a subscript.
221
+
if (-not [Security.Principal.WindowsPrincipal]::new(
0 commit comments