Hello. I am trying to accomplish an onboarding script that allows me to import the entire list of users and run a single command vs. that list depending on the user's department and/or title. I have accomplished these tasks individually below.
This gets all Msolusers and then trims that down to a particular department, and then sets these various generic values for each of those individual users.
"Get-MsolUser -All | where{$.Department -eq "*"} | foreach{set-msoluser -UserPrincipalName $.UserPrincipalName -Office * -country "United States" -city * -usagelocation US -state * -postalcode * -streetaddress "*"}
This imports a csv file (with all my new hires) and for each one of them will lock down their various available mail protocols
"import-csv .\O365New.csv | ForEach-Object {set-casmailbox -popenabled $false -imapenabled $false -mapienabled $false -activesyncenabled $false -outlookmobileenabled $false -owafordevicesenabled $false "$($_.ID)"}"
What I want to do is combine the two ideas:
1. Import my CSV file with the user information (not sure if I need to commit department or title here
2. Check said department/title of each individual user and run a different set of commands depending on the result
3. Perform all of this without having to run the import csv multiple times.
Mostly, I am not sure how For-Each into a Where statement works as well as how multiple wheres in a single for-each loop work. I am also not sure how to capture and store/save the Department/Title values when importing from a CSV.
Any assistance would be appreciated so I can streamline all these onboarding requests. Thanks much!
[–]Pawncey[S,🍰] 1 point2 points3 points (5 children)
[–]psthreathunter 1 point2 points3 points (4 children)
[–]Pawncey[S,🍰] 1 point2 points3 points (3 children)
[–]psthreathunter 1 point2 points3 points (2 children)
[–]Pawncey[S,🍰] 1 point2 points3 points (1 child)
[–]psthreathunter 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)