【发布时间】:2015-02-28 09:09:44
【问题描述】:
我有一个 Powershell 脚本,它使用存储为文件中安全字符串的密码运行了几个月。当我今天去运行脚本时,我开始收到“密钥在指定状态下无效”。该脚本由 Active Directory 域帐户运行的计划任务调用。该帐户没有更改,我知道的唯一事件是服务器重新启动。什么可能导致此问题发生?
将我的数据转换回安全字符串再次解决了这个问题,但我很困惑为什么它首先会发生。
我通过以下方式创建密码文件:
Write-Host "Please enter the filename where you'd like to store the password:"
$passwordFile = Read-Host
Write-Host "Please enter the ftp password and press enter:"
read-host -AsSecureString | ConvertFrom-SecureString | Out-File $passwordFile
Write-Host "Your Password File ($passwordFile) has been created."
我像这样从文件中检索密码:
$FTPPassword = Get-Content $FTPPasswordFilePath
$script:FTPCredObj = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $FTPUserName,($FTPPassword | ConvertTo-SecureString)
我确实注意到与用户个人资料有关的事件日志中有错误:
“Windows 找不到本地配置文件,正在使用临时配置文件让您登录。您对此配置文件所做的更改将在您注销时丢失。”
我作为任务用户执行 RDP 以更新包含安全字符串的文件,之后我没有注意到任何配置文件错误。
【问题讨论】:
标签: windows powershell