PoshCode Archive  Artifact [05b39ec6de]

Artifact 05b39ec6de9f20eeaba3ed349fcbf0da3a95011c094e8cd922453578aae51b92:

  • File Deploy-VM-with-Static-IP.ps1 — part of check-in [8b8c25dd0d] at 2018-06-10 13:04:05 on branch trunk — Deploying VM with static ip in 3 steps (user: Nedko Nedev size: 946)

# encoding: utf-8
# api: powershell
# title: Deploy VM with Static IP
# description: Deploying VM with static ip in 3 steps
# version: 0.1
# author: Nedko Nedev
# license: CC0
# x-poshcode-id: 2013
# x-archived: 2010-07-26T15:33:29
#
#
# 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