diff --git a/reference/docs-conceptual/samples/Collecting-Information-About-Computers.md b/reference/docs-conceptual/samples/Collecting-Information-About-Computers.md index 898740a74e8d..40361e9f6b1a 100644 --- a/reference/docs-conceptual/samples/Collecting-Information-About-Computers.md +++ b/reference/docs-conceptual/samples/Collecting-Information-About-Computers.md @@ -64,7 +64,7 @@ Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property System SystemType ---------- -X86-based PC +X64-based PC ``` ## Listing computer manufacturer and model @@ -77,9 +77,9 @@ Get-CimInstance -ClassName Win32_ComputerSystem ``` ```Output -Name PrimaryOwnerName Domain TotalPhysicalMemory Model Manufacturer ----- ---------------- ------ ------------------- ----- ------------ -MyPC Jane Doe WORKGROUP 804765696 DA243A-ABA 6415cl NA910 Compaq Presario 06 +Name PrimaryOwnerName Domain TotalPhysicalMemory Model Manufacturer +---- ---------------- ------ ------------------- ----- ------------ +LAPTOP-X542UQ RAJU WORKGROUP 17021026304 X542UQ ASUSTeK COMPUTER INC. ``` Your output from commands such as this, which return information directly from some hardware, is @@ -97,9 +97,11 @@ Get-CimInstance -ClassName Win32_QuickFixEngineering This class returns a list of hotfixes that looks like this: ```Output -Source Description HotFixID InstalledBy InstalledOn PSComputerName ------- ----------- -------- ----------- ----------- -------------- - Security Update KB4048951 Administrator 12/16/2017 . +Source Description HotFixID InstalledBy InstalledOn +------ ----------- -------- ----------- ----------- + Update KB5030651 NT AUTHORITY\SYSTEM 16-09-2023 12:00:00 AM + Update KB5031455 NT AUTHORITY\SYSTEM 12-10-2023 12:00:00 AM + Update KB5031893 NT AUTHORITY\SYSTEM 12-10-2023 12:00:00 AM ``` For more succinct output, you may want to exclude some properties. Although you can use the @@ -119,29 +121,30 @@ Name : Status : CSName : FixComments : -HotFixID : KB4533002 +HotFixID : KB5030651 InstalledBy : ServicePackInEffect : PSComputerName : CimClass : root/cimv2:Win32_QuickFixEngineering -CimInstanceProperties : {Caption, Description, InstallDate, Nameā€¦} +CimInstanceProperties : {Caption, Description, InstallDate, Name...} CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties ... ``` -The additional data is returned, because the **Property** parameter in `Get-CimInstance` restricts +The additional data is returned because the **Property** parameter in `Get-CimInstance` restricts the properties returned from WMI class instances, not the object returned to PowerShell. To reduce the output, use `Select-Object`: ```powershell -Get-CimInstance -ClassName Win32_QuickFixEngineering -Property HotFixId | - Select-Object -Property HotFixId +Get-CimInstance -ClassName Win32_QuickFixEngineering -Property HotFixId | Select-Object -Property HotFixId ``` ```Output HotFixId -------- -KB4048951 +KB5030651 +KB5031455 +KB5031893 ``` ## Listing operating system version information @@ -151,8 +154,7 @@ explicitly select only these properties to get a version information summary fro **Win32_OperatingSystem**: ```powershell -Get-CimInstance -ClassName Win32_OperatingSystem | - Select-Object -Property BuildNumber,BuildType,OSType,ServicePackMajorVersion,ServicePackMinorVersion +Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property BuildNumber,BuildType,OSType,ServicePackMajorVersion,ServicePackMinorVersion ``` You can also use wildcards with the **Property** parameter. Because all the properties beginning @@ -160,12 +162,11 @@ with either **Build** or **ServicePack** are important to use here, we can short following form: ```powershell -Get-CimInstance -ClassName Win32_OperatingSystem | - Select-Object -Property Build*,OSType,ServicePack* +Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property Build*,OSType,ServicePack* ``` ```Output -BuildNumber : 18362 +BuildNumber : 22621 BuildType : Multiprocessor Free OSType : 18 ServicePackMajorVersion : 0 @@ -178,8 +179,7 @@ General information about local users can be found with a selection of **Win32_O class properties. You can explicitly select the properties to display like this: ```powershell -Get-CimInstance -ClassName Win32_OperatingSystem | - Select-Object -Property NumberOfLicensedUsers, NumberOfUsers, RegisteredUser +Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property NumberOfLicensedUsers, NumberOfUsers, RegisteredUser ``` A more succinct version using wildcards is: @@ -205,9 +205,7 @@ Q: 3 New Volume 122934034432 44298250240 . ``` ```powershell -Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" | - Measure-Object -Property FreeSpace,Size -Sum | - Select-Object -Property Property,Sum +Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" | Measure-Object -Property FreeSpace,Size -Sum | Select-Object -Property Property,Sum ``` ```Output @@ -245,16 +243,16 @@ Get-CimInstance -ClassName Win32_LocalTime ``` ```Output -Day : 23 -DayOfWeek : 1 -Hour : 8 +Day : 13 +DayOfWeek : 5 +Hour : 20 Milliseconds : -Minute : 52 -Month : 12 +Minute : 18 +Month : 10 Quarter : 4 -Second : 55 -WeekInMonth : 4 -Year : 2019 +Second : 25 +WeekInMonth : 2 +Year : 2023 PSComputerName : ``` @@ -266,8 +264,7 @@ cmdlet. For remote systems, you can use the **Win32_Service** WMI class. If you format is almost identical to that from `Get-Service`: ```powershell -Get-CimInstance -ClassName Win32_Service | - Select-Object -Property Status,Name,DisplayName +Get-CimInstance -ClassName Win32_Service | Select-Object -Property Status,Name,DisplayName ``` To allow the complete display of names for services with long names, use the **AutoSize** and @@ -275,6 +272,5 @@ To allow the complete display of names for services with long names, use the **A to wrap instead of being truncated: ```powershell -Get-CimInstance -ClassName Win32_Service | - Format-Table -Property Status, Name, DisplayName -AutoSize -Wrap +Get-CimInstance -ClassName Win32_Service | Format-Table -Property Status, Name, DisplayName -AutoSize -Wrap ```