Powershell Enter-PSSession use current credential

8,643

For Enter-PSSession cmdlet "-Credential" is not a mandatory parameter. So if you don't specify credential, your current credential will be used.

Share:
8,643

Related videos on Youtube

Void Star
Author by

Void Star

Hi, my name is Kyle. I have been interested in science, math, and engineering for (quite literally) as long as I can remember. I am an avid programmer and electronics hobbyist. I attended the University of Washington as an undergraduate in the Electrical Engineering department and now work for Keysight Technologies as a research and development software engineer.

Updated on September 18, 2022

Comments

  • Void Star
    Void Star almost 2 years

    I want to use Windows Powershell to start up a VirtualBox VM and then Enter-PSSession to manage the machine on an automated nightly system, which means I will be asleep when this is happening and not able to enter in a password.

    I have two choices as far as I know: 1. Use the current credentials, as these are on a domain that the VM accepts credentials from. 2. Hardcode in my credentials (probably the same as the current credentials)

    I do not like option 2 as I have been tasked with the avoidance of hardcoded credentials where possible, but I do not know whether option 1 is possible. How would you solve this problem?

  • Void Star
    Void Star almost 9 years
    Yeah, I tried that before and it didn't work, but that's because I was logged on as a different user than I intended to be. Managing a desktop is hard enough without a remote desktop inside that and a virtual machine inside the remote desktop... Ok, thanks for prompting me to try this again.
  • Void Star
    Void Star almost 9 years
    Also you have to use New-PSSession in a script, Enter-PSSession is for interactive remote session.