Christoffer Reijer
Christoffer Reijer

Reputation: 1995

Check connectivity on virtual machine in vCenter

I am trying to write a small powershell script that checks the health of a newly started server. Here's what I want to do:

  1. Start VM if it's not already started
  2. Wait for Guest Tools to start running
  3. Run the powershell script Test-Connection MyDCServer -Quiet using Invoke-VMScript
  4. Act on whether the check return $true or not.

I have 1. and 2. donem but I am running into trouble on 3. All I get back from Invoke-VMScript is a string presenting the output from the script, when I really want the return value from the script that I invoked.

Is this possible?

Upvotes: 0

Views: 544

Answers (1)

Christoffer Reijer
Christoffer Reijer

Reputation: 1995

I found the solution:

$result = Invoke-VMScript ...
$result.ScriptOutput
$result.ExitCode

Upvotes: 1

Related Questions