列表中每个用户的PowerShell Set-AdaccountPassword
我有一个生成随机密码的函数。我最终希望导入用户名列表,然后在设置密码时为每个名称运行该功能。
Function New-Password {
$Password = $null
Get-RandomCharacters
Scramble-String
Write-Host "$Password"
}
New-Password
$Password
我如何将$密码合并
Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "$Password" -Force)
I have a function that generates a randomized password. I would ultimately like to import a list of usernames and then have that function run for each name while setting the password.
Function New-Password {
$Password = $null
Get-RandomCharacters
Scramble-String
Write-Host "$Password"
}
New-Password
$Password
How can I merge the $Password with
Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "$Password" -Force)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将开关添加到您的功能,以便在必要时转换。您的完整功能将包括以下内容,并引用您的其他自定义功能:
其中
new -password -converttoss
应返回system.security.securestring
。但是我认为有一种更简单的方法可以使用
system.web
组装来完成此操作。使用此测试数据:
您可以使用类似于下面的脚本。注意 - 请确保在生产中使用它之前对其进行测试。
You could add a switch to your function to convert it if necessary. Your full function would include something below with a reference to your other custom functions:
Where
New-Password -converttoSS
should returnSystem.Security.SecureString
.But I think there's an easier way to do this with the
System.Web
assembly.Using this test data:
You could use a script similar to the one below. Note - Please make sure you test this before using it in production.