VMware Cloud Community
Mueller2
Contributor
Contributor

Problem with Remove-Snapshot (PowerCLI)

Hello,

 

why does Command 1 work but command 2 doesn't:

1: 

Get-VM | Get-Snapshot | Where-Object -FilterScript {$_.Created -lt $timestamp} | Remove-Snapshot
 
2:
Get-VM | Get-Snapshot | Where-Object -FilterScript {$_.Created -lt $timestamp} | Select-Object -Property name, vm, Created, SizeGB | Remove-Snapshot
 
The second command throws the following error: "Remove-Snapshot: The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input."
 
Can anyone explain why?
 
Thank you very much.
0 Kudos
2 Replies
scott28tt
VMware Employee
VMware Employee

There is an area dedicated to PowerCLI, expect a moderator to move your thread there, now that I have reported it.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
0 Kudos
Macleud
Enthusiast
Enthusiast

Hello.

Command 1 transfer an object in a remove-snapshot "VMware.VimAutomation.ViCore.Impl.V1.VM.SnapshotImpl"

Command 2 object type "Selected.VMware.VimAutomation.ViCore.Impl.V1.VM.SnapshotImpl"

Cannot convert the value of type "Selected.VMware.VimAutomation.ViCore.Impl.V1.VM.SnapshotImpl" to type "VMware.VimAutomation.ViCore.Types.V1.VM.Snapshot".

Use this example:

$Snapshot = Get-VM | Get-Snapshot | Where-Object -FilterScript {$_.Created -lt $timestamp}

$Snapshot | Select-Object -Property name, vm, Created, SizeGB

$Snapshot | Remove-Snapshot

0 Kudos