Que vous souhaitiez configurer Exchange Online, SharePoint Online ou encore Skype Online, découvrez comment vous connecter en PowerShell à vos tenants Office 365.

Retrouvez le script PowerShell sous la vidéo…

# Installer les composants:
# WindowsAzurePowerShell
# (En option) sharepointclientcomponents
# sharepointonlinemanagementshell
|# Module Skype Entreprise Online Connector
# (En option) AzureADConnect
#

$AdminO365Login = « UserName@abonnement.onmicrosoft.com »

$SpPowerShellOnline = « https://abonnement-admin.sharepoint.com »
$SpSiteCollection = « https://abonnement.sharepoint.com »
$mySiteUri = « https://abonnement-my.sharepoint.com »

# TEST LA PRESENCE DES MODULES POWERSHELL ET IMPORTE LES MODULES DANS LA SESSION POWERSHELL #
Write-host « Test et importation du module SharePoint Online PowerShell … » -ForegroundColor Cyan
if (Get-Module -ListAvailable -Name Microsoft.Online.SharePoint.PowerShell)
{ Write-Host « Le Module existe. Importation du module. » Import-Module Microsoft.Online.SharePoint.PowerShell |Out-Null
}
else
{ Write-Host « Le Module Microsoft.Online.SharePoint.PowerShell n’existe pas. Veuillez installer le composant associé. » -ForegroundColor Yellow pause exit
}

Write-host « Test et importation du module MsOnline PowerShell » -ForegroundColor Cyan
if (Get-Module -ListAvailable -Name MsOnline)
{ Write-Host « Le Module existe. Importation du module. » Import-Module MsOnline |Out-Null
}
else
{ Write-Host « Le Module MsOnline n’existe pas. Veuillez installer le composant associé. » -ForegroundColor Yellow pause exit
}
# FIN DU CHARGEMENT DES MODULES POUR OFFICE 365 #

Write-host « Entrez vos informations d’identification Administrateur Office 365 » -ForegroundColor Yellow
$cred = Get-Credential $AdminO365Login

# Connection vers Office 365 #
Write-host « Connexion à votre tenant Office 365. » -ForegroundColor Yellow
Connect-MsolService -Credential $cred
# Fin de connexion vers Office 365 #

# Connexion à SharePoint Online #
Write-Host « Connexion vers SharePoint Online (O365)  » -ForegroundColor Yellow
Connect-SPOService -Url $SpPowerShellOnline -credential $cred
# Fin de connexion à SharePoint Online #

# Connexion à Exchange Online #
write-host « Connexion à Exchange Online » -ForegroundColor Yellow
$ExchangeOnline = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Cred -Authentication basic -AllowRedirection
write-host « Importation de la session PowerShell pour Exchange Online » -ForegroundColor Yellow
Import-PSSession $ExchangeOnline -AllowClobber -ErrorAction SilentlyContinue
# Fin de connexion à Exchange Online #

# Connexion à Lync Online #
write-host « Connexion à Lync Online » -ForegroundColor Yellow
$lyncSession = New-CsOnlineSession -Credential $cred -WarningAction SilentlyContinue
Import-PSSession $lyncSession -AllowClobber -ErrorAction SilentlyContinue
# Fin de connexion à Lync Online #