Get-DistributionGroupMember -Identity “GROUP_NAME@rajanmaharjan.com” -ResultSize Unlimited | Select Name, PrimarySMTPAddress | Export-CSV “D:\Rajan-1145\Office365\members-of-dl.csv” -NoTypeInformation -Encoding UTF8 Add-DistributionGroupMember -Identity “GROUP_NAME@rajanmaharjan.com” -Member “rajan@rajanmaharjan.com”
Bulk add members to Distribution List (DL)
$UserCredential = Get-CredentialGet-DistributionGroupMember -Identity “GROUP_NAME@rajanmaharjan.com” | ft alias #to get current list members$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-pssession $Session$import= import-csv -Path ‘<PATH_TO_CSV_FILE>member-to-add-in-dl.csv’ #location of CSV file$import | ForEach-Object { Add-DistributionGroupMember -Identity “GROUP_NAME@rajanmaharjan.com” -Member $_.identity Write-host $_.identity ‘added to distribution list’}
Very first #PowerShell Basic
In windows 10, you just need to do run, Type “Powershell” and choose “Windows PowerShell ISE” You must have office365 Login $UserCredential = Get-Credential –it will ask for login credentials $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-pssession $session Thats it!!!, you are now ready […]
Basic commands of PowerShell
Get-Mailbox -Identity * | ft name, alias #gives column name and an alias for all the list of emails available Get-Mailbox | sort Alias |ft Name, alias #sorts record by an alias Get-Mailbox -Identity “rajan.maharjan” | fl #give all columns for individual identity- rajan.maharjan get-MailboxMessageConfiguration -Identity rajan.maharjan | fl #to […]