Skip to content

Commit

Permalink
Update Collecting-Information-About-Computers.md
Browse files Browse the repository at this point in the history
added full command, changed output result as of today.
taken reference output from Windows 11.

i edited this article
https://learn.microsoft.com/en-us/powershell/scripting/samples/collecting-information-about-computers?view=powershell-7.3
  • Loading branch information
RAJU2529 authored Oct 13, 2023
1 parent a9d1800 commit 381f6fe
Showing 1 changed file with 31 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -151,21 +154,19 @@ 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
with either **Build** or **ServicePack** are important to use here, we can shorten this to the
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
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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 :
```

Expand All @@ -266,15 +264,13 @@ 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
**Wrap** parameters of `Format-Table`. These parameters optimize column width and allow long names
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
```

0 comments on commit 381f6fe

Please sign in to comment.