Quantcast
Channel: VMware Communities : Discussion List - Automation Tools
Viewing all articles
Browse latest Browse all 9071

OsCustomizationSpec and OSCustomizationNicMapping are they a good way to configure new VM's from Template

$
0
0

I am building a script to build VM's auto magicly when as I import the relevent information from a csv file.I have the newest version of PowerCli, I am trying to build Sever 2012 r2 servers from a template.  I have tried serveral OsCustomizationSpec (OCS)'s in hopes of getting something to work, but I have had no luck so far.  In VCenter, it shows it applying the OCS, but it doesn't apear to have any impact on the server.  I have turned off UAC since last time I tried it so maybe that will make a difference.  I am running ESXi 5.1 Update2, just to try to give all the info neccessary.  Idealy, I would like it to sysprep, set the IP's, change the computer name and join the server to the domain.  That's all!!! lol  I have the book "VMware vSphere PowerCLI Reffernece, Automating vSphere Administration, I walked through it step by step.  This newest version of PowerCli doesn't seem to have the x86 limitation that earlier versions of PowerCli did.  I have tried so many different things, I am not sure what to put up as a place to start.

 

 

# Save the credential object with permission to join the domain.
$DomainCredentials = Get-Credential 'domain\testername'
# Clone our Spec adding the domain information.
$Spec = Get-OSCustomizationSpec 'Windows Server 2012 R2'
$Spec += Get-OSCustomizationNicMapping -Spec $Spec
#$Spec | select *

# Get our VM
# Change network settings
Get-VM BigServername | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName nic-172.16.25-VLAN225 -Connected:$true `
-Confirm:$false | out-null
# Shut down guest to make change.
Shutdown-VMGuest -VM $VM -Confirm:$false | out-null
# Wait while guest shuts down
While ($vm.ExtensionData.Runtime.PowerState -ne ‘poweredOff’)
{
Start-Sleep -Seconds 1
$vm.ExtensionData.UpdateViewData(‘Runtime.PowerState’)
}
# Apply customization Spec to apply new network settings
Get-VM ‘BigServername’|
Set-VM -OSCustomizationSpec 'Windows Server 2012 R2' -Confirm:$false|
Start-VM

 

I can rebuild the template, or anything else we need to to make this work.

OR - is this just not the best way to configure VM's?  If not, what about sysprep?


Viewing all articles
Browse latest Browse all 9071

Latest Images

Trending Articles



Latest Images

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