Solved

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

Posted on 2014-02-13
8
2,224 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
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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
EVC and clusters 12 55
VMware 6.0 client integration plugin not working 2 69
Powershell Split 18 27
Need to export the list of AD users with below attrubutes 2 15
In this article, I will show you HOW TO: Suppress Configuration Issues and Warnings Alert displayed in Summary status for ESXi 6.5 after enabling SSH or ESXi Shell.
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
Teach the user how to install and configure the vCenter Orchestrator virtual appliance Open vSphere Web Client: Deploy vCenter Orchestrator virtual appliance OVA file: Verify vCenter Orchestrator virtual appliance boots successfully: Connect to the …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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