{"id":22608,"date":"2020-02-07T17:46:34","date_gmt":"2020-02-07T09:46:34","guid":{"rendered":"http:\/\/4563.org\/?p=22608"},"modified":"2020-02-07T17:46:34","modified_gmt":"2020-02-07T09:46:34","slug":"a1%e5%85%a8%e5%b1%80%e7%ae%a1%e7%90%86%e6%89%b9%e9%87%8f%e6%92%b8%e8%b5%84%e8%b4%a6%e6%88%b7%e8%84%9a%e6%9c%acoffice-365-powershell","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=22608","title":{"rendered":"A1\u5168\u5c40\u7ba1\u7406\u6279\u91cf\u64b8\u8d44\u8d26\u6237\u811a\u672cOffice 365 PowerShell"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>\u53e3\u5410\u82ac\u82b3<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3>A1\u5168\u5c40\u7ba1\u7406\u6279\u91cf\u64b8\u8d44\u8d26\u6237\u811a\u672cOffice 365 PowerShell<\/h3>\n<p>  \t\t\u8fde\u63a5\u5230 Office 365 PowerShell<br \/>  \u6b65\u9aa4 1\uff1a\u5b89\u88c5\u6240\u9700\u8f6f\u4ef6<br \/>  \u8fd9\u4e9b\u6b65\u9aa4\u53ea\u9700\u5728\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u6267\u884c\u4e00\u6b21\u5373\u53ef\uff0c\u800c\u4e0d\u662f\u5728\u6bcf\u6b21\u8fde\u63a5\u65f6\u90fd\u8981\u6c42\u6267\u884c\u3002\u4f46\u662f\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5b9a\u671f\u5b89\u88c5\u8f83\u65b0\u7248\u672c\u7684\u8f6f\u4ef6\u3002<br \/>  \u5b89\u88c5 64 \u4f4d\u7248 Microsoft Online Services \u767b\u5f55\u52a9\u624b\uff1a\u9002\u7528\u4e8e IT \u4e13\u4e1a\u4eba\u5458 RTW \u7684 Microsoft Online Services \u767b\u5f55\u52a9\u624b\u3002<br \/>  \u5b89\u88c5\u7528\u4e8e Windows PowerShell \u7684 Microsoft Azure Active Directory \u6a21\u5757\uff0c\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<br \/>  \u6253\u5f00\u63d0\u5347\u7684 Windows PowerShell \u547d\u4ee4\u63d0\u793a\u7b26\uff08\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c Windows PowerShell\uff09\u3002<br \/>  \u8fd0\u884c Install-Module MSOnline \u547d\u4ee4\u3002<br \/>  \u5982\u679c\u7cfb\u7edf\u63d0\u793a\u5b89\u88c5 NuGet \u63d0\u4f9b\u7a0b\u5e8f\uff0c\u8bf7\u952e\u5165 Y\uff0c\u7136\u540e\u6309 Enter \u952e\u3002<br \/>  \u5982\u679c\u7cfb\u7edf\u63d0\u793a\u4ece PSGallery \u5b89\u88c5\u6a21\u5757\uff0c\u8bf7\u952e\u5165 Y\uff0c\u7136\u540e\u6309 Enter \u952e\u3002<\/p>\n<p>  \u6b65\u9aa4 2\uff1a \u8fde\u63a5\u5230 Office 365 \u8ba2\u9605 Azure AD<br \/>  \u8bf7\u4ece Windows PowerShell \u547d\u4ee4\u63d0\u793a\u7b26 \uff08\u5b83\u6ca1\u6709\u8981\u63d0\u5347\u7684\u6743\u9650\uff09 \u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>  Connect-MsolService<\/p>\n<p>  \u767b\u5f55\u5230\u60a8\u7684\u5e10\u6237\u5bf9\u8bdd\u6846\u4e2d\uff0c\u952e\u5165\u60a8\u7684 Office 365 \u5de5\u4f5c\u6216\u5b66\u6821\u5e10\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\uff0c\u7136\u540e\u5355\u51fb\u786e\u5b9a\u3002<\/p>\n<p>  \u67e5\u770b\u8ba2\u9605SKU<br \/>  \u8fd0\u884c\u547d\u4ee4\uff1a<br \/>  Get-MsolAccountSku<\/p>\n<p>  \u51c6\u5907\u8d26\u53f7\u6587\u672c<br \/>  \u672c\u793a\u4f8b\u4ece\u540d\u4e3a C:My DocumentsNewAccounts.csv \u7684\u6587\u4ef6\u521b\u5efa\u7528\u6237\u5e10\u6237\uff0c\u5e76\u5c06\u7ed3\u679c\u8bb0\u5f55\u5728\u540d\u4e3a C:My DocumentsNewAccountResults.csv \u7684\u6587\u4ef6\u4e2d<\/p>\n<p>  UserPrincipalName&nbsp; &nbsp; &nbsp; &nbsp; FirstName&nbsp; &nbsp; &nbsp; &nbsp; LastName&nbsp; &nbsp; &nbsp; &nbsp; DisplayName&nbsp; &nbsp; &nbsp; &nbsp; UsageLocation&nbsp; &nbsp; &nbsp; &nbsp; AccountSkuId<br \/>  ClaudeL@contoso.onmicrosoft.com&nbsp; &nbsp; &nbsp; &nbsp; Claude&nbsp; &nbsp; &nbsp; &nbsp; Loiselle&nbsp; &nbsp; &nbsp; &nbsp; Claude Loiselle&nbsp; &nbsp; &nbsp; &nbsp; US&nbsp; &nbsp; &nbsp; &nbsp; contoso:ENTERPRISEPACK<br \/>  LynneB@contoso.onmicrosoft.com&nbsp; &nbsp; &nbsp; &nbsp; Lynne&nbsp; &nbsp; &nbsp; &nbsp; Baxter&nbsp; &nbsp; &nbsp; &nbsp; Lynne Baxter&nbsp; &nbsp; &nbsp; &nbsp; US&nbsp; &nbsp; &nbsp; &nbsp; contoso:ENTERPRISEPACK<br \/>  ShawnM@contoso.onmicrosoft.com&nbsp; &nbsp; &nbsp; &nbsp; Shawn&nbsp; &nbsp; &nbsp; &nbsp; Melendez&nbsp; &nbsp; &nbsp; &nbsp; Shawn Melendez&nbsp; &nbsp; &nbsp; &nbsp; US&nbsp; &nbsp; &nbsp; &nbsp; contoso:ENTERPRISEPACK<br \/>  \u521b\u5efaNewAccounts.csv<br \/>  \u91cc\u9762\u5305\u542b<\/p>\n<p>  \u4f7f\u7528 Office 365 PowerShell \u521b\u5efa\u591a\u4e2a\u7528\u6237\u5e10\u6237<br \/>  \u8f93\u5165\u547d\u4ee4<\/p>\n<p>  Import-Csv -Path &quot;C:NewAccounts.csv&quot; | foreach {New-MsolUser -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -UserPrincipalName $_.UserPrincipalName -UsageLocation $_.UsageLocation -LicenseAssignment $_.AccountSkuId} | Export-Csv -Path &quot;C: NewAccountResults.csv&quot;<br \/>  \u8d26\u53f7\u5199\u5165\uff1a<br \/>  Import-Csv -Path &quot;C:NewAccounts.csv&quot; | foreach {New-MsolUser -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -UserPrincipalName $_.UserPrincipalName -UsageLocation $_.UsageLocation -LicenseAssignment $_.AccountSkuId} | Export-Csv -Path &quot;C:NewAccountResults.csv&quot;<\/p>\n<p>  \u5220\u9664\u6240\u6709\u8d26\u53f7\u811a\u672c\uff08\u8c28\u614e\u64cd\u4f5c\uff09\uff1a<\/p>\n<p>  $users = Get-MsolUser -All<br \/>  $users | Remove-MsolUser \u2013Force\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>bhgchinaboy<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u8c22\u8c22\u5927\u4f6c<\/p>\n<p>  \u4f46\u662f\u6211\u4ee5\u4e3a\u662f\u64b8\u5168\u5c40\u7684\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>tssz<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u4e4b\u524d\u8bba\u575b\u6709\u4eba\u5f00\u8f66\uff0c\u7ed3\u679c\u6211\u73b0\u5728\u5fd8\u8bb0\u5bc6\u7801\u4e86\u3002\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53e3\u5410\u82ac\u82b3 \u5927\u4f6c\u6709\u8bdd\u8bf4 : A1\u5168\u5c40&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/22608"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22608"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/22608\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22608"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}