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 […]
Rajan’s Date Converter
API to get TODAY’s NEPALI Date (output: वि.सं २०७४ श्रावन ८, आइतबार) http://rajanmaharjan.com/getdate/ http://rajanmaharjan.com/getdate/index.php?dateType=np API to get TODAY’s English Date (output: 23 July 2017, Sunday) http://rajanmaharjan.com/getdate/index.php?dateType=en API to get TODAY’s NEPALI day or year or month or date (To display date as per your customization) http://rajanmaharjan.com/getdate/index.php?dateType=np&dformat=day (output: आइतबार) http://rajanmaharjan.com/getdate/index.php?dateType=np&dformat=yyyy (output: […]
Import xls data to MYSQL
mysql_connect(“localhost”,”root”,””) or die(“cannot connect”); mysql_select_db(“db_name”) or die(“cannot find database”); $dataSheetFile=”sample_csv.csv”; $counter=0; if (($handle = fopen($dataSheetFile, “r”)) !== FALSE) { while (($data = fgetcsv($handle, 1000, “,”)) !== FALSE) { $university=htmlentities(trim($data[0])); $faculty=htmlentities(trim($data[1])); $research_sub_group=htmlentities(trim($data[2])); $themenband=htmlentities(trim($data[3])); $street=htmlentities(trim($data[4])); $zipcode=htmlentities(trim($data[5])); $city=htmlentities(trim($data[6])); $website=htmlentities(trim($data[7])); $counter++; mysql_query(“INSERT INTO research_sub_group set university=’$university’, faculty=’$faculty’, research_sub_group=’$research_sub_group’, themenband=’$themenband’, street=’$street’, zip=’$zipcode’,city=’$city’,website=’$website'”); } } echo […]