Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Examples of the usage of PowerShell Where-Object

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The FilterScript value is a script block that evaluates to True or False, that is, one or more Windows PowerShell commands surrounded by curly braces {}. These script blocks may be very simple, but you need to understand another concept about Windows PowerShell, the comparison operator, to create them. The comparison operator compares the items displayed on each side of it. The comparison operator begins with the "-" character, followed by the name. The basic comparison operator applies to almost any type of object. More advanced comparison operators may apply only to text or arrays.

Here are some sample commands, from simple to complex

Get-WmiObject-Class Win32_SystemDriver | Where-Object-FilterScript {$_ .State-eq 'Running'}

Get-WmiObject-Class Win32_SystemDriver | Where-Object-FilterScript {$_ .State-eq "Running"} | Where-Object-FilterScript {$_ .StartMode-eq "Auto"}

Get-WmiObject-Class Win32_SystemDriver | Where-Object-FilterScript {$_ .State-eq "Running"} | Where-Object-FilterScript {$_ .StartMode-eq "Manual"} | Format-Table-Property Name,DisplayName

Get-WmiObject-Class Win32_SystemDriver | Where-Object-FilterScript {($_ .State-eq 'Running')-and ($_ .StartMode-eq' Manual')} | Format-Table-Property Name,DisplayName

In addition to the comparison operators listed above, there are some logical operators that can also be used with where-object

You can also follow the official Wechat account below for more information.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report