转换为字符串 Powershell 问题
Convert to string Powershell issue
我想像这样使用我的信用连接到在线 Exchange :
$Username = "bigdaddy@love.onmicrosoft.com"
$PasswordPath = "C:\PowerShell\password.txt"
#Read the password from the file and convert to SecureString
$SecurePassword = Get-Content $PasswordPath | ConvertTo-SecureString
$Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword
但是我在尝试转换为如下所示的字符串时遇到了问题
我只使用了 .txt 文件
只需添加-AsPlainText -Force
$Username = "bigdaddy@love.onmicrosoft.com"
$PasswordPath = "C:\PowerShell\password.txt"
#Read the password from the file and convert to SecureString
$SecurePassword = Get-Content $PasswordPath | ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword
我想像这样使用我的信用连接到在线 Exchange :
$Username = "bigdaddy@love.onmicrosoft.com"
$PasswordPath = "C:\PowerShell\password.txt"
#Read the password from the file and convert to SecureString
$SecurePassword = Get-Content $PasswordPath | ConvertTo-SecureString
$Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword
但是我在尝试转换为如下所示的字符串时遇到了问题
我只使用了 .txt 文件
只需添加-AsPlainText -Force
$Username = "bigdaddy@love.onmicrosoft.com"
$PasswordPath = "C:\PowerShell\password.txt"
#Read the password from the file and convert to SecureString
$SecurePassword = Get-Content $PasswordPath | ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword