Solved

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

Posted on 2014-02-13
8
2,277 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Giving access to ESXi shell console is always an issue for IT departments to other Teams, or Projects. We need to find a way so that teams can use ESXTOP for their POCs, or tests without giving them the access to ESXi host shell console with a root …
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

707 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