Powershell 脚本报告帐户锁定策略设置?

Ben*_*ing 2 registry powershell policy registrykey content-security-policy

我有几台外网电脑,不允许安装PS AD模块。

我想做的就是使用 Powershell 报告一些帐户锁定设置,特别是锁定阈值、锁定持续时间以及本机是否被锁定。

我在搜索过程中找到的只是使用 Active Directory PS 模块的信息。此外,还有其他涉及远程访问的参考资料。两者都不符合我的需要。

我还查找了与“本地”锁定设置相关的注册表项,但没有找到任何内容(例如,仅引用远程访问 maxDenial;而不是本地设置)。

除了启动gpedit和查看本地策略之外,我希望有一种方法可以使用 Powershell 来简单地报告当前的本地设置。

无论如何,帮助/指示/知识将不胜感激。

Ben*_*ing 5

从“网络帐户”中发现的此信息最终对我有用,我能够编写一个快速显示锁定策略信息的脚本。以下是“净账户”的输出:

PS C:\Users\Siduser> net accounts

Force user logoff how long after time expires?:       0
Minimum password age (days):                          1
Maximum password age (days):                          60
Minimum password length:                              14
Length of password history maintained:                24
Lockout threshold:                                    3
Lockout duration (minutes):                           15
Lockout observation window (minutes):                 15
Computer role:                                        WORKSTATION
The command completed successfully.
Run Code Online (Sandbox Code Playgroud)

创建此代码片段是为了将信息放入变量中:

$lockoutObj = net accounts | Select-string threshold
$lockoutStr = $lockoutObj.ToString()
$lockoutStr -match '\d{1,3}' | out-null
$lockoutStr -match 'Never' | out-null
$LO_threshold = $matches[0]

PS C:\Users\Siduser> echo $LO_threshold
3
Run Code Online (Sandbox Code Playgroud)

如果您需要设置锁定阈值,请使用此命令(需要提升权限):

PS C:\Users\Siduser> net accounts /lockoutthreshold:10
The command completed successfully

PS C:\Users\Siduser> net accounts

Force user logoff how long after time expires?:       0
Minimum password age (days):                          1
Maximum password age (days):                          60
Minimum password length:                              14
Length of password history maintained:                24
Lockout threshold:                                    10
Lockout duration (minutes):                           15
Lockout observation window (minutes):                 15
Computer role:                                        WORKSTATION
The command completed successfully.
Run Code Online (Sandbox Code Playgroud)