PoshCode Archive  Artifact [f6490e8faa]

Artifact f6490e8faab9b280c95f9254892e26ad3ae906b5fc5116f13fb1f1293c8866a9:

  • File Deploy-VM-with-Static-IP.ps1 — part of check-in [f6644c54ed] at 2018-06-10 13:04:04 on branch trunk — Deploying a VM with Static IP in 3 Lines (user: Nedko Nedev size: 909)

# encoding: utf-8
# api: powershell
# title: Deploy VM with Static IP
# description: Deploying a VM with Static IP in 3 Lines
# version: 0.1
# author: Nedko Nedev
# license: CC0
# x-poshcode-id: 2011
# x-archived: 2010-07-26T15:33:24
#
#
# 1. Create a simple customizations spec:
$custSpec = New-OSCustomizationSpec -Type NonPersistent -OSType Windows -OrgName �My Organization� -FullName �MyVM� -Domain �MyDomain� �DomainAdminUsername �user� �DomainAdminPassword �password�
# 2. Modify the default network customization settings:
$custSpec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress 192.168.121.228 -SubnetMask 255.255.248.0 -Dns 192.168.108.1 -DefaultGateway 192.168.108.1
# 3. Deploy a VM from a template using the newly created customization:
New-VM -Name �MyNewVM� -Template $template -VMHost $vmHost -OSCustomizationSpec $custSpec