Tuesday, June 3, 2014

How to schedule PowerShell Scripts with Parameters

The global VMware admins at the company I work at needed a mechanism to monitor the membership of AD groups associated with the virtual environment.

The following script by Francois-Xavier Cat fit the bill perfectly!  (Thanks again!)
http://www.lazywinadmin.com/2013/10/powershell-monitor-and-report-active.html

Setup was simple and it ran perfectly in the Powershell ISE.  However, when it came time to scheduling it in Windows Task Scheduler, I had a bit of trouble.  It turn out, escape characters (ex. \) are needed for it to run properly.

In the Program/script field enter the following:
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe

In the Add arguments field, the following was entered:

-command "D:\MyFolder\TOOL-MONITOR-AD_Group_20131127.ps1 -group \"group01\",\"group02\",\"group03\" -EmailFrom test@MyDomain.com -Emailto \"user01@MyDomain.com\",\"user02@MyDomain.com\",\"user03@MyDomain.com\" -emailserver smtprelay.MyDomain.com



No comments:

Post a Comment