問題描述
查找具有特定 startname 的特定服務 (Finding specific services with specific startname)
I m looking for a powershell one line script to find all the services that contain the word "Altiris" and service start name not equal 'localSystem'. Is the below a valid script for that purpose?
$Services = get‑WMIObject ‑query "Select * from win32_service where name ‑contain 'Altiris' and startname ‑ne 'LocalSystem'"
參考解法
方法 1:
There is no ‑Contains
in WMI Query Language. The operators you are using are all PowerShell operators and the WQL operators are different.
Get‑WmiObject ‑Query "Select * from Win32_Service WHERE Name LIKE '%Altris%' AND StartName
<> 'Localsystem'"
For more information on WQL Operators, read http://msdn.microsoft.com/en‑us/library/windows/desktop/aa394605(v=vs.85).aspx