Start again function in script

I’ve written a ~250 line Powershell script to create users in AD. It prompts for all of the required fields, then takes the data and creates the account, creates a second file for our password reset tool, and syncs to Azure. I’m trying to add Office 365 licensing in too, but if I have a batch of users to do, I’d like to hold off on syncing to Azure and licensing users until I’ve done all of the users to keep from getting rate-limited. So, an “add another (y/n)” type of prompt seems to make sense.

The question is, how to actually start again? My guess is I need to encapsulate my entire prompt/create setup in a function, and then just call the function, but I didn’t know if there’s a better way. I’d guess I’d also store the completed users in an array to apply Office 365 licensing once the sync to Azure is completed.

submitted by /u/smalltimesysadmin
[link] [comments]

Leave a Reply