安装依赖版本的 PowerShell
Installing a dependent version of PowerShell
如何告诉 DSC 我需要先更新 PowerShell 本身?
我是否只使用脚本资源并安装 chocolatey,然后使用 choco
安装最新的 WMF/PowerShell?
我已经编写了一个示例来执行此操作。我假设您使用的是 PowerShell 4.0 并想更新到 5.0,但概念是相同的。这里是 link 到完整的 sample.
Set-ExecutionPolicy remotesigned
Set-WSManQuickConfig -Force
$nugetPath = Join-Path $env:temp nuget.exe
if(!(Test-Path $nugetPath))
{
Invoke-WebRequest -UseBasicParsing -Uri https://nuget.org/nuget.exe -OutFile $nugetPath
}
&$nugetPath install XWindowsUpdate -source https://www.powershellgallery.com/api/v2 -outputDirectory "$env:programfiles\WindowsPowerShell\Modules\ " -ExcludeVersion
Configuration WMF5Install
{
Import-DscResource -ModuleName xWindowsUpdate
Node localhost
{
xHotfix HotfixInstall
{
Path = 'E:\WindowsBlue-KB3055381-x64.msu'
Id = 'KB3055381'
Ensure = 'Present'
}
LocalConfigurationManager
{
RebootNodeIfNeeded = $true
}
}
}
$outputPath = Join-Path $env:temp Wmf5Install
WMF5Install -OutputPath $outputPath
Set-DscLocalConfigurationManager -Path $outputPath -Verbose
Start-DscConfiguration -Path $outputPath -Wait -Verbose -force
如何告诉 DSC 我需要先更新 PowerShell 本身?
我是否只使用脚本资源并安装 chocolatey,然后使用 choco
安装最新的 WMF/PowerShell?
我已经编写了一个示例来执行此操作。我假设您使用的是 PowerShell 4.0 并想更新到 5.0,但概念是相同的。这里是 link 到完整的 sample.
Set-ExecutionPolicy remotesigned
Set-WSManQuickConfig -Force
$nugetPath = Join-Path $env:temp nuget.exe
if(!(Test-Path $nugetPath))
{
Invoke-WebRequest -UseBasicParsing -Uri https://nuget.org/nuget.exe -OutFile $nugetPath
}
&$nugetPath install XWindowsUpdate -source https://www.powershellgallery.com/api/v2 -outputDirectory "$env:programfiles\WindowsPowerShell\Modules\ " -ExcludeVersion
Configuration WMF5Install
{
Import-DscResource -ModuleName xWindowsUpdate
Node localhost
{
xHotfix HotfixInstall
{
Path = 'E:\WindowsBlue-KB3055381-x64.msu'
Id = 'KB3055381'
Ensure = 'Present'
}
LocalConfigurationManager
{
RebootNodeIfNeeded = $true
}
}
}
$outputPath = Join-Path $env:temp Wmf5Install
WMF5Install -OutputPath $outputPath
Set-DscLocalConfigurationManager -Path $outputPath -Verbose
Start-DscConfiguration -Path $outputPath -Wait -Verbose -force