PowerShell Commands for a O365 System Admin

Create New O365 User

Connect-MsolService​

New-Msoluser -UserPrincipalName torky.elenazy@alamarfoods.com -DisplayName "Torky ElEnazy" -FirstName Torky -LastName Elenazy -Country SA -MobilePhone +966594399666 -Fax SADP01334 -Department "Human Resources" -Title "Recruiter Assistant" -UsageLocation SA

Adding License to user

Set-MsolUserLicense -AddLicenses AlamarFoods:O365_BUSINESS_PREMIUM -UserPrincipalName mohammed.hemdan@alamarfoods.com

Add Manager Credentials – first connect to Exchange Online

Add Manager – MFA Enabled

Connect to EAC<Hybrid<Exchange Online Powershell with MFA

Connect-EXOPSSession -UserPrincipalName shrenik.salguna@alamarfoods.com

(in Hybrid PowerShell )

Set-User -Identity mohammed.hemdan@alamarfoods.com -Manager mohammed.roustom@alamarfoods.com

Set-ExecutionPolicy RemoteSigned

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session

Add to Distribution List – (Office365 Groups)

Add-DistributionGroupMember -Identity "Alamar Foods" -Member "kiran.venugopal@alamarfoods.com"

Add-DistributionGroupMember -Identity "Alamar Corporate" -Member "kiran.venugopal@alamarfoods.com"

Add to O365 Group

Add-UnifiedGroupLinks -Identity "Alamar Foods KSA" -LinkType Members -Links kiran.venugopal@alamarfoods.com

Create New User in Active Directory

New-ADUser -Name "Kiran Venugopal" -GivenName "Kiran" -Surname "Venugopal" -SamAccountName "kiran.venugopal" -UserPrincipalName "kiran.venugopal@alamarfoods.com" -Office "Head Office" -EmailAddress "kiran.venugopal@alamarfoods.com" -Mobile "+971551477891" -Title "KSA Financial Analyst" -Department "Finance" -Path "OU=Finance,OU=HO Users,OU=Saudi Arabia-HO,DC=alamarfoods,DC=local" -AccountPassword(Read-Host -AsSecureString "Aa123456") -Company "Alamar Foods | KSA" -City "Riyadh" -Country ‘SA’ -StreetAddress "AlOlaya District, Street No. 36, Building No. 3" -POBox ‘4748’ -Manager "usama.ruby" -Enabled $true

For MENAP Users

New-ADUser -Name "Mohamed Younes" -GivenName "Mohamed" -Surname "Younes" -SamAccountName "mohamed.younes" -UserPrincipalName "mohamed.younes@alamarfoods.com" -Office "Head Office" -EmailAddress "mohamed.younes@alamarfoods.com" -Mobile "+20106644628" -Title "Warehouse Supervisor" -Department "Supply Chain" -Path "OU=Commissary,OU=EG Users,OU=Egypt,OU=MENAP,DC=alamarfoods,DC=local" -AccountPassword(Read-Host -AsSecureString "Aa123456") -Company "Alamar Foods | Egypt" -City "Cairo" -Country ‘EG’ -Manager "mohamed.amer" -Enabled $true

Adding Manager thru CSV command

Create CSV; UserPrincipalName; (see desktop)

Manager

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session

Add Manager

Set-User -Identity mohammed.hemdan@alamarfoods.com -Manager mohammed.roustom@alamarfoods.com

Import-Csv "C:\Users\shrenik.salguna\Desktop\UpdateManager.csv" | foreach {Set-User -Identity $_.UserPrincipalName -Manager $_.Manager}

Get all properties of user

Get-User | gm

Get properties of user and manager

Get-User | select -Property Name,Manager

Export to CSV

Get-User | select -Property Name,Manager | Export-csv "C:\Users\shrenik.salguna\Desktop\Manager.csv"

"C:\Users\shrenik.salguna\Desktop\UpdateManager.csv" | foreach {Set-User -Identity $_.UserPrincipalName -Manager $_.Manager}

AWS Global Infrastructure

Overview

The AWS Global Infrastructure is so exciting of course because for one, it allows you to deploy services right in the area where most of your customers are located.

Crazy Growth

It is amazing to think that just 4 regions existed 5 years after Amazon launched AWS. The first region was N. Virginia in the USA.

After the second 5 years – AWS added 7 more regions. So that is 11 regions in the first 10 years.

What is amazing, is that from 2016 to 2018 – AWS will add another 11 regions! The growth is really exploding of course! AWS expects this to growth rate to continue to increase even faster.

Another exciting fact is that AWS is pushing hard to eventually be powered by 100% renewable energy. One of the reasons for the Sweden launch is their commitment to renewables. 50% of their energy is renewables as country!

Availability Zones

This is a critical part of the Global Infrastructure. A region is made up of multiple AZs. Here are the important aspects to keep in mind:

  • An AZ is a fully isolated infrastructure with one or more data centers – the distance between AZs is as far as possible (miles)
  • There is a meaningful distance of separation for fault tolerance
  • Each has a unique power infrastructure
  • There are many 100Ks of servers at scale
  • Datacenters within an AZ are connected with high speed fiber (with redundant links)
  • Regions have at least two AZs and some have six!
  • AZs are connected to each other with redundant high speed fiber

Region Connectivity

  • Each region has multiple high speed connection options to the rest of the Internet
  • Direct Connect points are expanding – this permits a private connection to the cloud; there are 67 currently
  • There is now inter-region Direct Connect – so the customer can not only connect to their local region privately, they can then do cross region work on their own connections

Edge Locations

  • Over 100 around the world
  • Serve as the basis for CloudFront locations to deliver content to users quickly

Add External Users as ‘Mail Contact’​ to add them to a ‘Distribution List’​ Email Address

This is a guide on how to add External Users to O365 Distribution List Email Address. It is not possible to directly add external users, unless they are created manually as a Mail Contact. This guide allows you to add the users in bulk by importing the contacts in a CSV file.

Firstly, you would need to create a notepad CSV file of the users with Email, DisplayName and then we will import that file in PowerShell by the following cmdlets

PS C:\Users\shrenik.salguna> $users=Import-csv C:\Users\shrenik.salguna\Desktop\CallCenterEmails.txt -Delimiter ","


PS C:\Users\shrenik.salguna> $users

Email            DisplayName

—–            ———–

naser.abdulrahman@email.com Naser Saeed Abdulrahman

Wadha.AlBakmi@email.com   Wadha Hamoud AlBakmi

rehab.alrwished@email.com Rehab Hamad AlRwished

 This cmdlet creates the users as a Mail Contact

PS C:\Users\shrenik.salguna> $users | foreach {New-MailContact -Name $_.DisplayName -ExternalEmailAddress $_.Email}

 Check from the list of users in the .txt file whether the users have been added to the Portal as ‘Mail Contact’

PS C:\Users\shrenik.salguna> Get-Recipient naser.abdulrahman@email.com

 Name          RecipientType

—-          ————-

Naser Saeed Abdulrahman MailContact

 Add the user to the Distribution List in Bulk

PS C:\Users\shrenik.salguna> $users | fore