Sunday, May 29, 2022

PowerShell 003 - Piping, Variables and a few Commands

Piping, Variables and a few Commands

            Piping | (above the enter key) - Used to "pipe" (continue/extend) one cmdlet into another


                        Start-Process 'C:\[Path]\[file.exe]'

            Starts a process at the specified file location



                        Get-Process [Name] | Stop-Process

            Gets a specified process and stops it.



                        Run "cmd.exe /c \"start compmgmt.msc\""

            Will run a command in cmd.exe, runs what is between “[cmd]”



                        $hn = hostname

                        Get-WmiObject -Class Win32_Product -ComputerName $hn | select name

            $hn is variable set as the current device hostname, the next line will pull a list of installed applications piped | into a filter to only show by name.