Powershell query windows services
The default display shows the status, service name, and display name of each service. This example displays services with a display name that includes the word network. Searching the display name finds network-related services even when the service name doesn't include Net, such as xmlprov, the Network Provisioning Service. This example only gets the services with service names that begin with win , except for the WinRM service. Get-Service gets all the services on the computer and sends the objects down the pipeline.
The Where-Object cmdlet, selects only the services with a Status property that equals Running. Status is only one property of service objects. To see all of the properties, type Get-Service Get-Member. The Get-Service cmdlet gets all the services on the computer and sends the objects down the pipeline. The Where-Object cmdlet selects the services whose DependentServices property isn't null.
The results are sent down the pipeline to the Format-List cmdlet. The Property parameter displays the name of the service, the name of the dependent services, and a calculated property that displays the number of dependent services for each service. This example shows that when you sort services in ascending order by the value of their Status property, stopped services appear before running services.
The reason is because the value of Status is an enumeration, in which Stopped has a value of 1, and Running has a value of 4. For more information, see ServiceControllerStatus. To list running services first, use the Descending parameter of the Sort-Object cmdlet. Gets or sets a value that indicates whether the objects that are returned from WMI should contain amended information. Typically, amended information is localizable information, such as object and property descriptions, that is attached to the WMI object.
Runs the command as a background job. Use this parameter to run commands that take a long time to finish. When you use the AsJob parameter, the command returns an object that represents the background job and then displays the command prompt. You can continue to work in the session while the job finishes. If Get-WmiObject is used on a remote computer, the job is created on the local computer, and the results from remote computers are automatically returned to the local computer.
To manage the job, use the cmdlets that contain the Job cmdlets. To get the job results, use the Receive-Job cmdlet. To use this parameter with remote computers, the local and remote computers must be configured for remoting.
Additionally, you must start Windows PowerShell by using the "Run as administrator" option in Windows Vista and later versions of Windows. Specifies the authority to use to authenticate the WMI connection. You cannot include the authority setting when you connect to the local computer. Specifies the name of a WMI class. When this parameter is used, the cmdlet retrieves instances of the WMI class. Specifies the target computer for the management operation.
When the remote computer is in a different domain than the local computer, the fully qualified domain name is required. The default is the local computer. To specify the local computer, such as in a list of computer names, use "localhost", the local computer name, or a dot. Specifies a user account that has permission to perform this action. The default is the current user. When you type a user name, you are prompted for a password.
Your email address will not be published. Aggiungi e-mail alla newsletter. Notify me of follow-up comments by email. Notify me of new posts by email. Enabling Remote Work. Small and Medium Business. Humans of IT. Green Tech. MVP Award Program. Video Hub Azure. Microsoft Business. Microsoft Enterprise. Browse All Community Hubs. Turn on suggestions. Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
0コメント