Book Image

PowerCLI Cookbook

By : Philip Brandon Sellers
Book Image

PowerCLI Cookbook

By: Philip Brandon Sellers

Overview of this book

Table of Contents (19 chapters)
PowerCLI Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Scoping and filtering a list of snapshots


As with other cmdlets, there are several ways to approach scoping and filtering a list of snapshots in PowerCLI. There are several methods and some will have benefits in one situation over another. In this recipe, you will look at a couple of different ways to scope a list of snapshots.

Getting Started

To begin this recipe, you will need a PowerCLI window and an active connection to vCenter. You should also have completed the previous recipe.

In this recipe, you will write PowerCLI that will scope down the list of snapshots returned in the output object to only include snapshots that were created more than 30 days ago. However, since your environment might not have snapshots more than 30 days old, you can modify the code to work with 30 minute old snapshots.

You will begin by manually inputting a date to compare against the Created column of the snapshot object returned by Get-Snapshot.

How to do it…

In order to approach scoping and filtering a list of...