powershell dsc 版本 3.8.0.0 安装

powershell dsc version 3.8.0.0 installation

我安装了新版本的 ps DSC 3.8.0.0 使用:

Find-Module -Name xpsd* | Install-Module

我确定在写这个问题时,我已经至少重启过我的电脑一次。 问题是旧版本 (3.7.0.0) DSC 资源智能感知是 keeps 出现的。实际上就像从未安装过新模块一样。

我尝试使用以下方法删除旧的 dsc 资源:

Get-DSCResource | Where-Object{$_.Version -eq '3.7.0.0'} | Remove-Item

这导致模块未被删除但已损坏,因为它们被列为:

ImplementedAs   Name                      ModuleName                     Version    Properties                                        
-------------   ----                      ----------                     -------    ----------                                        
Binary          File                                                                {DestinationPath, Attributes, Checksum, Content...

最初他们的 ImplementedAs 属性 的值为 PowerShell,在 Remove-Item 命令后更改为 Binary。此外,它们的 ModuleNameVersion 属性在损坏之前已正确填充。

使用 $env:PSModulePath,我找到了 3.7.0.0 文件夹并将其删除。

虽然模块不再显示在 'Get-DSCResource' 检索到的列表中,但我还有两个问题:

1) 如何让 DSC 使用新的 3.8.0.0 资源及其相应的参数?

注意:我试过 Find-Module -Name xpsd* | Install-Module -Force 但没有改善。

xPSDesiredStateConfiguration 是我们在图库中提供的实验模块,而 PSDesiredStateConfiguration 是包装盒中的模块。为了使用模块中的资源,您需要使用 Import-DscResource 语句导入

Import-DscResource -ModuleName xPSDesiredStateConfiguration

那么您可以使用以下资源:

xService MyService
{
}

请注意,资源名称也不同 - xPSDesiredStateConfiguration 中的资源名称前面有 "x" 前缀

显然 github documentation 声称 xPackage 资源中有 Version 属性 是不准确的。

我怎么知道?

$res = Get-DSCResource xPackage
$res.Properties

属性 项列表不包含 Version 属性。因此,DSC 编译器成功地使用了较新的版本 3.8.0.0,令我惊讶的是,随后在 3 周内发布了较新的版本 3.9.0.0。上一个 3.7.0.0 版本比 3.8.0.0 版本早 13 个月发布!!!