VMware Cloud Community
ga2peio
Contributor
Contributor
Jump to solution

Creating / removing multiple snapshots through PowerCLI from a text file list

I'm very green to PowerCLI. I am looking to create multiple snapshots through PowerCLI, and pull the list of vm's from a text file.

Is this possible ?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Sure

Get-VM -Name (Get-Content -Path .\vmnames.txt)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

5 Replies
LucD
Leadership
Leadership
Jump to solution

Yes


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ga2peio
Contributor
Contributor
Jump to solution

Do you mind sharing what the command looks like if I want to pull the list of vm's from a text file ?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure

Get-VM -Name (Get-Content -Path .\vmnames.txt)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

ga2peio
Contributor
Contributor
Jump to solution

Thank you so much ! With your command, this is what I put together.

 

To create new snapshots ...

Get-VM -Name (Get-Content -Path .\vmservers.txt) | New-Snapshot -Name "SnapshotName" -Description "Created $(Get-Date)" –RunAsync

 

To remove the snapshots from those same vm's ...

Get-VM -Name (Get-Content -Path .\servers.txt) | Get-Snapshot | Remove-Snapshot -confirm:$false

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Nice, just watch out with the RunAsync.
Running a lot of snapshots in parallel might have a performance impact on your environment


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos