我試圖使用DSC安裝PS模塊。它需要3種獨立的配置:
Configuration InitialConfiguration
{
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Node MyServer
{
Script InstallModule
{
SetScript = { Install-Module PackageManagement -MinimumVersion 1.1.7 -Force }
TestScript = { $version = (Get-Module PackageManagement -ListAvailable).Version; $version.Major -ge 1 -and $version.Minor -ge 1 }
GetScript = { Get-Module PackageManagement -ListAvailable }
}
}
}
Configuration ModulesConfiguration
{
Import-DscResource -ModuleName 'PackageManagement' -ModuleVersion 1.1.7.0
Node MyServer
{
PackageManagement xWebAdministration
{
Name = 'xWebAdministration'
}
}
}
Configuration WebServerConfiguration
{
Import-DscResource –ModuleName 'xWebAdministration'
Node MyServer
{
xWebAppPool SampleAppPool
{
Name = 'SampleAppPool'
}
}
}
然而,微軟使用simple script在他們example安裝使用WinRM的模塊。