9
u/SammyGreen Mar 03 '21
I wouldn't exactly call this is scripting but I use this cmdlet all the time and it's definitely very valuable to know 🙃
4
u/abraxastaxes Mar 03 '21
I have this all the time at work, someone will be like "oh I found this powershell script for that" sends long one-liner
8
u/SammyGreen Mar 03 '21
Haha well cmdlets leads to piping which leads to scripting which leads to making modules
So whatever gets people going is great. I got my start as a script kiddie modifying a line or two here and there ;)
7
u/techerton Mar 03 '21
We should get rid of script kiddie shaming as it's how most get started.
5
2
u/anomalous_cowherd Mar 04 '21
The shaming is for people who only know how to run other people's scripts but think they know everything.
You've met them, you know who they are.
1
u/abraxastaxes Mar 10 '21
Oh yeah, same. I certainly don't shame anyone for it, I try to be really encouraging I'd love to not be the only one on my team with more in depth powershell knowledge. Lots of stuff comes my way that I don't necessarily want being the only one lol.
3
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.CimSystemProperties9
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
1
1
u/seanking83 Mar 03 '21
Awesome. Thanks for sharing. I’m a beginner and lost and confused a lot. Haha
-5
u/robomikel Mar 03 '21 edited Mar 03 '21
Note for the beginners. Get-CIMinstance is for PS7. use Get-WMIobject for PS5. If I am not mistaken.
10
u/Swarfega Mar 03 '21
You are mistaken. Although I think the CIM cmdlets came about in v3. Before then it was only WMI.
2
u/robomikel Mar 03 '21
Was doing on it my phone. Fixed the spelling. I use PS7. Remember trying to CIM and it failing server 2016. Guess would have to check the default versions for windows server.
6
u/Swarfega Mar 03 '21
2008 R2 came with V2 which didn't have CIM. 2012 R2 came with v4. Version 3 was the release that introduced the CIM cmdlets
1
11
u/InsrtCoffee2Continue Mar 03 '21
Yeah, not a script but you can easily make it into one with those Cmdlets.