Run Powershell as Scheduled Task
In the scheduled task action, program path should point to powershell.exe and add the argument: -ExecutionPolicy Bypass -File C:\path-to-your-script.ps1
In the scheduled task action, program path should point to powershell.exe and add the argument: -ExecutionPolicy Bypass -File C:\path-to-your-script.ps1
Example AD powershell query of directory information for School of Pharmacy members and affiliates. #define constants $UsersOU = “OU=Users, OU=Identity, DC=AD, DC=UNC, DC=EDU” $usefullFields = “LastLogonTimeStamp”, “createTimeStamp”, “Division”, “title”, “EmployeeID”, “samAccountName”, “GivenName”, “sn”, “Manager”, “StreetAddress”, “telephoneNumber” $today = get-date $sixMonthsAgo … Read more
This powershell script creates a function called send-report: e.g., $ACL_GROUPS = “DC=ad,DC=unc,DC=edu” $ACL_FITLER = “(name=SOP_*)” $MYEMAIL = “example@ad.unc.edu” $SUBJECT = “Access Report” $INSTRUCTIONS = “<p>Please review and reply with any changes.</p>” send-report -ou $ACL_GROUPS -filter $ACL_FILTER -to $MYEMAIL -subject $SUBJECT … Read more
This is an example of using the powershell active-directory module to query directory information. $pidFile = ‘temp.txt’ # replace with full path to file foreach($p in get-content $pidFile){ get-aduser -ldapFilter “(employeeid=$p)” -properties employeeid | select samaccountname,employeeid }
This is an example of using the active-directory powershell module to query directory information. This script queries the Connect Carolina group structure for School of Pharmacy divisions, designated by a number between 450000 and 459999, and counts the members of each … Read more
This is an example of using the active-directory powershell module to query directory information. This script produces a count of all employees (faculty and staff) by Connect Carolina division number as well as comma separated list consisting of {division number, employee … Read more