I have a powershell script that keeps throwing this error
Get-ComputerRestorePoint : This functionality is not supported on this operating system.
At line:1 char:25
+ Get-ComputerRestorePoint <<<<
+ CategoryInfo : InvalidOperation: (:) [Get-ComputerRestorePoint], ArgumentException
+ FullyQualifiedErrorId : GetComputerRestorePointNotSupported,Microsoft.PowerShell.Commands.GetComputerRestorePoin
tCommand
Is there a simple way to test to see if a cmdlet is supported before running it? I know I can throw a try catch around the cmdlet, but it this approach seems rather expensive compare to a simple check.
Thanks
You can easily check if a cmdlet is available in your session (using Get-Command) but there is not a direct way to test if an available cmdlet supports the current OS. The help notes section for this cmdlet says:
However I wouldn’t rely on the Notes being accurate. The best I can think of is what you suggest, use try/catch.