PRTG Vsphere snapshot script

636 Views Asked by At

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!

2

There are 2 best solutions below

0
On

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

0
On

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