VMware Cloud Community
hypermx1
Contributor
Contributor

set-VmGuestRoute Error in commnuication?

Hello.

I'm trying to create a PowerCli Script to add and remove routes in a guest OS.

But with my current command, it fails saying:

Get-VMGuestRoute : 23-05-2012 10:32:03    Get-VMGuestRoute        While perform
ing operation 'Open VM file '[OPR_VDI] OPR-WIN7-20/OPR-WIN7-20.vmx'' the follow
ing error occured: 'There was an error in communication'
+ get-vmguestroute <<<<  -VM $VM -GuestUser $VMUser -GuestPassword $VMPassword
    + CategoryInfo          : OperationStopped: (:) [Get-VMGuestRoute], VimExc
   eption
    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_VixWaitForJob_VixErr
   or,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVmGuestRoute

Current script:

add-pssnapin VMware.VimAutomation.Core

set-PowerCLIConfiguration -invalidCertificateAction "ignore" -confirm:$false

$vCenter = "center_address"

$VCUser = "center_user"

$VCPassword = "center_password"

$VMUser = "Network admin with all permissions"

$VMPassword = "network password"

$VMName = "OPR-WIN7-20"

## Login

Connect-VIServer -Server $vCenter -User $VCUser -Password $VCPassword

## Get VM ID

$VM = Get-VM $VMName

## Add default gateway

$VM | New-VMGuestRoute -Destination 0.0.0.0 -Netmask 0.0.0.0 -Gateway 92.43.233.1 -GuestUser $VMUser -GuestPassword $VMPassword -Confirm:$false

Disconnect-VIServer -Server $vCenter -Confirm:$false

I've also tryed with just get-VmGuestRoute to see if there was something wrong with the above command.

As it is now, im thinking about if it could be something with the user? And im also unable to find any information about this on google Smiley Happy

0 Kudos
41 Replies
LucD
Leadership
Leadership

Are you running the script from a 32-bit PowerCLI session ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
hypermx1
Contributor
Contributor

Yes, Im running the script in a PowerCli 32Bit session.

0 Kudos
LucD
Leadership
Leadership

Just like the Invoke-VMScript cmdlet, the New-OSGuestRoute cmdlet has a couple of prerequisites.

You could check with the script from my Will Invoke-VMScript work ? post if all the prereqs are met.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
hypermx1
Contributor
Contributor

Hmm, Im unable to run the function proberly.

When i paste the script in my shell, it makes ">>" on every new line, like its waiting for something

I have to CTRL+C to get back.

What did i do wrong?

0 Kudos
LucD
Leadership
Leadership

Save my script in a .ps1 file.

Then from the PowerCLI prompt do

PS C:\> . .\filename.ps1

PS C:\> $vm = Get-VM MyVM

PS C:\> Test-InvokeVMScript -VM $vm

In the first line you dot-source the .ps1 file (there is a blank between the two dots).

That way the function is know/defined in your PowerCLI session.

Then call the function with the VM as parameter.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

hypermx1
Contributor
Contributor

Doing that, and running the function gets me:

WARNING: 'Host' property is obsolete. Use 'VMHost' instead.
                                     OK VM
                                     -- --
                                  False OPR-WIN7-20
0 Kudos
Grzesiekk
Expert
Expert

Hello,

  can you please test this ?

Invoke-VMScript -VM OPR-WIN7-20 -GuestCredential (Get-Credential) -ScriptType Powershell -ScriptText "route print"

Does this print the route table or do you get error ?  Please run this as it is, and provide the credentials when asked

--- @blog https://grzegorzkulikowski.info
0 Kudos
LucD
Leadership
Leadership

Ok, so there is prereq missing.

Add the -Detail parameter on the function call.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

hypermx1
Contributor
Contributor

Command "Invoke-VMScript -VM OPR-WIN7-20 -GuestCredential (Get-Credential) -ScriptType Powershell -ScriptText "route print" " Doesnt not work.

Same error.

And using the detail parameter i get:

OK                               : False
VM                               : OPR-WIN7-20
PoweredOn                    : True
X86Engine                    : True
ToolsInstalled              : True
Port902Open                 : False
FolderReadAccess            : True
PrivilegeConsoleInteraction : True
SupportedOS                 : True
0 Kudos
LucD
Leadership
Leadership

It looks as if port 902 is not open.

Do you have a Firewall active on your client or on the vCenter ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
hypermx1
Contributor
Contributor

All firewalls are disabled.

I've tryed to run the commands from another machine, where it worked fine? Which really bugs me Smiley Sad

0 Kudos
LucD
Leadership
Leadership

Perhaps another application or service is blocking port 902 ?

Does 'netstat -a' reveal anything ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
hypermx1
Contributor
Contributor

Acording to Netstat -a, nothing is currently using port 902.

0 Kudos
LucD
Leadership
Leadership

What does

telnet Your-vCenter 902

say ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
hypermx1
Contributor
Contributor

Both on the working and on the not working machine:

"

Connecting To myVCenterAddress...Could not open connection to the host, on p
ort 902: Connect failed

"

0 Kudos
LucD
Leadership
Leadership

That is strange !?!

Does my function also marks port902 as False on the PC where the script seems to be working  ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
hypermx1
Contributor
Contributor

On the working machine.

OK                          : True
VM                          : OPR-WIN7-20
PoweredOn                   : True
X86Engine                   : True
ToolsInstalled              : True
Port902Open                 : True
FolderReadAccess            : True
PrivilegeConsoleInteraction : True
SupportedOS                 : True
0 Kudos
LucD
Leadership
Leadership

That's what to expect when the script is working ok.

But then I don't get why the telnet over port 902 doesn't work on that PC.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
hypermx1
Contributor
Contributor

My co-worker just said that its a windows machine, and it have telnet disabled.

Is telnet required for this to work?

0 Kudos