Jas*_*son 2 powershell windows-10
我正在使用以下内容来创建密码文件:
$path = "C:\Users\USER\Desktop"
$passwd = Read-Host "enter desired password" -AsSecureString
$encpwd = ConvertFrom-SecureString $passwd
$encpwd > $path\filename.bin
Run Code Online (Sandbox Code Playgroud)
然后使用以下命令调用文件:
# define path to store password and input password
$path = "C:\Users\USER\Desktop"
# get the encrypted password from the path
$encpwd = Get-Content $path\filename.bin
# convert file to secure string
$passwd = ConvertTo-SecureString $encpwd
# define needed credential
$cred = new-object System.Management.Automation.PSCredential 'WIN-SERVER\AdminForQB',$passwd
# go to DVD drive launch setup.exe as user with privileges to launch the program with no user input required
Set-Location "C:\Program Files (x86)\Intuit\QuickBooks 2017\"
Start-Process PowerShell -windowstyle hidden -Cred $cred -ArgumentList .\QBW32PremierAccountant.exe
Run Code Online (Sandbox Code Playgroud)
我的目标是能够使用admin privs运行QB2017,而无需赋予用户admin privs。我遇到的问题是我必须在每个用户上生成密码文件,或者如果一个用户尝试使用从另一个用户生成的一个密码,则会出现以下错误:
Key not valid for use in specified state.
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以使用此方法而无需为每个用户生成密钥?
当您使用ConvertTo-SecureString
并ConvertFrom-SecureString
没有Key
或SecureKey
,PowerShell的将使用Windows数据保护API(DPAPI)来加密/解密的字符串。这意味着它将仅适用于同一台计算机上的同一用户。
当您使用密钥/安全密钥时,将使用高级加密标准(AES)加密算法。只要知道所使用的AES密钥,您就可以与任何用户一起从任何计算机使用存储的凭据。
注意:这只是通过隐蔽性实现的安全性,这不是一个好习惯。如果您将密钥和加密密码存储在同一台计算机上,它的安全性就比纯文本密码安全得多!
归档时间: |
|
查看次数: |
5480 次 |
最近记录: |