The command would look like this:
[PS] C:\ > Get-User | Where-Object { $_.Office -eq ???Dallas??? -and $_.Department -eq
???Engineering??? } | Set-User -Manager ???John Doe???
After collecting all users with Get-User , the collection of objects is passed to Where-Object to apply
the test conditions on each object one at a time. The first test checks for the Office property equal to
???Dallas??? . The second condition checks the Department property equal to ???Engineering??? . If both test
conditions result in true, the object is passed to the next command. If one of the test conditions results in
false, the object is disposed. After processing all objects in the stream, they are passed to Set-User for
applying the modification.
Finding Property Names and Data Types
To use Where-Object effectively you need to know the available property names and data types for
the objects being passed by a given cmdlet. By passing the results of any cmdlet that uses the Get verb
to the Get-Member cmdlet you can generate a list of properties and their data type. For example,
the command in Figure 1 - 18 sends the objects collected by the Get-Mailbox cmdlet to Get-Member and
displays the objects ??™ properties and their definition.
It is important to know the exact name of each property used in the Where-Object script block.
Pages:
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64