PowerShell Services the Basics

#|||| Gets Service by Name ||||   
        Get-Service -Name Wsearch -ErrorVariable ErrorVar -ErrorAction SilentlyContinue | Select Name, Status

        #|||| Get Service by Name and Starts Service |||        
        Get-Service | Where{$_.Name -eq "WSearch"} | Start-Service -ErrorVariable ErrorVar -ErrorAction SilentlyContinue

        #|||| Get Service by Name and Changes Startup Type |||
        Get-Service | Where{$_.Name -eq "Wsearch"} | Set-Service -StartupType Automatic -ErrorVariable ErrorVar -ErrorAction SilentlyContinue

        #|||| Gets Service by Name and if Stopped Tries to Start it ||||  
        Get-Service -Name WSearch -ErrorVariable  ErrorVar -ErrorAction SilentlyContinue | ?{$_.Status -eq 'Stopped'} | Start-Service 




    #Displays any Error Messages
    if($ErrorVar -ne $Null){