Posts

Export AD user's group membership - Active Directory PowerShell

Export AD user's group membership -  Active Directory PowerShell For a single user: For a single user run the below command in Active directory Powershell. Get-ADUser -identity "user-SAMaccountname" | Get-ADPrincipalGroupMembership | select distinguishedName, SamAccountName, GroupCategory, GroupScope, name, objectClass For Multiple user: create a csv file (group-export.csv) with a column named "sam" who's group membership should be exported. The below command in Active directory Powershell will create one csv output file for each user provided as input in csv file. $users = import-csv group-export.csv foreach ($user in $users)  { $filename = $user.sam Get-ADUser -identity $user.sam | Get-ADPrincipalGroupMembership | select distinguishedName, SamAccountName, GroupCategory, GroupScope, name, objectClass | Export-csv "$filename.csv" -NoTypeInformation }

create AD contacts, Bulk create AD contacts - Active Directory PowerShell

Image
Create AD contacts, Bulk create AD contacts - Active Directory PowerShell Create AD contact To create a single AD contact, use the below powershell command. New-ADObject -Type "Contact" -Name "Displayname" -DisplayName "Displayname" -Description "Description" -Path "OU=Contacts,DC=domain,DC=com" -OtherAttributes @{ sn="surname";givenName="firstname";mail="externalemailaddress";mailNickname="sn.gn";targetAddress="SMTP:externalemailaddress";title="title";physicalDeliveryOfficeName="officelocation"} Bulk create AD contacts Create a csv file (contact_creation.csv) for the contacts with their external email address, user details description. The Column names as in the below snapshot . Open Active directory powershell as an administrator and run the below command to create contacts in bulk. $users= Import-csv " contact_creation.csv " f...

Add description to AD contact and bulk add description for contacts - Active Directory PowerShell

Image
Add description to AD contact- Active Directory PowerShell To update a single contact with description Get-adobject -filter {mail -eq  "user@domain.com"} | set-adobject -description "contract employee" Bulk add description for contacts Create a csv file (contact_desc.csv) for the contacts with their external email address and description. The Column names as in the below snapshot . Open Active directory powershell as an administrator and run the below command to update the contacts with description. $users = Import-Csv contact_desc.csv foreach($user in $users) { $ExternalEmailAddresses=$User.ExternalEmailAddress $des1=$user.des Get-adobject -filter {mail -eq $ExternalEmailAddresses} | set-adobject -description $des1 }

Remove mails from Exchange online user mailbox

Remove the emails from Exchange online user mailbox When SPAM emails have been delivered to user mailbox, admin must remove the emails from mailboxes by determining recipients of the spam email and deleting them from recipient mailbox. Or in some instances confidential emails shared internally to the wrong user/recipient. For a precaution, I would suggest you have one shared mailbox to be created for such activities and save the deleted emails to this shared mailbox. Connect to Exchange online powershell Run a trace for emails with the below power shell command and the report will be exported into the CSV file. Get-MessageTrace -SenderAddress "sender@spam.com" -StartDate “start date in mm/dd/yyyy” -enddate “end date in mm/dd/yyyy” -Pagesize 5000 | Export-csv “output.csv" Filter the columns based on the subject and copy the recipient field to another csv file which would be the input for the future commands. Ensure the column name is s...

Clearing Exchange online mailbox purge, dumpster folder

Clearing mailbox purge folder What to do when you have a Exchange plan2 licensed user under litigation hold going over the maximum mailbox quota of 100GB. Try to find out the mailbox folder statistics, disable litigation and run the commands to clear the contents of purge folder. Connect to Exchange online powershell Get the user folder statistics Get-MailboxFolderStatistics -Identity "useralias@domain.com" | Select name,Foldersize,itemsinFolder Enter any of the following command to clear the purge folder. 1) Set-Mailbox –identity useralias@domain.com -LitigationHoldEnabled $False Disables litigation hold set on the user mailbox 2) Set-Mailbox –identity useralias@domain.com -RetainDeletedItemsFor 1:00:00:00 Sets retain deleted items to 1 day 3) Set-mailbox –identity useralias@domain.com –RemoveDelayHoldApplied Removes the delay hold which is used to prevent accidental deletions, which may delay 4) Start-ManagedFolderA...

Recover Office365 group

Image
Recover Office365 group Deleted Office365 group can be recovered using Azure AD powershell. The retention period is 30 days and group can be recovered if they are in soft deleted.Connect to your environment and search for the deleted group. Connect to Azure AD powershell Enter following command to view the list of soft deleted groups. Get-AzureADMSDeletedGroup Copy the ID of the group and use in the following syntax to recover the group. Restore-AzureADMSDeletedDirectoryObject -Id "groupID" The recovered group will be visible back in the EAC and also to group members.

Creating resource (room or resource) mailboxes on Office365 Exchange online hybrids

Creating resource (room or resource) mailboxes on Office365 Exchange online hybrids Create a AD object and then enable a remote mailbox from On-Prem Open Active Directory users and computers console.  Navigate to the desired OU (remember that the OU should be Synced to Office365) Right Click on the OU to create a New user. Complete the user details in the New Object dialog box and click on finish. Open exchange management powershell on the Hybrid servers and run the below command to enable a remote mailbox for the user. Enable-RemoteMailbox -Identity "useralias@domain.com"  -primarysmtpaddress " useralias@domain.com" -RemoteRoutingAddress "useralias@tenant.mail.onmicrosoft.com" Please add " smpt: useralias@tenant.mail.onmicrosoft.com " to proxyaddress list to avoid mail flow issues. Wait for the object to Sync We would be able to search for the user in Office365 Admin console once the sync is completed. We would be searching ...

Converting office365 exchange online mailbox to resource (room or equipment) mailbox

Converting office365 exchange online mailbox to resource (room, equipment) mailbox Conversion of the regular to resource (room or equipment) mailbox is done through Powershell. Please follow the below link and steps. Connect to Exchange online powershell Enter any of the following command to convert the mailbox to room.  Set-Mailbox -Identity "useralias@domain.com" -Type  room Set-Mailbox "useralias@domain.com" -Type  room Enter any of the following command to convert the mailbox to equipment.  Set-Mailbox -Identity "useralias@domain.com" -Type  equipment. Set-Mailbox "useralias@domain.com" -Type  equipment.

Creating shared mailboxes on Office365 / Exchange online hybrids

Creating shared mailboxes on Office365 / Exchange online hybrids Create a AD object and then enable a remote mailbox from On-Prem Open Active Directory users and computers console.  Navigate to the desired OU (remember that the OU should be Synced to Office365) Right Click on the OU to create a New user. Complete the user details in the New Object dialog box and click on finish. Open exchange management powershell on the Hybrid servers and run the below command to enable a remote mailbox for the user. Enable-RemoteMailbox -Identity "useralias@domain.com"  -primarysmtpaddress " useralias@domain.com" -RemoteRoutingAddress "useralias@tenant.mail.onmicrosoft.com" If you need Archive to be enabled, run the below command as well. Enable-RemoteMailbox -Identity "useralias@domain.com" -Archive Please add " smpt: useralias@tenant.mail.onmicrosoft.com " to proxyaddress list to avoid mail flow issues. Wait for the obje...

Converting office365 exchange online mailbox to shared

Image
Converting office365 exchange online mailbox to shared This can be done through EAC or Powershell Using EAC Log on to  Office365 portal  then navigate to Exchange Admin Center (EAC) or open  EAC  directly. Select Admin tile to view your Admin center page. Select Exchange from the Admin drop down.  Select mailboxes from the EAC page (or) Recipients > mailboxes  search and select the mailbox.  On the right hand pane, please click on convert to change the mailbox to shared Using Powershell Connect to Exchange online powershell Enter any of the following command to convert the mailbox to shared.  Set-Mailbox -Identity "useralias@domain.com" -Type shared  Set-Mailbox "useralias@domain.com" -Type shared