?
Solved

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

Posted on 2014-02-13
8
Medium Priority
?
2,377 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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
1
 
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

Introducing the WatchGuard 420 Access Point

WatchGuard's newest access point includes an 802.11ac Wave 2 chipset, providing the fastest speeds for VoIP, video and music streaming, and large data file transfers. Additionally, enjoy the benefits of strong security as the 3rd radio delivers dedicated WIPS protection!

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
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.
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 use configure the vCenter Server storage filters Open vSphere Web Client:  Navigate to vCenter Server Advanced Settings: Add the four vCenter Server storage filters: Review the advanced settings: Modify the values of the four v…

719 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