Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Handle password not as plaintext in the script

$
0
0

I need to work with password in a powershell function. I am getting the password using the below code

$credentials=Get-Credential
$p=$credentials.GetNetworkCredential().Password

This way the password is not visible  while entering it and I can use it later inside the script.

However, later when I try to use it in the function, it does not work, says password is empty  and even when I use Write-Host to display the contents of $p it does not work. I need to use this password multiple times in the function.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>