r/PowerShell • • Mar 03 '21

Powershell scripts for beginners

121 Upvotes

21 comments sorted by

View all comments

3

u/TheGift1973 Mar 03 '21

When you run:

Get-CimInstance -ClassName Win32_ComputerSystem -Property UserName

You get a load of other information that doesn't have any values. The only value showing is for Username (which is not surprising given the script.)

What would you add to output the values for all the other items listed:

PS C:\Users\Me PC> Get-CimInstance -ClassName Win32_ComputerSystem -Property UserName


AdminPasswordStatus         :
BootupState                 :
ChassisBootupState          :
KeyboardPasswordStatus      :
PowerOnPasswordStatus       :
PowerSupplyState            :
PowerState                  :
FrontPanelResetStatus       :
ThermalState                :
Status                      :
Name                        : MyUsername
PowerManagementCapabilities :
PowerManagementSupported    :
Caption                     :
Description                 :
InstallDate                 :
CreationClassName           :
NameFormat                  :
PrimaryOwnerContact         :
PrimaryOwnerName            :
Roles                       :
InitialLoadInfo             :
LastLoadInfo                :
ResetCapability             :
AutomaticManagedPagefile    :
AutomaticResetBootOption    :
AutomaticResetCapability    :
BootOptionOnLimit           :
BootOptionOnWatchDog        :
BootROMSupported            :
BootStatus                  :
ChassisSKUNumber            :
CurrentTimeZone             :
DaylightInEffect            :
DNSHostName                 :
Domain                      :
DomainRole                  :
EnableDaylightSavingsTime   :
HypervisorPresent           :
InfraredSupported           :
Manufacturer                :
Model                       :
NetworkServerModeEnabled    :
NumberOfLogicalProcessors   :
NumberOfProcessors          :
OEMLogoBitmap               :
OEMStringArray              :
PartOfDomain                :
PauseAfterReset             :
PCSystemType                :
PCSystemTypeEx              :
ResetCount                  :
ResetLimit                  :
SupportContactDescription   :
SystemFamily                :
SystemSKUNumber             :
SystemStartupDelay          :
SystemStartupOptions        :
SystemStartupSetting        :
SystemType                  :
TotalPhysicalMemory         :
UserName                    : MyUsername\Me PC
WakeUpType                  :
Workgroup                   :
PSComputerName              :
CimClass                    : root/cimv2:Win32_ComputerSystem
CimInstanceProperties       : {Caption, Description, InstallDate, Name…}
CimSystemProperties         : Microsoft.Management.Infrastructure.CimSystemProperties

9

u/doog36 Mar 03 '21

Change property from 'username' to *

4

u/TheGift1973 Mar 03 '21

Beautiful.

Thank you for this.

Very new to all things PS, so thanks for the assist