Search code examples
powershellpowershell-2.0powershell-3.0powershell-remotingpowershell-4.0

Powershell - Running remote session on intended server


So I have a server set up for remoting called "Server01" so I can use the PS2 configuration.

Problem is I want to run the ISE as PS2 on the same machine.

So I am trying:

$username = "Domain\User"
$password = "Password"

$cred = new-object -typename System.Management.Automation.PSCredential -ArgumentList $username, $password

$s=new-PSsession "Server01" -authentication Credssp -credential $cred -ConfigurationName PS2

Invoke-Command -Session $s -ScriptBlock {

}
Remove-PSSession $s

while on "Server01" and I am getting an access denied error. I have made sure "Allow Delegating Fresh Credentials" is enabled and configured properly.

I am trying to avoid running this through the Management Shell because I would like to have a scheduled task kick off this script automatically.

Any suggestions/ideas?


Solution

  • You don't have to use session configurations to invoke PowerShell with version 2.0 in a scheduled task.

    Just use:

    powershell.exe -Version 2.0
    

    In your task definition. This is way easier and safer than trying to remote into the local machine with CredSSP.