I have a few scripts in my $profile that require passwords for things like connecting to a corporate VPN or sending a command to a virtualized VM.
I don't want to type these passwords over and over and storing the passwords in my $profile is insecure.so i've come up with a solution.on $profile startup, i do something like this
$env:VpnPassword = (Get-Credential DomainGeorge.Mauer).GetNetworkCredential().Password
So when powershell starts i enter a password one time and in any scripts i can then use
I've confirmed that the variable is available only to the PS Session.and my reasoning is, since it seems to be in memory, that's a reasonably safe place to store it.
Is my logic sound? are the
$env values i'm creating stored only in memory?what about the pagefile? is that something that could be used to somehow grab these strings?is there a better way to achieve what i'm trying to do without introducing whole new systems?