Once you have enabled PowerShell remoting on a target machine, try and connect to it interactively. Here is a line you should try. Just make sure you replace “targetComputerName” with the name of the target computer you want to connect to:
PS C:\> Enter-PSSession -ComputerName targetComputerName
[targetComputerName]: PS C:\Users\User12\Documents> $env:COMPUTERNAME
[targetComputerName]: PS C:\Users\User12\Documents> exit
PS C:\> $env:COMPUTERNAME
If connection fails with an “Access Denied”, you may want to use the –Credential parameter and log on to the remote computer using a different user account. You will need local Administrator privileges.
If your connection fails with an RDP error, or if WinRM cannot find the target computer name, check the connection with Test-WSMan, and if it cannot connect, review your remoting setup. You may have to run Enable-PSRemoting on the target machine first as described in an earlier tip.
Do not run commands that open windows. Only run commands that produce text information.
To leave the remote session, use “exit”.
ReTweet this Tip!