PowerShell offers powerful features in dealing with Windows services, and many convenient, powerful cmdlet waiting for you to patronize.
Get-service, alias GSV, gets the service object.
Example: GSV eventlog or $evtlog = GSV EventLog
Start-service, start the service.
Stop-service, stop the service.
Restart-service, restart the service.
Suspend-service, suspend/suspend service.
Resume-service, continue to serve.
Set-service, set the properties of the service.
New-service, create a new service.
Invoke the properties and methods of the service
1, first access to services
GSV < service name, or $ service variable name =GSV < service name >
2. Calling Properties
$ service Variable name. Property name
3. Calling methods
$ service Variable name. Method Name ()
There is a simpler way: (GSV < service name >) .< Property name > or < method name > (), such as (GSV w3svc). Stop ()