[玩转系统] Office 365:使用 PowerShell 获取上次密码更改日期
作者:精品下载站 日期:2024-12-15 00:27:37 浏览:13 分类:玩电脑
Office 365:使用 PowerShell 获取上次密码更改日期
要求:检查 Office 365 中上次密码更改日期。
如何查看Office 365的最后一次密码更改?
安全的关键组成部分之一是管理密码。密码管理是维护数字领域安全的一个关键方面。对于 Microsoft 365 用户,了解密码何时过期对于避免帐户被锁定至关重要。在本综合指南中,我们将讨论检查 Office 365 中上次密码更改日期以及检查用户密码何时过期的各种方法。通过遵循我们的分步说明,您将能够监控您的密码到期日期并保持对您帐户的无缝访问。
为什么检查 Office 365 中的上次密码更改日期很重要
密码是防止未经授权访问您的 Office 365 帐户的第一道防线。如果您的密码落入坏人之手,您的数据就会面临风险。定期更改密码非常重要,并确保您的员工也这样做。检查 Office 365 中的上次密码更改日期可以帮助您识别潜在的安全风险,例如长时间未更改密码的员工。
此外,了解上次更改密码的时间可以帮助您解决帐户问题。例如,如果您在登录时遇到问题,了解上次更改密码的时间可以帮助您确定问题是否与您的密码有关。
在 Office 365 中检查上次密码更改日期的方法
在 Office 365 中检查上次密码更改日期有两种主要方法:Microsoft Graph PowerShell 和 Microsoft Online Services PowerShell 模块(Azure AD PowerShell 模块 V1)。这两种方法都相对易于使用,并且可以提供有关您帐户安全的有价值的信息。
要获取特定用户的上次密码更改日期,请使用以下 Microsoft Graph PowerShell 脚本:
#Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All"
#Get the User
$User = Get-MgUser -UserId "[email protected]" -Property UserPrincipalName, PasswordPolicies, lastPasswordChangeDateTime
#Get the user's last password change date and time
$User | Select UserPrincipalName, PasswordPolicies, lastPasswordChangeDateTime
同样,要获取所有用户的上次密码更改日期时间戳,请使用以下 PowerShell 脚本:
#Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All"
#Retrieve the password change date timestamp of all users
Get-MgUser -All -Property UserPrincipalName, PasswordPolicies, lastPasswordChangeDateTime `
| Select -Property UserPrincipalName, PasswordPolicies, lastPasswordChangeDateTime
此信息对于需要监控用户帐户并确保其密码安全的管理员非常有帮助。要将所有用户的上次密码更改日期导出到 CSV 文件,请使用以下 PowerShell 脚本:
#Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All"
#Set the properties to retrieve
$Properties = @(
"id",
"DisplayName",
"userprincipalname",
"PasswordPolicies",
"lastPasswordChangeDateTime",
"mail",
"jobtitle",
"department"
)
#Retrieve the password change date timestamp of all users
$AllUsers = Get-MgUser -All -Property $Properties | Select -Property $Properties
#Export to CSV
$AllUsers | Export-Csv -Path "C:\Temp\PasswordChangeTimeStamp.csv" -NoTypeInformation
Azure AD PowerShell 模块 (AzureAD) 不提供检索“上次更改密码”属性的功能。使用 MSOL PowerShell 模块获取 Office 365 中的上次密码更改日期
PowerShell 是一个功能强大的命令行工具,可用于管理 Office 365 的几乎所有方面。若要使用 PowerShell 获取 Office 365 中的上次密码更改日期,必须安装适用于 Windows PowerShell 的 Microsoft 在线服务 (MSOL) 模块。
使用 PowerShell 获取 Office 365 中上次密码更改日期的分步指南
- 安装适用于 Windows PowerShell 的 Microsoft Online Services PowerShell 模块:
Install-Module MSOnline
- 打开 PowerShell 并通过运行以下命令连接到您的 Office 365 帐户:
Connect-MsolService
- 出现提示时输入您的 Office 365 凭据。
- 使用以下命令获取特定用户的上次密码更改日期:
(Get-MsolUser -UserPrincipalName [email protected]).LastPasswordChangeTimestamp
。将“[email protected]”替换为您要检查的用户的电子邮件地址。 - 最后一次密码更改日期将以 UTC 格式返回。
#Connect to Microsoft Online Service
Connect-MsolService
#Get the User
$user=Get-MsolUser -UserPrincipalName "[email protected]"
#Get the last password change date
$user.LastPasswordChangeTimestamp
如何查看Office 365密码何时过期?
监控密码过期日期使您能够避免帐户锁定等中断,并保持对 Microsoft 365 应用程序的一致访问!以下是用于计算用户帐户的密码到期日期的 PowerShell 脚本:
#Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All"
#Get the User
$User = Get-MgUser -UserId "[email protected]" -Property UserPrincipalName, lastPasswordChangeDateTime
#Get the user's password expiring date
$User.lastPasswordChangeDateTime.AddDays(90)
同样,使用 MSOL 模块,您可以获得密码到期日期,如下所示:
#Connect to Microsoft Online Service
Connect-MsolService
#Get the User
$user = Get-MsolUser -UserPrincipalName "[email protected]"
#Get the password Expiring date
$user.LastPasswordChangeTimestamp.AddDays(90)
该脚本根据用户上次更改密码和默认的 90 天密码过期策略来计算密码过期日期。如何查找 Office 365 租户中所有用户的密码到期日期?
#Connect to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All"
#Set the properties to retrieve
$Properties = @(
"id",
"DisplayName",
"userprincipalname",
"PasswordPolicies",
"lastPasswordChangeDateTime",
"AccountEnabled",
"userType"
)
#Retrieve All users from Microsoft 365 and Filter
$AllUsers = Get-MgUser -All -Property $Properties | Select -Property $Properties | `
Where {$_.AccountEnabled -eq $true -and $_.PasswordPolicies -notcontains "DisablePasswordExpiration" -and $_.userType -ne "Guest"}
#Filter and Export data to CSV
$FilteredUsers = $AllUsers | Select Id, DisplayName, UserPrincipalName, @{Name="ExpiryDate";Expression={$_.lastPasswordChangeDateTime.AddDays(90)}}
$FilteredUsers
$FilteredUsers | Export-Csv -Path "C:\Temp\PasswordExpiryDate.csv" -NoTypeInformation
Write-host "Password Expiry Date for all users is exported!" -f Green
如何检查Office 365密码何时过期?
要获取特定用户帐户的密码到期日期,请使用以下 PowerShell 脚本:
#Parameter
$UserAccount = "[email protected]"
#Connect to Office 365 from PowerShell
Connect-MsolService
#Get the Default Domain
$Domain = Get-MsolDomain | where {$_.IsDefault -eq $true}
#Get the Password Policy
$PasswordPolicy = Get-MsolPasswordPolicy -DomainName $Domain.Name
#Get the User account
$UserAccount = Get-MsolUser -UserPrincipalName $UserAccount
#Get Password Expiry date
$PasswordExpirationDate = $UserAccount.LastPasswordChangeTimestamp.AddDays($PasswordPolicy.ValidityPeriod)
$PasswordExpirationDate
#Get the Password Expiring date
$UserAccount | Select LastPasswordChangeTimestamp, @{Name="Password Age";Expression={((Get-Date).ToUniversalTime())-$_.LastPasswordChangeTimeStamp}}
要获取使用 MSOL 模块的所有用户的密码到期日期,请使用以下脚本:
#Connect to Microsoft Online Service
Connect-MsolService
#Get all Users
$AllUsers = Get-MsolUser -All | Select ObjectId, DisplayName,UserPrincipalName, BlockCredential, UserType, @{Name="ExpiryDate";Expression={$_.LastPasswordChangeTimeStamp.AddDays(90)}}
#Filter users
$FilteredUsers = $AllUsers | Where {$_.PasswordNeverExpires -ne $true -and $_.UserType -ne "Guest" -and $_.BlockCredential -ne $true } | Select DisplayName,UserPrincipalName, ExpiryDate
$FilteredUsers
#Get the password Expiring date
$FilteredUsers | Export-Csv -Path "C:\Temp\PasswordExpiryDates.csv" -NoTypeInformation
结论和要点
总之,检查密码过期日期是一个简单的过程,可以为您节省时间并减少将来的麻烦。通过本文概述的方法,您可以轻松检查用户的上次密码更改日期,并采取措施提高密码安全性。请记住要求使用强密码、强制密码过期并教育您的员工密码安全的重要性。通过执行上述步骤,您可以轻松检查密码的到期日期并确保用户帐户的安全。
猜你还喜欢
- 03-30 [玩转系统] 如何用批处理实现关机,注销,重启和锁定计算机
- 02-14 [系统故障] Win10下报错:该文件没有与之关联的应用来执行该操作
- 01-07 [系统问题] Win10--解决锁屏后会断网的问题
- 01-02 [系统技巧] Windows系统如何关闭防火墙保姆式教程,超详细
- 12-15 [玩转系统] 如何在 Windows 10 和 11 上允许多个 RDP 会话
- 12-15 [玩转系统] 查找 Exchange/Microsoft 365 中不活动(未使用)的通讯组列表
- 12-15 [玩转系统] 如何在 Windows 上安装远程服务器管理工具 (RSAT)
- 12-15 [玩转系统] 如何在 Windows 上重置组策略设置
- 12-15 [玩转系统] 如何获取计算机上的本地管理员列表?
- 12-15 [玩转系统] 在 Visual Studio Code 中连接到 MS SQL Server 数据库
- 12-15 [玩转系统] 如何降级 Windows Server 版本或许可证
- 12-15 [玩转系统] 如何允许非管理员用户在 Windows 中启动/停止服务
取消回复欢迎 你 发表评论:
- 精品推荐!
-
- 最新文章
- 热门文章
- 热评文章
[电影] 黄沙漫天(2025) 4K.EDRMAX.杜比全景声 / 4K杜比视界/杜比全景声
[风口福利] 短视频红利新风口!炬焰创作者平台重磅激励来袭
[韩剧] 宝物岛/宝藏岛/金银岛(2025)【全16集】【朴炯植/悬疑】
[电影] 愤怒的牦牛 (2025) 国语中字 4k
[短剧合集] 2025年05月30日 精选+付费短剧推荐56部
[软件合集] 25年5月30日 精选软件26个
[软件合集] 25年5月29日 精选软件18个
[短剧合集] 2025年05月28日 精选+付费短剧推荐38部
[软件合集] 25年5月28日 精选软件37个
[软件合集] 25年5月27日 精选软件26个
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电视剧] 欢乐颂.5部全 (2016-2024)
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[影视] 【稀有资源】香港老片 艺坛照妖镜之96应召名册 (1996)
[剧集] 神经风云(2023)(完结).4K
[剧集] [BT] [TVB] [黑夜彩虹(2003)] [全21集] [粤语中字] [TV-RMVB]
[办公模版] office模板合集:包含word、Excel、PowerPoint、Access四类共计2000多个模板
[资源] B站充电视频合集,包含多位重量级up主,全是大佬真金白银买来的~【99GB】
[音乐] 华语流行伤感情经典歌无损音乐合集(700多首)
[影视] 内地绝版高清录像带 [mpg]
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电影] 美国队长4 4K原盘REMUX 杜比视界 内封简繁英双语字幕 49G
[电影] 死神来了(1-6)大合集!
[软件合集] 25年05月13日 精选软件16个
[精品软件] 25年05月15日 精选软件18个
[绝版资源] 南与北 第1-2季 合集 North and South (1985) /美国/豆瓣: 8.8[1080P][中文字幕]
[软件] 25年05月14日 精选软件57个
[短剧] 2025年05月14日 精选+付费短剧推荐39部
[短剧] 2025年05月15日 精选+付费短剧推荐36部
- 最新评论
-
- 热门tag