VMware

PowerCLI and Set-OSCustomizationSpec – Specify Hostname

Hi,

I’m working on a script to create VMs using powercli. The script is almost ready, but I don’t know how I can assign a new VMs name from the $ VMName variable. My code:

​

​

$OSSpecs = Get-OSCustomizationSpec -Name RDS | New-OSCustomizationSpec -Name Temp -Type NonPersistent

$NicSpecsProperties = @{OSCustomizationNicMapping= Get-OSCustomizationNicMapping -OSCustomizationSpec WsTemp }
#Assigning IP values
$NicSpecsProperties.IpMode = “UseStaticIP”
$NicSpecsProperties.IpAddress = $IP
$NicSpecsProperties.SubNetMask = $SubNetMask
$NicSpecsProperties.DefaultGateway = &Gateway
$NicSpecsProperties.dns = &DNS

Set-OSCustomizationNicMapping -IpMode $NicSpecsProperties.IpMode -IpAddress $IP -SubnetMask $NicSpecsProperties.SubNetMask -DefaultGateway $NicSpecsProperties.DefaultGateway -Dns $NicSpecsProperties.dns -Confirm:$false

Thank You for any help.


View Reddit by norbo80View Source

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Close