Answered through testing. It's all about the double quotes.
$civapp = Get-CIVApp TEST
$script =
"@echo off
if ""%1%"" == ""precustomization"" (
echo Do precustomization tasks
) else if ""%1%"" == ""postcustomization"" (
cmd /c schtasks.exe /change /TN ""\Microsoft\Windows\Defrag\ScheduledDefrag"" /Disable
)"
Foreach ($civm in ($civApp | Get-CIVM)) {
$GuestCustomization = $civm.ExtensionData.Section | Where {$_.GetType() -like "*GuestCustomizationSection"}
$GuestCustomization.Enabled = $true
$GuestCustomization.ChangeSid = $false
$GuestCustomization.ResetPasswordRequired = $false
$GuestCustomization.CustomizationScript = $script
$GuestCustomization.UpdateServerData()
}
Message was edited by: jgreenback