Contributor
Contributor

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

Jump to solution

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
Leadership
Leadership

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
Leadership
Leadership

Yes


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

0 Kudos
Contributor
Contributor

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
Leadership
Leadership

Sure

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


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

View solution in original post

Contributor
Contributor

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
Leadership
Leadership

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