PowerShell 脚本中调用密文密码
发布时间:2020-12-15 23:12:48 所属栏目:安全 来源:网络整理
导读:1. 把密码转变为加密的字符串。使用命令 ConvertFrom-SecureString Read-Host "Enter Password" -AsSecureString | ConvertFrom-SecureString | Out-File "C:pwd.txt"????????? #弹出输入密码的对话框,然后把加密后的密码保存到输出的文件中。 2. 把加密后
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
?
3.
使用密码文件创建 Credential 信息
$Cred
=
New-Object
-TypeName
System.Management.Automation.PSCredential
example:
Enter-PSSession -ComputerName?10.1.1.1 -Credential $Cred???? #此命令可远程登录指定机器
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |