Solved

Windows 2012 R2 and error with Get-VMGuestNetworkInterface: "Unable to parse script output"

Posted on 2014-02-13
8
2,252 Views
Last Modified: 2014-02-27
I have this powershell script here below. It works fine for all various VMs that we have, except the new Windows 2012 R2 OS's we have created.

$vCenterHost = "vCenter"
$vCenterUser = "domain\vmCreator"
$vCenterPass = "superSecret123"

function ConnectVIServer([string]$vCenterHost, [string]$vCenterUser, [string]$vCenterPass) {
	#The Following is compatible with version 5.1 of powercli: 
	Set-PowerCLIConfiguration -DefaultVIServerMode Single -InvalidCertificateAction Ignore -WebOperationTimeoutSeconds -1 -confirm:$false
	Connect-VIServer -Server $vCenterHost -User $vCenterUser -Password $vCenterPass
}

$vmname = "SuperServer"
$NewPassword = "SuperSecret321"
$newNetworkName = "myPortGroup"
$IP = "10.10.42.130"
$mask = "255.255.255.0"
$gateway = "10.10.42.10"
$dns1 = "10.10.42.200"
$dns2 = "10.10.42.201"

if($vmname -eq "" -or $vmname -eq $null) {
	throw "No vmname entered"
}

$ErrorID = 0

if(-not (Get-PSSnapin VMware.VimAutomation.Core 2> $NULL)) { 
    Add-PSSnapin VMware.VimAutomation.Core 
}
ConnectVIServer $vCenterHost $vCenterUser $vCenterPass

if(!$dns1) {  
	$dns1 = "8.8.8.8"
}
if(!$dns2) {  
	$dns2 = "8.8.8.8"
}

try {
	get-vm $vmname | Get-NetworkAdapter | % {
		(Get-VMGuestNetworkInterface -VM $vmname -GuestUser .\administrator -GuestPassword $NewPassword -ToolsWaitSec 32 | where-object {($_.Name).ToLower() -match "local area connection" -and $_.IP -ne $NULL}) | %{ Set-VMGuestNetworkInterface -VmGuestNetworkInterface $_ -Ip $IP -Netmask $mask -Gateway $gateway -Dns $dns1 -GuestUser .\administrator -GuestPassword $NewPassword}
	}
} catch {
	$ErrorID = "8"
	$ErrorMessage = $_.Exception.Message
	$FailedItem = $_.Exception.ItemName
	throw "ERROR: 700 Could not set IP on vm: $FailedItem - $ErrorMessage"
}
try {
	get-vm $vmname | Get-NetworkAdapter | % {
		$_ | Set-NetworkAdapter -NetworkName $newNetworkName -Confirm:$false		
	}
} catch {
	$ErrorID = "7"
	$ErrorMessage = $_.Exception.Message
	$FailedItem = $_.Exception.ItemName
	throw "ERROR: 800 Could not set VLAN on vm: $FailedItem - $ErrorMessage"
}

Open in new window


The scripts sets the VLAN correctly, but at line 39 to 41 it is not able to set the IP settings. The error is as follows:


Get-VMGuestNetworkInterface : 13.02.2014 09:10:14    Get-VMGuestNetworkInterfac
e        Unable to parse script output.
At C:\ScriptSources\Scripts - LAB_PROD\PROD\5. Set final VLAN and IP.ps1:40 cha
r:4
+         (Get-VMGuestNetworkInterface -VM $vmname -GuestUser .\administrator -
GuestPass ...
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-VMGuestNetworkInterfac
   e], ViError
    + FullyQualifiedErrorId : Client20_VmHostServiceImpl_GetVmGuestNetworkInte
   rface_UnableToParse,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVmGues
  tNetworkInterface
0
Comment
Question by:itnifl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39855600
What version of PowerCLI are you using?
0
 
LVL 2

Author Comment

by:itnifl
ID: 39855604
VMware vSphere PowerCLI 5.5 Release 1. vSphere environment is 5.1.
0
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39855614
Hmmm strange, the thing is, when you look at the info about this cmdlet it's supposedly not supported for Windows 2012..
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 2

Author Comment

by:itnifl
ID: 39855624
Is there a workaround or another CMD'let I could use?
0
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39855639
Check the installation folder of PowerCLI to see if there's another cmdlet specified for 2012R2 per directions in the manual on page 26

I don't have access to a PowerCLI 5.5 installation at the moment to check for you...
0
 
LVL 2

Author Comment

by:itnifl
ID: 39858971
According to https://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.powercli.cmdletref.doc%2FSet-VMGuestNetworkInterface.html the cmdlet is only supported with Windows XP 32 SP3, Windows Server 2003 32bit SP2, Windows Server 2003 64bit SP2, Windows 7 64 bit, Windows Server 2008 R2 64bit and Redhat Enterprise 5 operating systems.

The system I am running it against is Windows 2012 R2
0
 
LVL 2

Accepted Solution

by:
itnifl earned 0 total points
ID: 39878968
I ended up with setting the server in a VLAN where I could reach it over SMB and changing IP with psexec. Psexec can transfer and run a batch file that uses various netsh commands.
0
 
LVL 2

Author Closing Comment

by:itnifl
ID: 39891393
Seems like I found my own solution..
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When converting a physical machine to a virtual machine using VMware vCenter Converter Standalone or vCenter Converter Enterprise, if an adapter type is not selected during the initial customization the resulting virtual machine may contain an IDE d…
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Teach the user how to configure vSphere Replication and how to protect and recover VMs Open vSphere Web Client: Verify vsphere Replication is enabled: Enable vSphere Replication for a virtual machine: Verify replicated VM is created: Recover replica…
Teach the user how to use create log bundles for vCenter Server or ESXi hosts Open vSphere Web Client: Generate vCenter Server and ESXi host log bundle:  Open vCenter Server Appliance Web Management interface and generate log bundle: Open vCenter Se…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question