1

I'm trying to find a working script to get active snapshots on vsphere 6.7. I've found this script linked to PAessler script portal:

CheckForVMwareSnapshots

The script is working running on Powershell inside the probe, but if I try to using it in Custom EXE/Script Sensor, I receive this error:

Response not well-formed: "(-1:Error occurred while checking for snapshots: System.Management.Automation.CommandNotFoundException The term 'Connect-VIServer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. . at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) )" (code: PE132)

thanks for the help!

Cipo80
  • 19
  • 4
  • might be worth working on the title of your post. seems like you'll want to get the attention of someone familiar with variables that are available to you from within powershell but not in the "custom exe/script sensor" environment. – rigsby Jun 11 '20 at 21:51

2 Answers2

0

It seems that user which is running your PRTG Probe doesn't have VMware.PowerCLI loaded. Try to import PowerShell module before you run the script - see documentation for details https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/import-module?view=powershell-7

Import-Module -Name VMware.PowerCLI

In case that this module is not installed you can install it before you run the script - just add it to the first line of that script - see this link for details https://thesysadminchannel.com/install-vmware-powercli-module-powershell/

In short - you need to add this line on the first line of the script and execute the sensor.

Install-Module -Name VMware.PowerCLI -Scope CurrentUser

Remove this line once module is installed

jana
  • 166
  • 1
  • 3
0

I've solved removing the module and imported again!

Finally I currently use this script found on git hub: https://github.com/saxos1983/prtg/blob/master/CheckForVMwareSnapshots.ps1

Cipo80
  • 19
  • 4