@@ -224,9 +224,9 @@ Get-CimInstance returns a CimInstance object, instead of
224
224
the ManagementObject that Get-WmiObject returns, but
225
225
the objects are quite similar.
226
226
227
- PS C:>(Get-CimInstance -Query "Select * from Win32_Bios").GetType().FullName
227
+ PS C:> (Get-CimInstance -Query "Select * from Win32_Bios").GetType().FullName
228
228
Microsoft.Management.Infrastructure.CimInstance
229
- PS C:>(Get-WmiObject -Query "Select * from Win32_Bios").GetType().FullName
229
+ PS C:> (Get-WmiObject -Query "Select * from Win32_Bios").GetType().FullName
230
230
System.Management.ManagementObject
231
231
232
232
USING THE [ wmisearcher] TYPE ACCELERATOR
@@ -287,12 +287,12 @@ When you use the [wmisearcher] type accelerator, it
287
287
changes the query string into a ManagementObjectSearcher
288
288
object, as shown in the following commands.
289
289
290
- PS C:>$a = "Select * from Win32_Bios"
291
- PS C:>$a.GetType().FullName
290
+ PS C:> $a = "Select * from Win32_Bios"
291
+ PS C:> $a.GetType().FullName
292
292
System.String
293
293
294
- PS C:>$a = [ wmisearcher] "Select * from Win32_Bios"
295
- PS C:>$a.GetType().FullName
294
+ PS C:> $a = [ wmisearcher] "Select * from Win32_Bios"
295
+ PS C:> $a.GetType().FullName
296
296
System.Management.ManagementObjectSearcher
297
297
298
298
This command format works on any query. The following
@@ -511,8 +511,8 @@ Select-Object cmdlet gets the Name and ProcessID
511
511
properties, and the Sort-Object cmdlet sorts the
512
512
results in alphabetical order by name.
513
513
514
- PS C:>$query = "Select * from win32_Process where name LIKE '[ A-P] %'"
515
- PS C:>Get-WmiObject -Query $query |
514
+ PS C:> $query = "Select * from win32_Process where name LIKE '[ A-P] %'"
515
+ PS C:> Get-WmiObject -Query $query |
516
516
Select-Object -Property Name, ProcessID |
517
517
Sort-Object -Property Name
518
518
@@ -523,8 +523,8 @@ do not begin with any of the following letters:
523
523
524
524
and followed zero or more letters.
525
525
526
- PS C:>$query = "Select * from win32_Process where name LIKE '[ ^ ASWPRCUN ] %'"
527
- PS C:>Get-WmiObject -Query $query |
526
+ PS C:> $query = "Select * from win32_Process where name LIKE '[ ^ ASWPRCUN ] %'"
527
+ PS C:> Get-WmiObject -Query $query |
528
528
Select-Object -Property Name, ProcessID |
529
529
Sort-Object -Property Name
530
530
@@ -588,8 +588,8 @@ For example, the following commands get all instances
588
588
of the Win32_Process WMI class but returns them
589
589
only if the process name is winword.exe or excel.exe.
590
590
591
- PS C:>$q = "Select * from Win32_Process where Name = 'winword.exe' or Name = 'excel.exe'"
592
- PS C:>Get-WmiObject -Query $q
591
+ PS C:> $q = "Select * from Win32_Process where Name = 'winword.exe' or Name = 'excel.exe'"
592
+ PS C:> Get-WmiObject -Query $q
593
593
594
594
The Or statement can be used with more than two
595
595
conditions. In the following query, the Or statement
@@ -613,7 +613,7 @@ ID of 6512.
613
613
614
614
Note that the commands use the Get-CimInstance cmdlet.
615
615
616
- PS C:>$q = "Select * from Win32_Process where Name = 'winword.exe' and ProcessID =6512"
616
+ PS C:> $q = "Select * from Win32_Process where Name = 'winword.exe' and ProcessID =6512"
617
617
PS C:> Get-CimInstance -Query $q
618
618
619
619
ProcessId Name HandleCount WorkingSetSize VirtualSize
@@ -657,17 +657,17 @@ For example, the following commands get processes
657
657
that have a null value for the IntallDate property.
658
658
The commands return many processes.
659
659
660
- PS C:>$q = "Select * from Win32_Process where InstallDate is null"
661
- PS C:>Get-WmiObject -Query $q
660
+ PS C:> $q = "Select * from Win32_Process where InstallDate is null"
661
+ PS C:> Get-WmiObject -Query $q
662
662
663
663
In contrast, the following command, gets user
664
664
accounts that have a null value for the Description
665
665
property. This command does not return any user
666
666
accounts, even though most user accounts do not have
667
667
any value for the Description property.
668
668
669
- PS C:>$q = "Select * from Win32_UserAccount where Description is null"
670
- PS C:>Get-WmiObject -Query $q
669
+ PS C:> $q = "Select * from Win32_UserAccount where Description is null"
670
+ PS C:> Get-WmiObject -Query $q
671
671
672
672
To find the user accounts that have no value for
673
673
the Description property, use the equality operator
@@ -685,14 +685,14 @@ sensitive.
685
685
The following WQL query returns only local user
686
686
accounts from a domain joined computer.
687
687
688
- PS C:>$q = "Select * from Win32_UserAccount where LocalAccount = True"
689
- PS C:>Get-CimInstance -Query $q
688
+ PS C:> $q = "Select * from Win32_UserAccount where LocalAccount = True"
689
+ PS C:> Get-CimInstance -Query $q
690
690
691
691
To find domain accounts, use a value of False,
692
692
as shown in the following example.
693
693
694
- PS C:>$q = "Select * from Win32_UserAccount where LocalAccount = False"
695
- PS C:>Get-CimInstance -Query $q
694
+ PS C:> $q = "Select * from Win32_UserAccount where LocalAccount = False"
695
+ PS C:> Get-CimInstance -Query $q
696
696
697
697
# USING THE ESCAPE CHARACTER
698
698
0 commit comments