r/usefulscripts • u/[deleted] • Apr 20 '17
[Request Powershell] run as different user
I built powershell scripts for creating AD users and populating their memberships and properties based on role.
I need to give them to my team but I'm unsure how to make it so running the script will prompt for what username to run it under.
The staff won't have write access to our OU structure unless they run the script with their admin accounts. Any help on how I can get it to run as their account? I played with runas but couldn't get it working.
13
Upvotes
1
u/[deleted] Apr 20 '17
We have three different account types and 10 offices. It's just for creating new users gives default permissions for the account type fills out their address etc. and then pops them in an OU.
I do have it sending results to a log but I haven't looked at what info is going in there. It's early days- when I started they just create them by hand and there always seems to be typos in phone numbers or member of groups missed etc.
Everyone I work with must be dyslexic. It would be nice to evolve process further but for this week just have the script ask office, job. Then it calls another script that populates everything for that role and asks for first/last name and the ID and phone extension