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

Scheduling automatic snapshot remediation


With the function in an established form, you can take and execute the .ps1 file using the Windows Task Scheduler. Creating the scheduled task for a PowerShell requires that you set up some basic things within the .ps1 file that has your function. You will also want to run the function with a given set of parameters for this scheduled task. All of these things can be added into the file.

In order to use a .ps1 file, you will need to change the execution policy and sign your code file. Code signing for PowerShell and PowerCLI adds a trusted digital signature to a file, allowing PowerShell to identify the source and trust the file if the signature is trusted. Code signed with a trusted publisher can be run on a Windows machine with a more secure PowerShell execution policy set to AllSigned or RemoteSigned. Code files that have not been signed require the Unsigned execution policy to be set, but this is not secure since even malicious PowerShell could...