Posts

Showing posts from April, 2020

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...