我在尝试使用 Desired State Configuration (DSC) 时遇到问题。我正在使用脚本资源,当我运行Start-DscConfiguration -Wait -Verbose -Path .\blah
它时,无论如何它都会跳过这一步。我已将 TestScript 设置为 False,但它仍会跳过该步骤。有谁知道它为什么跳过这些步骤?这是我正在做的事情:
http://technet.microsoft.com/en-us/library/dn249912.aspx
configuration disk
{
node $env:computername
{
Script disk
{
SetScript = {
ADD-Content -Path "c:\disk.txt" "List Disk"
$listDisk = (Diskpart /s c:\disk.txt);
$c = 0;
$dname = "", "_d_data" , "_e_wmapps", "_f_wmlogs", "_s_swapfile";
for($i = 0; $i -le ($listDisk.Count) ; $i++)
{
if($listDisk[$i] -match "Disk [0-99]")
{
$dn = $dname[$c];
if ($c -eq 0)
{
Add-Content -Path "C:\hrd.txt" "Select Volume 0"
Add-Content -Path "C:\hrd.txt" "assign letter=B"
}
else
{
Add-Content -Path "C:\hrd.txt" "Select Disk $c"
Add-Content -Path "C:\hrd.txt" "CREATE PARTITION PRIMARY"
}
$c++
}
}
diskpart /s "c:\hrd.txt"
Remove-Item "c:\disk.txt"
Remove-Item "c:\hrd.txt"
}
GetScript = {return @{Name = "Disk"}}
TestScript =
{
$obj = Get-WmiObject "Win32_DiskDrive" -Filter "Partitions=0"
if($obj.count -eq 0)
{
[bool]::TrueString
}
else
{
[bool]::FalseString
}
}
}
}
}