Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 176483

Adding a wait time to a script

$
0
0

Hello,

 

I am brand new to scripting and I am working towards being able to deploy a large number of VMs from a .csv file and then customize their network settings once deployed.  I know that there are probably scripts already on the Internet that will accomplish this, but I'm trying to learn so I would like to build the script from scratch so that I full understand it.  Here's what I have so far:

 

Connect-VIServer -Server MYVCSERVER.MYDOMAIN.local -User MYDOMAIN\USERNAME -Password MYPASSWORD

New-vm -vmhost prodh1.MYDOMAIN.local -Name TEST-SVR02 -Template W2K8R2SP1 -Datastore IOMEGA -OSCustomizationspec W2K8R2SP1 -Location _Tobedeleted| Start-VM

get-vm "TEST-SVR02" | Get-VMGuestNetworkInterface -Guestuser Administrator -GuestPassword "MYPASSWORD" |?{$_.name -eq "Local Area Connection 3"} | set-vmguestnetworkinterface -Guestuser Administrator -GuestPassword "MYPASSWORD" -IPPolicy static -IP 192.168.1.25 -Netmask 255.255.255.0 -Gateway 192.168.1.1 -DNS 192.168.1.2,192.168.1.3

Get-NetworkAdapter "TEST-SVR02" | Set-NetworkAdapter -NetworkName VM1 -Confirm:$false

 

Each line in the code is working, however, the VM that is created must be deployed, then customized, only then can the network settings be changed since the VMtools needs to be running in order to customize the network settings.  The total time for this to complete is about 20 minutes.

 

Is there a simple way to either:

 

1.   have the script wait for the OS customization to complete before attempting to change the network settings

or

2.  have the script wait about 20 minutes to allow for the deployment/customization to complete

 

Thanks.


Viewing all articles
Browse latest Browse all 176483

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>