PowerShell Quick Tips : Get-CimInstance

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi and welcome to a Powershell quick tip video it's been a while since we've done one of these so I figured we would make another one and today we are going to be looking at the commandlet of get SIM instance now there are some situations where in Powershell 5.1 you would have to use get SIM instance in Powershell 6 and Powershell 7 they have created other commandlets now that make some of the uses that we used to use get SIM instance not useful anymore but there are still a bunch of other informations that you can get from SIM instance I'll be going over the one that we used to use it all the time for I'll show you the replacement but I'll show you the benefits of the get SIM instance and then we'll go through a couple other use cases of get them instance so really what that commandlet is used for is to get information from your local computer or you can actually use it remotely as well it does come with a computer name parameter so you can actually execute this on remote computers so if you have a large organization or even a medium organization and you need to grab tons of information off of some computers that you don't actually have physical access to it is a great commandlet to be able to use so let's actually go ahead and let's get started here we are going to do a get Dash Sim instance and then the primary use of this is going to be with the class name parameter now when you actually go in here you will actually get a bunch of different class names here there are hundreds and hundreds of these uh the first one that we're going to be starting off with is just going to be when 32 underscore operating system so if we actually just run this as it is right now we basically get a system directory the organization build number registered user serial number and the version but we can actually get more information if we actually pipe this to a select Dash object or just select and then a star we will actually get tons of more information so we can actually get the windows directory the system Drive the systems directory uh the serial number registered user as we've seen earlier we can actually get the languages the manufacturer which is going to be Microsoft because it's windows um we can see the encryption level there is a build number the version number um we'll also see the virtual memory size and the visible memory size we also get this is where it used to be very useful we also get the local date time and the last boot up time so this is how we used to figure out how long a computer was on for I'm going to show you the rest of the script of how to figure out how long the computer was on for but as we can see here the last boot up time for the computer is uh January 10 2023 and right now as you can see in the local date time it is 2023 uh 1 21 so it is January 21st um so that is all good there so we will actually see how long the computer has been on for we can also see when it was actually installed or configured here so we can actually see it was configured on September 3rd of 2022 so that is also very very useful information um and then yeah so that's pretty much all you really need to know with get SIM instance now we're going to be looking at some other uh classes because that is really where the command link gets different but just to let you guys know for the boot up time if you have Powershell 6 or Powershell seven uh you can actually use get uptime and it will tell you the exact amount of time that this computer has been up for so as we can see here it's been up for 10 days and 16 hours we will actually get this response just from using get SIM instance but if you do have Powershell 6 or 7 available to you on the computers you can use get uptime but you only get the uptime you don't get any of the other info that you would get from get SIM instance so Sim instance definitely still has its place in Powershell so let's go ahead and let's get the last boot up time here so what I would do is I would just create a variable called last boot time and I would just make that equal to our get SIM instance operating system win32 and then we would just do a DOT last boot up time and that should give me the last boot up time and it does perfect so once we actually put that in there if we just create another variable called uptime we make that equal to get dates and actually we're going to wrap get date a variable wrapper you could also just wrap it in parentheses but we're just going to do it that way and we're going to do minus last boot time so if we actually run these here our uptime is equal to 10 10 days and 16 hours and now it's two minutes uh so it works just as well as the get up time it is a little bit of extra steps but if you do want to capture maybe at the same time what is the local time on that computer who is it registered to what version of Windows it's at the operating system version of sim instance is going to give you a bunch more information compared to get uptime now another thing that we can actually do as well is we can actually check uh battery statuses with the get SIM instance so if we do get Sim instance we do the class name we do win 32 underscore and we have a win 32 underscore battery so we actually just look at that here and we just run that it gives us right away the estimated charge remaining is 94. if we actually look at this computer right now you guys actually don't actually see it um so let me actually just see if I could pull this up here because it is actually behind my camera on the screen I don't know if we will be able to see what the percentage is at um but the percentage of my battery right now is actually right here it is actually 94 so we actually see estimated charge remaining is 94. that's actually perfect um so it does give you a bunch of information it'll give you the battery status which is actually two because my computer is actually plugged in right now it'll give you that it's using an internal battery it'll give you some details on that battery and actually just to show you guys so as you can see right now the battery status is two because it's charging if I actually unplug the computer here and we run it again we will actually see that the battery status is one and that is actually unplugged and using battery so if we actually just let it this way we would actually eventually see that the estimated charge remaining would actually go down um and that would actually update now the estimated run time is quite off right now because I usually leave this plugged in so it's actually been estimating the run time for quite a bit um but that is the just of the battery now you can actually even see if you wanted to see who was actually logged into the computer you can actually do a get SIM instance class name and then we could do a win32 logged on user and if we look at that here we can actually see that we can actually see the the name is Jack programmer the domain is a local computer because this computer is not part of a domain uh so again with all of these uh commandlets because they are all using get SIM instance we're just using a different class name you can actually use a computer name in here and run this remotely uh you can also use the PS sessions and run them remotely but I would just say use the parameter for computer name put the computer name in there and get that info that way and if you need to grab maybe you want to check the status on all the batteries on your computers if they're all laptops maybe you want to make sure that who's logged onto the computer is actually who the computer belongs to if you actually store that information somewhere in your inventory system you can actually do that as well to make sure that laptops aren't being exchanged or computers aren't being exchanged between people so there are a lot a lot of options and just to show you guys how many other class names there are so if we do a get stem instance here and we do a class name we can actually see just in the win 32 options there are a bunch of different options here so you can see anything related to disks operating system there's tons of performance data as well there is Network information there is a lot a lot of information there is bios information you can get stuff on specific Hardware as we've seen it with the battery you can get physical memory so there are a lot a lot of resources to you to use there are tons of resources online as well that if you're looking for something specific you could probably find a class for it to use was get SIM instance but I did want to show you guys this command link because I think it is quite useful and a lot of people don't necessarily know about it or know about it because they've used it once or twice but then I'll often forget about it I still often forget about it sometime as well in some scenarios so I hope you guys liked this quick tip if you guys have a commandlet that you guys would like a little explanation on or a little bit of a deep dive on please let me know in the comment section I will do my best to do all of them for you guys because I finally there is a lot of different command lists that are super useful and sometimes we just don't know that they necessarily exist so it is a very useful thing even for me uh maybe you guys have some command list that you guys want to learn and I don't even know them and I will go and I will learn those commandlets and make a video for you guys if you guys want to please hit that subscribe button hit that like button also hit that notification Bell to be notified when that next video comes out and I will see you guys on the next video
Info
Channel: JackedProgrammer
Views: 2,517
Rating: undefined out of 5
Keywords: powershell basics, powershell, windows powershell, programming, scripting, powershell scripting, powershell scripting tutorial, powershell tutorial, how to, powershell api responses, powershell automation, powershell beginners, powershell variables, quick tips powershell, quick tips, learn powershell, powershell for beginners, powershell commands for beginners, shortcut, powershell registry, registry, get-ciminstance, get-ciminstance win32_battery
Id: 2SrmpcT3e74
Channel Id: undefined
Length: 11min 31sec (691 seconds)
Published: Thu Feb 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.