Posts

Showing posts with the label Active Directory PowerShell

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 }