• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Clatent

Technology | Fitness | Food

  • About
  • Resources
  • Contact

Cim

One-Liner Wednesday November 30, 2022

November 30, 2022 by ClaytonT Leave a Comment

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

Tagged With: Cim, One Liner Wednesday, PowerShell, Remote

Primary Sidebar

Clayton Tyger

Tech enthusiast dad who has lost 100lbs and now sometimes has crazy running/biking ideas. Read More…

Find Me On

  • Email
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter

Recent Posts

  • New version of EntraFIDOFinder is out now
  • EntraFIDOFinder now with over 50 new keys!
  • EntraFIDOFinder March Update
  • 02-14-2025 MSOnline and AzureAD PowerShell modules.. One last Valentine’s day card each
  • Custom Maester Tests: Validate Full Addresses Now and Cleaned Up Wording

Categories

  • 365
  • Active Directory
  • AI
  • AzureAD
  • BlueSky
  • Cim
  • Dashboards
  • Documentation
  • Entra
  • Get-WMI
  • Learning
  • Module Monday
  • Nutanix
  • One Liner Wednesday
  • Passwords
  • PDF
  • PowerShell
  • Read-Only Friday
  • Reporting
  • Security
  • Windows
  • WSUS

© 2025 Clatent