From the course: Complete Guide to PowerShell 7

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Using New-PSSession

Using New-PSSession

- [Instructor] Now, once we have all the configuration done, the first thing we want to do is obviously create a PowerShell session and we can use New-PSSession. So I'm going to paste just this in the right-hand side and you'll see it creates a session. But notice it's to the remote machine. Well, it's called a remote machine type, but actually the computer name is local host. So it's created it locally, so I now have remote session. If we ever want to see any of the sessions, then we can use what's called Get-PSSession, Get-PSSession lists, all of the sessions that exist. Now, of course I want to try and connect to the remote computer. So I have a variable here already. So if I just select that variable and say remote computer name, you can see it's already configured to try and connect to my active directory. So let me just clear that. So I'm going to say New-PSSession, computer name, and then load it into a session variable. And I'm going to copy this. Remember I'm running it in…

Contents