gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 21:47:38 24 4
gpt4 key购买 nike

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

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

我在搜索过程中发现的所有信息都是使用事件目录 PS 模块的信息。此外,还有其他涉及远程访问的引用资料。 两者都不符合我的需要。

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

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

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

最佳答案

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

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.

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

$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

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

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.

关于用于报告帐户锁定策略设置的 Powershell 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60117943/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com