如何訪問此處描述的內置DSC資源:https://technet.microsoft.com/en-us/library/dn282121.aspx?它們應該是內置的,但當我嘗試在配置中使用它們時出現錯誤。未找到內置DSC資源
我的配置如下:
configuration Windows8VM
{
param
(
[Parameter(Mandatory = $true)]
[string] $ComputerName
)
Import-DSCResource -Name Package
Node $ComputerName
{
File gitFolder
{
Ensure = "Present"
Type = "Directory"
DestinationPath = "C:\git"
}
Package gitSoftware
{
Ensure = "Present"
Name = "git"
ProductId = ''
Path = https://chocolatey.org/api/v2/
Arguments = '/SILENT /COMPONENTS="icons,ext\reg\shellhere,assoc,assoc_sh"'
}
}
}
我得到的錯誤是:
At C:\win8vmconfig.ps1:9 char:5
+ Import-DSCResource -Name Package
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unable to load resource 'Package': Resource not found.
At C:\win8vmconfig.ps1:20 char:9
+ Package gitSoftware
+ ~~~~~~~
Undefined DSC resource 'Package'. Use Import-DSCResource to import the resource.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : DscResourcesNotFoundDuringParsing
所以,這是完全不能定位的資源。這裏發生了什麼,以及我缺少訪問Microsoft記錄的內置DSC資源的步驟?
我正在使用WMF/PowerShell 5.0。
我已經試過這兩個獨立的操作系統,Windows 7和較新的Windows Server 2012 R2數據中心,因此它似乎獨立於操作系統。 我只在試圖解決原始錯誤時添加了「Import-DscResource」行, – learningKnight
@learningKnight Windows 7和2012 R2都只能使用帶有實驗功能的DSC 5,因此可能這是一個錯誤。如果你刪除了'Import-DscResource'行,那麼你會得到原始錯誤,那是第二個錯誤? – briantist
正確,我的評論顯然被切斷了,但是,第二個錯誤是原來的錯誤。 如果我運行'Get-DscResource',則只顯示文件。這似乎是我錯過了一個安裝步驟,但我無法找出需要安裝哪些內容才能訪問這些資源。 另一個奇怪的是,我在原帖中鏈接到的文檔資源是從2013年開始的,所以它引發了一些疑問,以瞭解這些功能對於Window 10來說是新的,但也許這與它有關,我會看看我是否可以設置Windows 10機器... – learningKnight