Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 193504

Re: How Can I Set the Customization Script for all VMs in a vApp

$
0
0

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


Viewing all articles
Browse latest Browse all 193504

Trending Articles