{"id":341,"date":"2015-04-27T20:22:24","date_gmt":"2015-04-28T00:22:24","guid":{"rendered":"http:\/\/www.hoplawego.com\/blog\/?p=341"},"modified":"2015-04-27T20:22:46","modified_gmt":"2015-04-28T00:22:46","slug":"utiliser-powershell-pour-administrer-office-365","status":"publish","type":"post","link":"https:\/\/www.hoplawego.com\/blog\/utiliser-powershell-pour-administrer-office-365\/","title":{"rendered":"Utiliser Powershell pour administrer Office 365"},"content":{"rendered":"<p>Pour utiliser powershell dans l&rsquo;environnement Office 365, il faut premi\u00e8rement utiliser le plugin suivant:<\/p>\n<p><a href=\"https:\/\/technet.microsoft.com\/en-ca\/library\/jj151815.aspx\">https:\/\/technet.microsoft.com\/en-ca\/library\/jj151815.aspx<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.microsoft.com\/en-us\/download\/confirmation.aspx?id=39267\">http:\/\/www.microsoft.com\/en-us\/download\/confirmation.aspx?id=39267<\/a><\/p>\n<p>Ensuite faire les commandes suivantes:<\/p>\n<p>Ouvrir powershell (start, run, powershell) en mode administrateur<\/p>\n<p>Cr\u00e9er la variable Cred avec les bonnes infos (pop de connexion)<\/p>\n<blockquote><p>$Cred = Get-Credential<\/p><\/blockquote>\n<p>Cr\u00e9er la variable Session.<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p>$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri <a href=\"https:\/\/ps.outlook.com\/powershell\/\">https:\/\/ps.outlook.com\/powershell\/<\/a> -Credential $Cred -Authentication Basic -AllowRedirection<\/p><\/blockquote>\n<p>Permettre les scripts de rouler.<\/p>\n<blockquote><p>Set-ExecutionPolicy Unrestricted<\/p><\/blockquote>\n<p>Se connecter.<\/p>\n<blockquote><p>Import-PSSession $Session<\/p>\n<p>Connect-Mso -Credential $Cred<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>Ensuite, ne reste plus qu&rsquo;a utiliser les scripts habituels de Exchange et AD.<\/p>\n<p>&nbsp;<\/p>\n<p>Par exemple:<\/p>\n<p>&nbsp;<\/p>\n<p>Changer les mots de passe pour plusieurs utilisateurs.<\/p>\n<p>Sortir la liste des comptes en format CSV.<\/p>\n<blockquote><p>Get-MsolUser | Select UserPrincipalName| Export-CSV -Path users.csv<\/p><\/blockquote>\n<p>Ensuite, relancer pour les utilisateurs s\u00e9lectionn\u00e9s.<\/p>\n<blockquote><p>Import-CSV\u00a0 users.csv |%{Set-MsolUserPassword -userPrincipalName $_.UserPrincipalName \u2013NewPassword \u00ab\u00a0NOUVEAUPASSWORD\u00a0\u00bb -ForceChangePassword $False}<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Pour utiliser powershell dans l&rsquo;environnement Office 365, il faut premi\u00e8rement utiliser le plugin suivant: https:\/\/technet.microsoft.com\/en-ca\/library\/jj151815.aspx &nbsp; http:\/\/www.microsoft.com\/en-us\/download\/confirmation.aspx?id=39267 Ensuite faire les commandes suivantes: Ouvrir powershell (start, run, powershell) en mode administrateur Cr\u00e9er la variable Cred avec les bonnes infos (pop de connexion) $Cred = Get-Credential Cr\u00e9er la variable Session. &nbsp; $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri &hellip; <\/p>\n","protected":false},"author":1,"featured_media":314,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,2],"tags":[],"class_list":["post-341","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft","category-t-i","grid-sizer"],"_links":{"self":[{"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/posts\/341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/comments?post=341"}],"version-history":[{"count":2,"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/posts\/341\/revisions"}],"predecessor-version":[{"id":343,"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/posts\/341\/revisions\/343"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/media\/314"}],"wp:attachment":[{"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/media?parent=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/categories?post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hoplawego.com\/blog\/wp-json\/wp\/v2\/tags?post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}