# First Create Credential File
$CredentailFileName = "AzCredential.txt";
$Credential = Get-Credential
$UserName =[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($Credential.UserName))
$Password = ConvertFrom-SecureString -SecureString $Credential.Password -Key (1..16)
($UserName,$Password) | Set-Content -Path $CredentailFileName
# Read Credential File and Connect-AzAccount
$CredentailFileName = "AzCredential.txt";
[string[]]$CredentialRead = Get-Content -Path $CredentailFileName
$UserName = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($CredentialRead[0]))
$Password = $CredentialRead[1] | ConvertTo-SecureString -Key (1..16)
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $Password
Connect-AzAccount -Credential $Credential
沒有留言:
張貼留言