Solved

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

Posted on 2014-02-13
8
2,101 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
  • 5
  • 3
8 Comments
 
LVL 25

Expert Comment

by:Zephyr ICT
Comment Utility
What version of PowerCLI are you using?
0
 
LVL 2

Author Comment

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

Expert Comment

by:Zephyr ICT
Comment Utility
Hmmm strange, the thing is, when you look at the info about this cmdlet it's supposedly not supported for Windows 2012..
0
 
LVL 2

Author Comment

by:itnifl
Comment Utility
Is there a workaround or another CMD'let I could use?
0
Want to promote your upcoming event?

Are you going to an event? Are you going to be exhibiting at a tradeshow? Talking at a conference? Using a promotional banner in your email signature ensures that your organization’s most important contacts stay in the know and can potentially spread the word about the event.

 
LVL 25

Expert Comment

by:Zephyr ICT
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Seems like I found my own solution..
0

Featured Post

Are your corporate email signatures appalling?

Is it scary how unprofessional your email signatures look? Do users create their own terrible designs and give themselves stupid job titles? You can make this a lot easier for yourself by choosing an email signature management solution from Exclaimer today.

Join & Write a Comment

Will try to explain how to use the VMware feature TAGs in the VMs and create Veeam Backup Jobs using TAGs. Since this article is too long, I will create second article for the Veeam tasks.
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Teach the user how to rename, unmount, delete and upgrade VMFS datastores. Open vSphere Web Client: Rename VMFS and NFS datastores: Upgrade VMFS-3 volume to VMFS-5: Unmount VMFS datastore: Delete a VMFS datastore:
Teach the user how to convert virtaul disk file formats and how to rename virtual machine files on datastores. Open vSphere Web Client: Review VM disk settings: Migrate VM to new datastore with a thick provisioned (lazy zeroed) disk format: Rename a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now