Powershell Secure密码可在任何机器上使用 [英] Powershell Secure password to work on any machine

查看:139
本文介绍了Powershell Secure密码可在任何机器上使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一个Powershell脚本,该脚本可以在任何计算机上运行以连接到服务器. 安全字符串是否使用计算机或用户进行加密,即安全密码将在域中的任何计算机上工作,还是只能在创建该计算机的计算机上解密?如果是后者,则可以加密密码,以便我可以在任何计算机上运行脚本

I need to write a powershell script that i can run on any machine to connect to a server. Does the secure-string encrypt using the machine or user i.e will a secure password work on any machine in the domain or can it only be decrypted on the machine it was created on. If it is the latter is there away to encrypt the password so i can run the script on any machine

推荐答案

要在其他计算机上工作,您需要创建一个与ConvertTo-SecureString和ConvertFrom-SecureString cmdlet一起使用的密钥.

To work on other machines you'll need to create a key for use with the ConvertTo-SecureString and ConvertFrom-SecureString cmdlets.

PS C:\> $Key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)
PS C:\>$StandardString = ConvertFrom-SecureString  $SecureString -Key $Key

http://www.leeholmes.com/blog/2006/06/01/securestrings-in-powershell/

默认情况下,SecureString cmlet使用Windows的数据保护API 当他们与纯文本之间来回转换您的SecureString时 表示.加密密钥基于Windows登录 凭据,这样只有您才能解密已加密的数据. 如果您希望导出的数据在其他系统上运行或在其他系统上运行 用户帐户,您可以使用参数集来提供 明确的密钥.

By default, the SecureString cmlets use Windows’ Data Protection API when they convert your SecureString to and from a plain text representation. The encryption key is based on your Windows logon credentials so only you can decrypt the data that you’ve encrypted. If you want the exported data to work on another system or separate user account, you can use the parameter sets that let you provide an explicit key.

这篇关于Powershell Secure密码可在任何机器上使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆