HI,
I have created a text file and saved my plain string there, then run below command to encrypt it:
'passkey' | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Set-Content -Path C:\PreShareKeyEncypted.txt
-
Next steps, I ran below commands to read from the encrypted text file and passed it to the next line:
$PreSharedKeyEncrypted = Get-Content -Path c:\system\PreShareKeyEnc.txt | ConvertTo-SecureString
Add-VpnConnection -Name "VPN" -ServerAddress "vpn.xxxx.com" -TunnelType "L2TP" -L2tpPsk "$PreSharedKeyEncrypted" -EncryptionLevel "Required" -AuthenticationMethod MSChapv2 -UseWinlogonCredential -SplitTunneling -RememberCredential -Force
When I run this script on my system it works as expected, however when I run it on another machine, it errors our with these errors:
1- "key not valid for use in specified state", and...