一度適用した DSC 構成をコンピューターから削除することはできますか?
たとえば、configuration
次のようなブロックがあります。
configuration SevenZip {
Script Install7Zip {
GetScript = {
$7ZipFolder = '{0}\7-Zip' -f $env:ProgramFiles;
$Result = @{
Result = '';
}
if (Test-Path -Path $7ZipFolder) {
$Result.Result = 'Present';
}
else {
$Result.Result = 'Nonpresent';
}
Write-Verbose -Message $Result.Result;
$Result;
}
SetScript = {
$7ZipUri = 'http://colocrossing.dl.sourceforge.net/project/sevenzip/7-Zip/9.20/7z920-x64.msi';
$OutputFile = '{0}\7-Zip.msi' -f $env:TEMP;
Invoke-WebRequest -Uri $7ZipUri -OutFile $OutputFile;
Write-Verbose -Message ('Finished downloading 7-Zip MSI file to {0}.' -f $OutputFile);
$ArgumentList = '/package "{0}" /passive /norestart /l*v "{1}\Install 7-Zip 9.20 64-bit.log"' -f $OutputFile, $env:TEMP;
$Process = Start-Process -FilePath msiexec.exe -ArgumentList $ArgumentList -Wait -PassThru;
Write-Verbose -Message ('Process finished with exit code: {0}' -f $Process.ExitCode);
Remove-Item -Path $OutputFile;
Write-Verbose -Message ('Removed MSI file: {0}' -f $OutputFile);
}
TestScript = {
$7ZipFolder = '{0}\7-Zip' -f $env:ProgramFiles;
if (Test-Path -Path $7ZipFolder) {
$true;
}
else {
$false;
}
}
}
}
Script
アプリケーションが見つからない場合、この構成ブロックは、リソースを使用して 7-Zip 9.20 64 ビットを適用先のシステムにインストールする MOF を生成します。
以下のコマンドを使用してこの構成を適用した後、7-Zip が不要になった場合、どのようにシステムから削除できますか?
SevenZip -OutputPath c:\dsc\7-Zip;
Start-DscConfiguration -Wait -Path C:\dsc\7-Zip -Verbose;