- PowerShell for Office 365
- Martin Machado Prashant G Bhoyar
- 509字
- 2021-07-02 18:50:42
Creating a new user
Now let's create a new user in Office 365. The PowerShell cmdlet to create the new user is as follows:
New-MsolUser
This cmdlet creates a user in Azure Active Directory. This cmdlet accepts 35 parameters, as shown in the following list. Out of these 35 parameters, only DisplayName and UserPrincipalName are required parameters:
- [-AlternateEmailAddresses <String[]>]: Specifies alternate email addresses for the user.
- [-AlternateMobilePhones <String[]>]: Specifies alternate mobile phone numbers for the user.
- [-BlockCredential <Boolean>]: Specifies whether the user is able to log on using their user ID.
- [-City <String>]: Specifies the city of the user.
- [-Country <String>]: Specifies the country of the user.
- [-Department <String>]: Specifies the department of the user.
- [-DisplayName <String>]: Specifies the display name of the user.
- [-Fax <String>]: Specifies the fax number of the user.
- [-FirstName <String>]: Specifies the first name of the user.
- [-ForceChangePassword <Boolean>]: Indicates that the user is required to change the password during the next sign-in.
- [-ImmutableId <String>]: Specifies the immutable ID of the federated identity of the user. This should be omitted for users with standard identities.
- [-LastName <String>]: Specifies the last name of the user.
- [-LicenseAssignment <String[]>]: Specifies an array of licenses to assign to the user.
- [-LicenseOptions <LicenseOption[]>]: Specifies the options for license assignment. Used to selectively disable individual service plans within an SKU.
- [-MobilePhone <String>]: Specifies the mobile phone number of the user.
- [-Office <String>]: Specifies the office of the user.
- [-Password <String>]: Specifies the new password for the user.
- [-PasswordNeverExpires <Boolean>]: Specifies whether the user password expires periodically.
- [-PhoneNumber <String>]: Specifies the phone number of the user.
- [-PostalCode <String>]: Specifies the postal code of the user.
- [-PreferredDataLocation <String>]: Specifies the preferred data location for the user.
- [-PreferredLanguage <String>]: Specifies the preferred language of the user.
- [-State <String>]: Specifies the state or province where the user is located.
- [-StreetAddress <String>]: Specifies the street address of the user.
- [-StrongPasswordRequired <Boolean>]: Specifies whether you require a strong password for the user.
- [-TenantId <Guid>]: Specifies the unique ID of the tenant on which the operation is to be performed. The default value is the tenant of the current user. This parameter applies only to partner users.
- [-Title <String>]: Specifies the title of the user.
- [-UsageLocation <String>]: Specifies the location of the user where services are consumed. Specifies a two-letter country code.
- [-UserPrincipalName <String>]: Specifies the user ID for this user. This is required.
- [-LastPasswordChangeTimestamp <DateTime>]: Specifies the time when the password was last changed.
- [-SoftDeletionTimestamp <DateTime>]: Specifies a time for soft deletion.
- [-StrongAuthenticationMethods <StrongAuthenticationMethod[]>]: Specifies an array of strong authentication methods.
- [-StrongAuthenticationRequirements <StrongAuthenticationRequirement[]>]: Specifies an array of strong authentication requirements.
- [-StsRefreshTokensValidFrom <DateTime>]: Specifies a StsRefreshTokensValidFrom value.
- [-UserType <UserType>] [<CommonParameters>]: Specifies the user type.
The following cmdlet will create a new user with minimum information:
New-MsolUser -UserPrincipalName "pbhoyar@pgbhoyar.onmicrosoft.com"
-DisplayName "Prashant G Bhoyar"
The following screenshot shows the output for the preceding command:

After the successful creation of the account, the temporary password will get generated/displayed. So far, we have not assigned a license to this user. We will cover this part in detail in the next chapter.
推薦閱讀
- 演進(jìn)式架構(gòu)(原書第2版)
- Cocos2D-X權(quán)威指南(第2版)
- 趣學(xué)Python算法100例
- 名師講壇:Java微服務(wù)架構(gòu)實(shí)戰(zhàn)(SpringBoot+SpringCloud+Docker+RabbitMQ)
- Python之光:Python編程入門與實(shí)戰(zhàn)
- C#實(shí)踐教程(第2版)
- HTML 5與CSS 3權(quán)威指南(第3版·上冊(cè))
- Python全棧數(shù)據(jù)工程師養(yǎng)成攻略(視頻講解版)
- Java Web開發(fā)就該這樣學(xué)
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)教程(Windows 7+Office 2010)
- 工業(yè)機(jī)器人離線編程
- 量子計(jì)算機(jī)編程:從入門到實(shí)踐
- 零基礎(chǔ)學(xué)編程系列(全5冊(cè))
- PHP 7 Programming Blueprints
- R語(yǔ)言數(shù)據(jù)分析從入門到實(shí)戰(zhàn)