Posts

Showing posts from March, 2024

PowerShell: Update User Permissions for a Shared Mailbox or Calendar using Add-MailboxFolderPermission

 I use this simple script to update permissions for a Shared Calendar for a group of Users.  This can be used for updating permissions to other Shared Mailbox Folders also. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #Connect to Exchange Online Connect-ExchangeOnline -UserPrincipalName alex.g @COMPANY .com #Create a list of User email addressses by seraching specific OUs and adding them to a users variable. $users = get-aduser -filter * -SearchBase "OU=MEC_Operations,OU=MEC,OU=COMPANY Users,DC=COMPANY,DC=local" -Properties mail | Select-Object mail $users += get-aduser -filter * -SearchBase "OU=COL_Operations,OU=COL,OU=COMPANY Users,DC=COMPANY,DC=local" -Properties mail | Select-Object mail $users += get-aduser -filter * -SearchBase "OU=HAR_Operations,OU=HAR,OU=COMPANY Users,DC=COMPANY,DC=local" -Properties mail | Select-Object mail $users += get-aduser -filter * -SearchBase "OU=RIC_Operations,OU=RIC,OU=

An Offboarding Script for On-Prem Active Directory

A while back I wrote an Offboarding Script that I still maintain.  It has saved me a ton of time throughout the years.   This code does several things, So let's go through the steps. Step 1. Import the Active Directory (AD) module into Powershell. Step 2. Prompts the user to enter the username of the user being offboarded. Step 3. Gets information about that user and sets those objects to variables. Step 4. Disables the account Step 5. Generates a random password and resets the user's password to the new randomly generated password. Step 6. Sets one of the extension attributes to today's date for use in a later account deletion script. Step 7. Gets the OU the user resides in and adds that information to the log file generated at the end of this script. Step 8. Gets the permissions, security groups, and distribution lists the user was a member of and adds them to the log file. Step 9. Clears all user permissions. Step 10. Moves the account to the Terminated OU. Step 11. Imp