Good morning all,
I am reaching out to see if anyone could assist me as my PowerShell knowledge is very limited. I am very new to PowerShell and unfortunately don’t know If I myself can pull off what I am trying to achieve, so any help would be greatly appreciated.
I work in a office environment and when people leave we need to
- Disable O365 account
- Remove all group memberships
- Hide from Global Address Book
- Prepend “Leaver 2022 -” at the start of the users name (Example: Leaver 2022 - John Smith)
As we manage multiple other office tenants, I am essentially looking to see if we can make a PowerShell script that will authenticate with admin credentials, then request for a variable users email and BOOM! It may be a complete shot in the dark and not even possible but any advice would be great.
I can get my head around basic PowerShell and have managed to come up with a structure.
# Script to connect to Exchange Online / M365, automate the leaver process.
#Variables
# Import Modules
Install-Module MSOnline
Install-Module AzureAD
# Connect to Exchange
Connect-MsolService
# Choice to list all users or Read-Host
# Read Host for UserPrincipalName
# Are you sure?
# Use the variable from Read-Host and perform actions against user account
# Action 1
# Action 2
# Action 3
# Action 4
# Are you finished? Perform against another account?
# Add this functionality later
# Close session / connection if finished
Many thanks in advance for any help with this at all!