get-localuser Passwordexpires in seconds (從現在開始)

喇嘛格拉
get-localuser |fl brings back the Date in that format: 

PasswordExpires        : 10/01/2022 15:31:34

我怎樣才能從現在開始以秒為單位計算這個日期?用powershell?有人可以幫我嗎?

AccountExpires         : 
Description            : 
Enabled                : True
FullName               : test-deleteme
PasswordChangeableDate : 29/11/2021 15:31:34
PasswordExpires        : 10/01/2022 15:31:34
UserMayChangePassword  : True
PasswordRequired       : True
PasswordLastSet        : 29/11/2021 15:31:34
LastLogon              : 
Name                   : test-deleteme
PrincipalSource        : Local
ObjectClass            : User
馬蒂亞斯·R·傑森

該值的PasswordExpired值本身沒有特定格式 - 但 PowerShell 會在需要將其輸出到屏幕時根據您的區域設置選擇默認格式。

如果要計算從現在到 中指定日期的持續時間,請計算屬性中PasswordExpiration使用減法運算符 ( -)

Get-LocalUser |Select-Object Name,@{Name='PasswordExpiresInSeconds'; Expression={$_.PasswordExpires - (Get-Date)}}

這將產生一個[timespan]描述持續時間值。要僅獲取秒數,請引用TotalSeconds生成的 timespan 對像上的屬性:

Get-LocalUser |Select-Object Name,@{Name='PasswordExpiresInSeconds'; Expression={$($_.PasswordExpires - (Get-Date)).TotalSeconds -as [int]}}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

找不到Microsoft.Powershell.LocalAccounts模块(或运行Get-LocalUser)

在Powershell上无法识别Rename-LocalUser

New-LocalUser:找不到接受参数“ True”的位置参数

getent passwd -s sss LOCALUSER显示本地用户

這個方法是從哪個版本開始實現的?

如何使頁腳僅從第二頁開始出現

LaTeX - 表格從新行開始

從表開始添加或刪除時,React 備忘錄會重新呈現後續表行

從括號出現開始的單獨字符串(正則表達式)

在不满足密码复杂性时创建了 New-LocalUser

Unity Google Play 服务插件 Social.localUser.Authenticate(...) 应用程序崩溃

New-LocalUser 函數中的屬性 PasswordNeverExpires 和 UserMayNotChangePassword 在 PowerShell 中不起作用

是否有 Unity 2019-Social.localUser.id 获取旧版 gamecenterPlayerId?

AppleScript:複製文件,使用 Seconds from Midnight 重命名,然後打開它

循環遍歷列表並從頭開始

迅速。日曆。veryShortWeekdaySymbols 從星期一開始

從哪裡開始加密用戶密碼?

如何從變量開始插入選擇序列?

SQL 中從 getdate 開始的會計年度

MySQL 自動增量不是從 1 開始

如何添加帶有日期的列(從今天開始)?

如何將信號居中以從零開始

向量迭代器不從索引 0 開始

Javascript 數組 reduce 從索引 1 開始

使用 Angular 從 GET 請求中創建圖表時出現問題

Kestrel 從 VS2019 開始:頁面正常,從可執行文件開始:404

TimeUnit.SECONDS.toMillis

时间戳seconds秒

Python timedelta with seconds