标签:pass container font object 脚本 comm 调用 secure mil
1. 把密码转变为加密的字符串。使用命令 ConvertFrom-SecureString
Read-Host "Enter Password" -AsSecureString | ConvertFrom-SecureString | Out-File "C:\pwd.txt" #弹出输入密码的对话框,然后把加密后的密码保存到输出的文件中。
2. 把加密后的字符串转换成SecureString对象。使用命令 ConvertTo-SecureString
$f = "D:\pwd.txt"$SecurePwd = Get-Content $f | ConvertTo-SecureString 使用密码文件创建 Credential 信息$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList UserName, (Get-Content $f | ConvertTo-SecureString) #UserName替换成你要创建的用户名密码是引用第二步的内容标签:pass container font object 脚本 comm 调用 secure mil
原文地址:https://www.cnblogs.com/20e8/p/9994151.html