How To Tell When A Command Won’t Work With The PowerShell Pipeline

Many commands work with the PowerShell pipeline but some don’t. If you’re trying to pipe a command to another and it’s not working, be sure to check out this video by Adam Bertram. He covers how to use the help content to figure out which commands work with the PowerShell pipeline and a little about how parameter binding works.
Hello this dip, I like to go over how to tell when a command won't work with the powershell pipeline or if you like win it will work. So if you're not familiar with the powershell pipeline and how it works with commands inputs and outputs. Not every command will actually work. So you won't bind the appropriate properties of appropriate objects between an outputing command and input of another command, so let me show. It example of how you can tell if a command does support pipeline input to do that. We have to use the get help command and in this instance, I'm using get help on the start service command. And you also have to use the dash full parameter, which is a switch parameter to see all of the different parameters that that command has so now I can scroll down through here and there's a section here that has all of the different parameters because I don't feel like scrolling forever. I'm just going to show you the parameters that I want to talk about and so the first one, is the display name parameter. So the start service command has a display name parameter that allows you to specify whatever. The. My name is you want to start. However, if you look down through each of those properties of the parameter. You see that it has accept pipeline input and that is currently false that's a clear indication that it does not accept pipeline input. That's the clear indication that the only indication right there and then you can see that it does not accept pipeline input and you'll see this attribute on not only built in command. Let's that I'm using here, but also advanced functions as well. So I'll show you another example here on start service. Start service has an input object parameter as well. In this case now you can see that accept pipeline input is true but it says by value by value means that it accept pipeline input by the entire object. There's all kinds of different content around the pipeline and how it works with binding. I'm actually going to demonstrate how this works in another snip. For now, you could just know that whenever the pipeline works by parameter binding so that you can bind to either by value or by a property name by value means the entire object so notice that the object here is service controller. An we have parameter binding works by if the start service command sees a service controller object coming into it. It's going to automatically try to bind to this by value so that's where you can tell that it binds by value. The next year is you can see the name parameter binds by property name and by value. That means that if the start service command. sees input coming in from the pipeline with a object with a name property. That means that it will bind as well. It will also try to bind with a string so to demonstrate what that looks like is let's say that I have a service name of WAUSERV, an I can. Pipe this to start service. And it actually works just fine because it bound to that name parameter WUAUSERV was just a string. Let me show you first what this looks like with get member just to show you that it is a string whenever I use get member see that's a system dot string there. So let's also pipe the output of get service to it. So let's say that I'm using get service WUAUSERV and pipe this to get member as well. Now you'll see that this is a service controller opposite the kind of type that the input object parameter wants to see. So now when I can pipe this to start service now that it works, just fine as well because that time, it bound. The entire object that get service returns so it found all that object there with all those properties based on value. Otherwise, we could have used this the string. We don't have a server control object. We just have a simple string and that actually bound on the name parameter. So all about seeing that accept pipeline input in the help to tell whether or not a command will work with the powershell pipeline or not so that is been how to tell when a command won't work with the powershell pipeline thanks for watching.