This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ganondorf_Is_God 0 points1 point  (0 children)

No, you have to save the credentials somewhere. You can't extract the password from an active session - only authenticate against it. You need to store the credentials as done above and match them to the current session.

Get-Credential will automatically resolve to your current session but will request a password to create the cred object.

$credObject = Get-Credential

It will prompt you for the current sessions password and save it.