使用PowerShell管理Office 365用户密码策略

简介:

 Office 365管理起来说简单也简单,说麻烦也麻烦,好多东西图形化界面都不能修改,只能通过PowerShell来进行修改,比如今天小编给大家分享的密码策略。

1.密码永不过期

为单个Office 365用户设置密码永不过期

PowerShell命令:

Set-msoluser –UserPrincipalName <UserPrincipalName> -PasswordNeverExpires $True

PowerShell命令示例:

Set-MsolUser –UserPrincipalName zhangc@itsoul.cn -PasswordNeverExpires $True

为单个Office 365用户禁用“密码永不过期”

PowerShell命令:

Set-MsolUser –UserPrincipalName <UserPrincipalName> -PasswordNeverExpires $False

PowerShell命令示例:

Set-MsolUser -UserPrincipalName zhangc@itsoul.cn -PasswordNeverExpires $False

为所有Office 365用户设置密码永不过期

PowerShell命令:

Get-MsolUser | Set-MsolUser –PasswordNeverExpires $True

为所有Office 365用户禁用密码永不过期

PowerShell命令:

Get-MsolUser | Set-MsolUser –PasswordNeverExpires $False

2.设置密码

为单个Office 365用户设置密码(重置密码)

PowerShell命令:

Set-MsolUserPassword –UserPrincipalName <UserPrincipalName> –NewPassword <New Password> -ForceChangePassword $False

PowerShell命令示例:

Set-MsolUserPassword -UserPrincipalName zhangc@itsoul.cn -NewPassword ww#322x -ForceChangePassword $False

为所有Office 365用户设置预定义密码(重置密码)

PowerShell命令:

Get-MsolUser |%{Set-MsolUserPassword -userPrincipalName $_.UserPrincipalName –NewPassword <password> -ForceChangePassword $False}

PowerShell命令示例:

Get-MsolUser |%{Set-MsolUserPassword -userPrincipalName $_.UserPrincipalName –NewPassword nihao123! -ForceChangePassword $False}

从CSV文件导入的Office 365用户设置预定义密码

步骤1:导出Office 365用户帐户

PowerShell命令:

Get-MsolUser | Select UserPrincipalName| Export-CSV

PowerShell命令示例:

Get-MsolUser | Select UserPrincipalName|Export-CSV C:\Temp\o365users.csv

步骤2:设置一个预定义的密码

PowerShell命令:

Import-CSV |%{Set-MsolUserPassword -userPrincipalName $_.UserPrincipalName –NewPassword <Password> -ForceChangePassword $False}

PowerShell命令示例:

Import-CSV C:\Temp\o365users.csv |%{Set-MsolUserPassword -userPrincipalName $_.UserPrincipalName –NewPassword nihao123! -ForceChangePassword $False}

3. Office 365密码策略

设置Office 365密码策略

PowerShell命令:

Set-MsolPasswordPolicy -DomainName <Domain Name> -NotificationDays <Number Of Days> –ValidityPeriod <Number Of Days>

PowerShell命令示例:

Set-MsolPasswordPolicy -DomainName ITSoul.cn -NotificationDays 15 -ValidityPeriod 180

4.显示密码设置

显示所有Office 365用户的密码设置

PowerShell命令:

Get-MsolUser | Select UserPrincipalName,PasswordNeverExpires

显示有关Office 365密码策略的信息

PowerShell命令:

Get-MsolPasswordPolicy –DomainName <Domain Name>

PowerShell命令示例:


Get-MsolPasswordPolicy –DomainName ITSoul.cn


本文转自  zyliday   51CTO博客,原文链接:

http://blog.51cto.com/itsoul/2056222
相关文章
|
3天前
|
数据库 Windows
【解决方案汇总】学校正版软件管理与服务平台office更新失败错误码0x80080005 + 错误码0XC004F074、0XC004F035、0XC004C003、0XC004F017+反复提示激活
【解决方案汇总】学校正版软件管理与服务平台office更新失败错误码0x80080005 + 错误码0XC004F074、0XC004F035、0XC004C003、0XC004F017+反复提示激活
240 0
|
数据安全/隐私保护
|
3天前
|
存储 Ubuntu Linux
windows可以安装Ubuntu,ubuntu上也可以安装Powershell
powerhsell除了可以在windows上使用外,还可以在Ubuntu上部署开发环境。下面介绍Ubuntu上安装powershell的方法。
61 0
|
6月前
|
Shell Linux 开发工具
windows中cmd和PowerShell批处理命令
之前在 Git 批量删除本地分支,有用到 Linux 或 MacOS 下的批处理命令,这个命令中的 grep、xargs 本身是 Shell script,在 windows 中的 cmd 和 PowerShell 中是不能用的
55 0
|
9月前
|
JavaScript Windows
[Vue]解决 Windows PowerShell 不识别 vue 命令的问题
[Vue]解决 Windows PowerShell 不识别 vue 命令的问题
|
9月前
|
Windows
使用PowerShell获取Windows当前锁屏壁纸
使用PowerShell获取Windows当前锁屏壁纸 如果原始图片丢了,用这段代码就可以提取当前锁屏壁纸了!
107 0
|
应用服务中间件 nginx Windows
Windows PowerShell 中启动 Nginx 报错解决方案
Windows PowerShell 中启动 Nginx 报错解决方案
Windows PowerShell 中启动 Nginx 报错解决方案