
Se connecter à Office 365 – Exchange Online en powershell avec une commande perso
Voilà une petite astuce pour créer une commande perso, sur powershell, afin de se connecter plus rapidement (en évitant les multiples commandes nécessaires) à Office 365 pour paramétrer Exchange Online.
Premièrement, ouvrez votre fenêtre de commande Powershell avec le module Microsoft Onlines Services chargé.
Ensuite créez un profil vide avec la commande New-item $profile –itemtype file –force.
Editez le module dans notepad avec l’instruction : notepad $profile
Pour finir copiez-collez ce texte, enregistrez et fermez notepad puis redémarrez Powershell :
Function Connect-ExchangeOnline
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $False)]
[System.Management.Automation.PsCredential]$Credential = $Host.UI.PromptForCredential(« Enter MSOL Admin Credential »,
« Enter the username and password of an MSOnline Administrator account. »,
« »,
« userCreds »),
[Parameter(Mandatory = $False)]
[System.Uri]$Uri = « https://ps.outlook.com/powershell/ »
)
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $Uri -Credential $Credential -Authentication « Basic » -AllowRedirection
Import-PSSession $session -AllowClobber
Return $session
}
Voilà maintenant vous pouvez utiliser la commande Connect-ExchangeOnline pour gagner de précieuses secondes !
Aucun commentaire