From the course: Complete Guide to PowerShell 7
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Using Invoke-Command - PowerShell Tutorial
From the course: Complete Guide to PowerShell 7
Using Invoke-Command
- [Instructor] Now of course we did touch on using the invoke command, but the invoke command is one that we can just pass the computer name to with the credentials, et cetera, and it will just invoke what we need. Now, of course, if we do invoke command like this and say get service, I'm just going to copy this here, we can paste that in like so. And of course you'll notice it comes back, and it does that failure process again. So let's just take this same command right here, and we can paste that into there. And then of course, what I want to do here is just look at what other properties are available. And sure enough, there's a credential property. So we are going to go and load our creds option into there. We can take that same command that just failed over here, paste it in, and then of course it works as expected. So just be aware, you may need to pass that creds object. Now of course, we can execute a standard retrieval like we did here, so get-service, or we could actually…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.