PoshCode Archive  Artifact [f225f62c61]

Artifact f225f62c6131802a7cc74afb30ae5a61003bb6f07dbacef75d5f06d5ac39d194:

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

# encoding: utf-8
# api: powershell
# title: Deploy VM with Static IP
# description: Deploying a VM with Static IP in 3 steps
# version: 0.1
# author: Nedko Nedev
# license: CC0
# x-poshcode-id: 2015
# x-archived: 2016-07-16T12:54:21
# x-published: 2011-07-23T01:21:00
#
#
# 1. Create a simple customizations spec:
$custSpec = New-OSCustomizationSpec -Type NonPersistent -OSType Windows `
    -OrgName “My Organization” -FullName “MyVM” -Domain “MyDomain” `
    –DomainUsername “user” –DomainPassword “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