当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] Set-MsolUser - 修改 Office 365 中的用户对象

作者:精品下载站 日期:2024-12-14 06:25:15 浏览:13 分类:玩电脑

Set-MsolUser - 修改 Office 365 中的用户对象


PowerShell 中的 Set-MsolUser cmdlet 用于修改 Microsoft Office 365 中的用户对象。

Set-MsolUser 命令用于更新 Azure Active Directory 中用户对象的基本属性。

在本文中,我们将讨论如何使用 PowerShell 中的 Set-MsolUser cmdlet 修改 Office 365 中用户的基本属性。

Set-MsolUser 语法

Set-MsolUser
   [-ImmutableId <String>]
   [-ObjectId <Guid>]
   [-UserPrincipalName <String>]
   [-BlockCredential <Boolean>]
   [-City <String>]
   [-Country <String>]
   [-Department <String>]
   [-DisplayName <String>]
   [-Fax <String>]
   [-FirstName <String>]
   [-LastName <String>]
   [-LastPasswordChangeTimestamp <DateTime>]
   [-MobilePhone <String>]
   [-Office <String>]
   [-PasswordNeverExpires <Boolean>]
   [-PhoneNumber <String>]
   [-PostalCode <String>]
   [-PreferredDataLocation <String>]
   [-PreferredLanguage <String>]
   [-SoftDeletionTimestamp <DateTime>]
   [-State <String>]
   [-StreetAddress <String>]
   [-StrongPasswordRequired <Boolean>]
   [-Title <String>]
   [-UsageLocation <String>]
   [-AlternateEmailAddresses <String[]>]
   [-StrongAuthenticationMethods <StrongAuthenticationMethod[]>]
   [-AlternateMobilePhones <String[]>]
   [-StrongAuthenticationRequirements <StrongAuthenticationRequirement[]>]
   [-StsRefreshTokensValidFrom <DateTime>]
   [-UserType <UserType>]
   [-TenantId <Guid>]
   [<CommonParameters>]

如何更新 Office 365 中用户的显示名称

要更新 Office 365 中用户的显示名称,请使用带有 DisplayName 属性的 Set-MsolUser cmdlet。

 Set-MsolUser -UserPrincipalName "[email " -DisplayName " Samer Amberson"

在上面的 PowerShell 脚本中,Set-MsolUser 命令使用 UserPrincipalName 指定用户对象的 ID,并使用 DisplayName 属性来更新指定用户的显示名称。

DisplayName 参数指定用户的显示名称,UserPrincipalName 参数指定用户的用户 ID。

下面给出了上述修改用户显示名称的 PowerShell 脚本的输出。

[玩转系统] Set-MsolUser - 修改 Office 365 中的用户对象

酷提示:如何在 PowerShell 中使用 Get-MsolUser cmdlet!

如何在 Office 365 中更新用户的位置

要更新 Office 365 中用户的位置,请使用带有 UsageLocation 参数的 Set-MsolUser cmdlet。 UsageLocation 参数用于设置用户的位置国家或地区。国家或地区必须是两个字母的 ISO 代码。

Set-MsolUser -UserPrincipalName "[email " -UsageLocation "AU"

在上述 PowerShell 脚本中,Set-MsolUser cmdlet 使用 UserPrincipalName 参数指定用户 ID,在本例中为“[email ” ”并将位置更新为AU

如何在 Office 365 中设置用户的首选数据位置

要在 Office 365 中设置用户的首选数据位置,请使用带有 PreferredDataLocation 参数的 Set-MsolUser cmdlet。 PreferredDataLocation 属性指定用户的首选数据位置。

Set-MsolUser -UserPrincipalName "[email " -PreferredDataLocation "EUR"

此命令将用户主体名称为“[email ”的用户的首选数据位置属性设置为EUR

酷提示:如何在 PowerShell 中使用 Get-MsolCompanyAllowedDataLocation!

如何在 Office 365 中阻止用户的凭据

要修改 Office 365 中用户的阻止凭据,请使用带有 BlockCredential 参数的 Set-MsolUser cmdlet。 BlockCredential 参数指定用户是否无法使用其用户 ID 登录。

Set-MsolUser -UserPrincipalName "[email " -BlockCredential $True

对于用户主体名称为“[email ”的用户,此命令将阻止凭据设置为 $True,从而阻止他们登录。

如何在 Office 365 中为用户设置密码永不过期

要在 Office 365 中为用户设置永不过期的密码,请使用带有 PasswordNeverExpires 参数的 Set-MsolUser cmdlet。 PasswordNeverExpires 指定用户密码是否定期过期。

Set-MsolUser -UserPrincipalName "[email " -PasswordNeverExpires $True

对于用户主体名称为“[email ”的用户,此命令将用户密码永不过期设置为 $True

如何在 Office 365 中更新用户的办公室位置

要更新 Office 365 中用户的办公位置,请使用带有 Office 参数的 Set-MsolUser cmdlet。 Office 参数指定用户办公室的位置。

Set-MsolUser -UserPrincipalName "[email " -Office "Austin"   

此命令将用户主体名称为“[email ”的用户的办公位置设置为Austin

结论

希望上述有关如何在 PowerShell 中使用 Set-MsolUser cmdlet 更新 Office 365 中用户的基本属性的文章对您有所帮助。

您可以在 ShellGeek 主页上找到有关 PowerShell Active Directory 命令和 PowerShell 基础知识的更多主题。

相关链接

获取 MsolUser

新MsolUser

删除-MsolUser

恢复-MsolUser

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯