It’s already Wednesday, can you believe it? Nothing crazy initially from today’s one liner, but once you learn the concepts, your imagination is the limit.
# Local Computer
(gcim Win32_OperatingSystem).LastBootUpTime
# Remote Computer
$s = new-cimsession -computername comp1,comp2 -credential credential
(gcim Win32_OperatingSystem -CimSession $s).LastBootTime
**GCIM is an alias for Get-CimInstance
So what does all of this mean? The first script will give you the last time your local computer booted up, and the second one does it for a remote computer. This is a great one liner(technically 2 for the remote as you need to create the CimSession) for you or your support team to make sure the user has really restarted their computer. Also a great way to check if a script you have that is supposed to reboot the device actually reboots it, and to not go any farther until the reboot has actually happened. I’d recommend having this one liner in your toolbox as well as creating a function out of it so that you can put parameter’s in place to make it even easier for your support team to use.
You also can see that I created a CimSession for the remote computer(s). This makes connecting to remote computers much easier and allow you to scale when needing information from CIM commands.
There is just so much information that you can get from the CimInstances and CimClass, that I can’t put here, but if you are looking for any thing related to hardware to a device check out these out. You can even see how much battery charge is left in a computer.
Get-CimInstance:
Microsoft Learn
Get-CimSession:
Microsoft Learn
CIM Classes:
Microsoft Learn
Leave a Reply