Tuesday, May 9, 2017

Powershell command tips

1. get-command will bring the list of all commands available in powershell

2.How to get commands related to particular operation
get-command *service*
PS C:\Windows\system32> get-command *service*

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Cmdlet          Get-Service                                        Microsoft.PowerShell.Management
Cmdlet          New-Service                                        Microsoft.PowerShell.Management
Cmdlet          New-WebServiceProxy                                Microsoft.PowerShell.Management
Cmdlet          Restart-Service                                    Microsoft.PowerShell.Management
Cmdlet          Resume-Service                                     Microsoft.PowerShell.Management
Cmdlet          Set-Service                                        Microsoft.PowerShell.Management
Cmdlet          Start-Service                                      Microsoft.PowerShell.Management
Cmdlet          Stop-Service                                       Microsoft.PowerShell.Management
Cmdlet          Suspend-Service                                    Microsoft.PowerShell.Management
Application     services.exe
Application     services.msc
Application     services.msc



3. How to get a service with a specific noun
PS C:\Windows\system32> get-command -Noun service

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Cmdlet          Get-Service                                        Microsoft.PowerShell.Management
Cmdlet          New-Service                                        Microsoft.PowerShell.Management
Cmdlet          Restart-Service                                    Microsoft.PowerShell.Management
Cmdlet          Resume-Service                                     Microsoft.PowerShell.Management
Cmdlet          Set-Service                                        Microsoft.PowerShell.Management
Cmdlet          Start-Service                                      Microsoft.PowerShell.Management
Cmdlet          Stop-Service                                       Microsoft.PowerShell.Management
Cmdlet          Suspend-Service                                    Microsoft.PowerShell.Management


4. Get , Start and stop a service
PS C:\Windows\system32> get-service "windows update"

Status   Name               DisplayName
------   ----               -----------
Running  wuauserv           windows update


PS C:\Windows\system32> stop-service "windows update"
PS C:\Windows\system32> start-service "windows update"




No comments:

Post a Comment