Skip to main content

Run Powershell as Scheduled Task

September 9, 2016

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

Directory Information

August 22, 2016

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 … Continued

Report Role and ACL group membership

August 17, 2016

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 … Continued

Get onyen from list of PIDs

June 20, 2016

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 }

FTE count grouped by role and division

May 5, 2016

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 … Continued

FTE Directory Information

April 4, 2016

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 … Continued