PowerShell Quick Tips : Out-GridView

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi and welcome to another Powershell quick tip in this quick tip we're going to be taking a look at the commandlet for out grid View outgrid view is a great commandlet if you just want to Output your data that you have imported or you've queried it in a nice kind of formatted screen compared to just outputting it to the console and having it to scroll through it with out grid view you can actually apply filters directly to the grid View and quickly sort through your data and find the information that you're looking for this could be especially useful if you have large CSV files or large XML files or large Json files or if you just have like a large data set like maybe get processed or get service and you want to find out something really quickly so let's actually go ahead and let's get started let's take a look at the out grid View commandlet so let's actually just start with the out grade view commandlet on something like a get process so if we actually just run the get process commandlet right now on this computer we see that we do get the output to our console it is like very easy to kind of process we can obviously also pipe this as we've seen before where process name is like uh let's find anything that's like code and then we have all the all the processes that are like code and we can even do aware object instead of where and that would just be the proper way but let's say you don't really know the name of the attribute you don't really want to spend that time what we can do instead of outputting it to where object you can actually output that to out Dash grid View and you can even give it a title as well so here let's just give it a title of processes on my computer if we actually run this here and we actually have the title here processes on my computer and we can actually see all the processes here so we can actually add criterias here where we can actually select process name and we can add and process name contains we can actually just put code and there it gives us our filter or even if we wanted to just let this filter above here we can actually type code in here it'll give us the same result so this just makes it very very easy to see um all your data you can sort it by simply clicking on the cut uh column title so it's a lot easier a lot more probably similar to how you would view data in Excel on a non-excel formatted data really and then what we can even do is we have our CSV file we have a Json file we have an XML file here so let's actually just create a variable here for all the different file paths that we have and uh let's see what we can do um with just importing the different data sets so let's create a variable for Json XML and CSV and we are just going to link it to the file paths accordingly so let me just copy all of these paths here I will be covering the exact details of the CSV Json and XML I do have those videos currently up right now on the intermediate tutorial Series so if you guys do want a deeper dive on CSV files Json files and XML files I would highly recommend to go check that out but let's actually just go ahead and let's start off with the simplest one here which is going to be the CSV file so let's go ahead and let's actually just store our data in CSV data and what we're going to do is we're going to do an import Dash CSV and then we're going to do the path it's going to be our CSV file path and our delimiter is going to be a comma and then all we want to do here is take csb data and pipe that out to out Dash grid View all right and let's just run these three lines here and our window pops up and notice because we didn't give it a title this time the title of the window by default is just the line that actually gets outputted to outgrid view including the outgrade view so here we have dollar sign CSV data piped to out grid View and there we have our data here so if we wanted to find out let's say we all want our employees from Canada foreign we can type in Canada and there they are if we want all of them from the states or United States but either way it uh United works and you can always again specify more like country and contains United so there are a lot of options that you can do again you can sort them by alphabetical order now if this was a large CSE file this is where you could see that benefit compared to just looking at the data plainly in the console it's a lot more it's a lot more playable you can click through it you can sort it easily you can search for the data I find a lot easier might be a lot easier for other people that aren't used to working with Powershell to see the data so this could even be something as we've seen before and in other videos how to make exes you can easily do that as well you can actually also just make shortcuts that will call the Powershell and then output it to out grid View and then all you would have to do is add the weight parameter and that will keep the Powershell window up um so that could also be something pretty cool um we will actually be seeing that at the end of this video but let's keep going with the Json file so with our Json file just to kind of go over Json files a little bit here um my Json file format there is a top level object called employees and all of our employees are stored in that so we will have to do a DOT notation so let's go ahead and let's create a variable type Json data and let's do our get content here and our path is going to be Json file path and we're just going to pipe that to convert from Json and then let's do Json data dot employees and let's pipe that out to out grid View and let's actually give it a title here and we're going to give that a title of Json data you all right and let's run these couple lines here for the Json data and there we have it we have our Json data View Title and we have our ability to sort through the different titles the different date of births the last name first names employees so we can easily search let's say who was born in 1987 and we have our employees that come up here with the date of births of course if they had the employee ID of 1987 they would all also appear unless you did a date of birth contains 1987 here empty that out then you would only have the date of births that contained 1987. so that is the Json view now of course we can do the exact same thing with XML and XML once again uh in here we actually have an employee's object and then we have employee objects as well so we have to do a little something extra here so as we know to import XML data we actually have to add our square brackets XML to add that data type and let's do XML data we're going to make that equal to get content from the path of XML file path and then let's do XML data Dot employees dot employee and we are going to pipe that out to out grid View and let's run these few lines and there we have our XML data again with all of our information in there once again we could still sort the exact same way and view that data very very easily now of course what we did here as an example I'm just going to use the CSV file as an example is we actually stored it into a variable but you actually don't even need to do that you can actually do an import Dash CSV uh csb file path delimiter let's put our delimiter here comma and we can output that directly to out grid View and we don't even need to store into a variable we can output that data right away so that is very very handy you can easily use that for exploring your date different datas in Powershell if you don't want to look through the console look through all that information as well so let's actually see how we can actually also create a shortcut on the computer let's say to give to an employee or co-worker a manager that might not necessarily be comfortable using Powershell but they could use the data very easily for them so let's actually go ahead and let's do short more show more options here and let's do a new shortcut and what we're going to do is the location of the item is we are going to go ahead and believe we should just be able to do Powershell so pwsh for Powershell seven it's actually going to be Powershell all typed out here and let's do a dash command and let's do a pair of double quotes here and it's going to be a get process we're going to pipe that to out grid View and then Dash wait let's go next and there we have it so if we double click on it there it is it runs our Powershell script that we have for get process and if we close the out grid view it automatically closes that Powershell window so as an example here let's go back into properties so as you can see it's running Powershell it's getting the get process and we have outputted it to with a dash weight if you do not put this Dash weight here this is what happens it'll open and it'll close right away so that's kind of where I mentioned a little bit earlier if you're wanting to create a shortcut always add that Dash weight at the end and that'll actually get it really nicely so what you could actually do with this possibility of just quickly getting data out and being very visible without grid view they could easily sort it and get that information if you created yourself some rest PS using some other videos um or if they have active directory tools installed you can easily set them up with shortcuts to get all the employees in the company or something and then they can easily filter it with that easy filter bar at the top or with selecting the different filters in Elk grid view outgrid view is very very good for people that aren't really used to playing with Powershell aren't really used to doing the pipe wear or pipe sorts oh grid view is very very useful I'm probably more useful in forms of shortcuts or automated scripts that you can just go ahead and give to people and they can run and look through the data more so than creating it for yourself you wouldn't want this in an automated script because again it gives something to the user to actually interact with but if you're handing it to people that again aren't used to Powershell or just want something quick and easy to use outgrid view is a great commandant to use hopefully you guys find a use for it in your scenarios as well hopefully you guys enjoyed this video if you guys have any other command list that you guys want me to cover please let me know down in the comment section down below please be sure to subscribe hit that like button and 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: 1,750
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, out-gridview, powershell interact with data, data, view data, data view, powershell out-gridview, shortcut
Id: Xm6b-OS1ISk
Channel Id: undefined
Length: 13min 48sec (828 seconds)
Published: Thu Dec 08 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.