上海isp 发表于 2018-9-1 13:23:21

如何使用powershell批量创建office 365账号

  首先,对powershell做一个简单介绍。
  当前powershell有四版本,分别为1.0,2.0,3.0 ,4.0

[*]  如果您的系统是window7或者Windows Server 2008,那么PowerShell 2.0已经内置了,可以升级为3.0,4.0。
[*]  如果您的系统是Windows 8 或者Windows server 2012,那么PowerShell 3.0已经内置了,可以升级为4.0。
[*]  如果您的系统为Windows 8.1,windows 10或者Windows server 2012 R2,那默认已经是4.0了。
  Powershell 1.0 下载地址
  Powershell 2.0 下载地址
  powershell3.0 介绍,下载
  powershell4.0 介绍,下载
  Powershell管理office 365云服务需要安装两个工具
  1.Microsoft Online Services Sign-In Assistant for IT Professionals RTW
  https://www.microsoft.com/en-us/download/details.aspx?id=28177
2.用于 Windows PowerShell 的 Windows Azure Active Directory 模块  https://go.microsoft.com/fwlink/p/?linkid=236297
  步骤一
  以管理员模式打开powershell。输入以下命令,查看上述两个工具是否安装完毕。
  import-module msonline
  get-module

  步骤二
  连接到office 365。在windows powershell中输入如下命令
$UserCredential = Get-Credential  在“Windows PowerShell 凭据请求”对话框中,键入您的 Office 365工作或学校帐户 用户名和密码,然后单击“确定”。
  运行以下命令。
Connect-MsolService -Credential $UserCredential
  编辑csv文件,表头需要自己只做,包含这些列
  DisplayName:显示名称,必填字段
  UserPrincipalName:用户名,需要带后缀,比如user1@abc.com。必填字段。
  City:城市
  Country:国家
  Department:部门
  FirstName:姓
  LastName:名
  MobilePhone:手机号码
  Office:办公室
  Password:密码
  PhoneNumber:办公电话
  PostalCode:邮编
  State:国家
  StreetAddress:街道地址
  Title:岗位
  UsageLocation:国家编码,如CN,或US。必填字段。

  具体参数的含义,可参考https://technet.microsoft.com/zh-cn/library/dn194096
  步骤三
  输入批量导入命令导入账号
  Import-Csv -Path “C:\Users\tommyjex\OneDrive - 中国电信股份有限公司上海分公司\综合\批量创建账号\批量创建-UNICODE.csv” | ForEach-Object{New-MsolUser -DisplayName
$_.DisplayName -UserPrincipalName $_.UserPrincipalName -City $_.City -Country
$_.Country -Department $_.Department -FirstName $_.FirstName -LastName $_.LastName
-MobilePhone $_.MobilePhone -Office $_.Office -Password $_.Password -PhoneNumber $_.PhoneNumber
-PostalCode $_.PostalCode -State $_.State -StreetAddress $_.StreetAddress -Title
$_.Title -UsageLocation $_.UsageLocation -LicenseAssignment ‘teckwah0:ENTERPRISEPACK_NO_RMS‘ -PasswordNeverExpires $true
-ForceChangePassword $False}

  这样即可完成Office 365账号的批量导入


页: [1]
查看完整版本: 如何使用powershell批量创建office 365账号