Можно ли удалить конфигурацию 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;
}
}
}
}
Этот блок конфигурации создаст MOF, который использует ресурс Script
для установки 7-Zip 9.20 64-bit в системе, к которой он применяется, если приложение не найдено.
Как после применения этой конфигурации с помощью приведенных ниже команд ее можно удалить из системы, если 7-Zip больше не требуется?
SevenZip -OutputPath c:\dsc\7-Zip;
Start-DscConfiguration -Wait -Path C:\dsc\7-Zip -Verbose;