繁体   English   中英

Powershell脚本可停用Windows Server 2003中的Windows用户(从CSV文件)

[英]Powershell script to deactivate the Windows users (from CSV file) in Windows Server 2003

是否有任何Powershell脚本来停用Windows Server 2003中的Windows用户(从CSV文件)? 这些Windows用户是本地用户帐户(不是AD帐户)。 实际上,我发现了很多用于AD的脚本。 非常感谢您的建议。

这应该对您有帮助。 请根据您的要求更改占位符:

$EnableUser = 512 
$DisableUser = 2 
$PasswordNotExpire = 65536 # password never expires
$PasswordCantChange = 64  # passwords cannot be changed
$users = Import-Csv "path\Users_to_disable.csv" # I believe you have only single column else you have to pick the column 
$computer = $env:COMPUTERNAME

Foreach($user in $users){ $user = [ADSI]"WinNT://$computer/$user"
$user.userflags = $DisableUser+$PasswordNotExpire+$PasswordCantChange
#$user.Userflags = $EnableUser+$PasswordNotExpire+$PasswordCantChange
$user.setinfo()
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM