博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用PowerShell管理Office 365用户密码策略
阅读量:7120 次
发布时间:2019-06-28

本文共 2399 字,大约阅读时间需要 7 分钟。

   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

转载于:https://blog.51cto.com/itsoul/2056222

你可能感兴趣的文章
(转)Linux传输大文件(分割传输)
查看>>
1003. 我要通过!(20)
查看>>
phpstudy for linux版环境安装
查看>>
MinGW GCC 7.1.0 2017年6月份出炉啦
查看>>
二叉树的实现(Java语言描述)
查看>>
Json Datable Convert
查看>>
微信小程序制作-随笔4
查看>>
adt 22.6出现的问题
查看>>
Struts2(补充)
查看>>
Linux文件系统的目录结构详解
查看>>
MySQL server PID file could not be found!
查看>>
洛谷 P3049园林绿化 题解
查看>>
eclipse New菜单项的显示问题
查看>>
python3常用内置函数总结
查看>>
二分法在生活中的一次应用
查看>>
iOS7新特性的兼容性处理方法 之三
查看>>
转载:Python正则表达式
查看>>
UVA10140 Prime Distance
查看>>
.NET深入 c#数据类型2
查看>>
DIV+CSS颜色边框背景等样式
查看>>