 Hello everybody, my name is John Hammond and welcome back from the YouTube video and man, it's been a while It's been a while since I posted a video It's been a while since I posted a power shell video and I have heard you I've read your letters You haven't sent me any letters, but I've read the comments and I know you guys were really wanting this So hopefully I'll be back at it back on the saddle and here we go This is power shell video number two. So we are gonna talk about output and some file system operations So without further ado, let's get to it. We know how to open up power shell You can simply open up your little start button there and search power shell. It'll fire right up for you So here we are at our prompt. We know the command. Let's now get child item and That will display the current directory listing or what's in our current directory And we know that's from our prompt visible where we are currently If we were to move with anything within that we are using an relative path If we use a period forward slash and anything that needs an absolute path includes the entire file structure C colon backslash or where we are from the root of what we're working with so Simple recap, right? That was the get child item command. We know that that is Aliased as something that power shell. Let's us do with the LS Kind of alias here and we've seen dir so LS if you're more Linux kind oriented dir for more old-school windows cmd.exe some DOS days and That's our output nice and easy super small We've done that before now we do want to learn how we're actually going to interact with the file system How we can do those copy file move file those regular things you would do in a GUI or in the file browser and explore So let's dive into that but before we do I want to chime in how we can actually Output some of this output in a different way the things that power shell lets us do so let's get started with that I will get child item again And we know through the pipeline that vertical bar just kind of the shift form of the backslash your keyboard Above the enter key that will allow you to transfer some of the C sharp net objects that we've seen as The result into that previous command into something else something new So I want to show you this kind of family of command let's Format hyphen and then whatever you want to format that output in so it's pretty simple It's pretty easy if you're to type format hyphen and I just figured this out I don't know if this is maybe my updated Version of windows to the power shell version I'm on right now But if you hit control spacebar, it'll show you some of the options of the things that you can actually use It'll help autocomplete what you're trying to work with it'll even show you a little bit of the help information What parameters or arguments you want to pass to it what you can pass to it and you can use your arrow keys Just kind of move around and navigate this little quick on the fly help system inside a power shell So by default the output that for that power shell will give you is format table So if I were to pipe this to format table, you see the exact same results we had earlier That's kind of boring and lame you can change I think how you Actually have power shell default to show you information, but the other options that we have are format wide and That will showcase some of the output and just kind of a tabulated way But now if the actual kind of headers the rows and columns there You can see it's just giving us the name of the entry not any of the other properties that we might like But if we wanted to see a lot more of the properties one cool thing we could use is format list And you can see that here of the other arguments that it might take maybe zooming on a specific property But format list works well for us because it will return each Entry each object that kind of our command that finds for us and give us a little bit more of the properties You can see link type and target and maybe we didn't see that by default when we ran get child item yeah, we didn't see The target and even it had a last right time kind of by default This will show us last access time and creation time and maybe some other interesting information This is a neat trick that I really want to show you because with format list You can actually get more properties that you may not have even known that that object might carry with it Let me show you this if you run get child item with format hyphen list and then add an asterisk at the end Suddenly you get a ton of information for each of those objects the attributes that might come with it I guess a parent directory a base name Everything that might be relative and pertinent to that object This is just kind of specific to this file system that we're looking at right now You can see that ps provider what we're really looking at But if we were to scroll through that we can see there's a lot of stuff that maybe you hadn't seen before So that's a good way to kind of track down some properties Maybe you hadn't seen before if you want to do a quick shorthand way to do that get child item The alias for format list is just FL and then FL star Here's all of the cool things you can do you can assume format wide is FW and that does that just as well And remember if you don't know any of these aliases you can check out get alias and That will return all the information for you funny thing the alias for a get alias is gal gl and Remember the power shell is case insensitive So it doesn't matter if you were to run get hyphen alias in all caps or whatever the case may be gay Al I don't know That's something that you can keep in the back of your mind power shell does not care about what Semantics you're using case sensitive case insensitive doesn't matter caps or lowercase So because we can use get alias and we can track down some of these Maybe commands that you might use in another language other language is not the right word But if you're on another operating system, you're kind of used to that old-school CMD.exe style or the linux style LS dir maybe some of those File system commands that you're used to or anything that you would just normally type in out of habit like echo like echo Literally just let's display some output on the screen echo The classic right we've just done that But what did echo come from you can gal echo just as an argument and you can see that that is alias to write output So if we were to simply write output It has the exact same effect because it's simply an alias kind of a recap on what we talked about in the last video but It helps me segue into a new topic and conversation because output is something that you can Control in the way that you're using and interacting with PowerShell right now We're working with PowerShell in just the console PowerShell.exe or this this program that we have open in the command line But how PowerShell is ran or invoked its host environment might differ We might get into PowerShell ISC as we will in later videos Or maybe it's running in a web browser because you've done it with some DLL magic output will allow us to kind of Change up what we're working with and how we can see things So let me actually dive into that if we were working with our alias output or our Python purist way Let's run get child item. We can pipe that to out And out is what we can use to kind of modify this and I'll use that control space bar to get some kind of Suggested auto completions for us. We could out host Just as we've seen before regular default output But it comes with some other things we can output if you want to get it as just a string Now we're not seeing the C sharp object anymore, but we're actually having them converted to a string Just regular kind of double quotes as you would expect in any of the programming language or more of a text-based console standard output standard input kind of the Linux way or This has other great stuff to us out null That's kind of like redirecting to forward slash dev forward slash null or kind of Squelching the output so you don't get to see it. That's might that might be handy for you later down the road Additionally, we have out file. So we've seen before and maybe some old-school Dostays or cmd.exe you can use the greater than symbol or the kind of redirection here. Let's call this Directory dot text right Now if I were to check that out, we've created a file directory dot text And we've just redirected that output or the command. Let's kind of results here Let's actually check out the information or the content inside of that Directory dot text I'll tap complete here and there is our output interestingly enough though It stored it when directory had no value to that's kind of a little funny Easter egg You can see the length of that file is zero at the time of Kind of reading the file, but if you actually check out on the file system It's filled with the contents of that file. So interesting thing. Maybe maybe you'll get a kick out of that. I did anyway So that's using the regular old-school redirection powershell lets you do that just as easily With piping it to out hyphen file and you will of course need to supply a parameter, right that path following it So let's call it again directory dot text Check out what we're working with and it's the exact same file size. It's the exact same file So we can open it up in notepad directory dot text and you'll notice we have still the headers And everything that we would have expected in a regular powershell output Because it's format table if we wanted to see format list or format wide We could use just that or select to move kind of our properties out as needed Those are other things you could do with it But those are the ways you can format your results in powershell and how you can output to some of them Before I kind of close off on that I do want to show you out grid view because you guys might like this that might come in handy This will give you kind of a quick GUI interface where you can actually scroll through some of the things that you're working with Click on them and do interesting things with them or if you had a ton of results That were just taken up a lot of space you have a little filter up here where you can search for things Like okay, I only want the entries that contain the letter o or whatever the case may be or a or Anything that you might like you can especially add criteria for some of these properties And you can verify whether or not they contain something or do not contain or start with or equal something And that will help you kind of narrow down your results if you have a huge data set that you're working with So that's out grid view. I think that's kind of handy Okay, we talked about right host We talked about how we can output into a file or a grid view or any of those other out Solutions and formatting them in a different way. Now, let's work with that directory dot text file that we've created so If you are again more Linux minded kind of like myself, you're used to the move command and the Power shell calls that move item And if you didn't know that again because you're used to that kind of structure and syntax You could just check out that alias gal mv and you'll see it tells you that is in fact move item Same thing with cp to copy right check out the alias for cp that command is copy item So if we wanted to kind of move this item Of the directory dot text we can bring it into our desktop Just simply running that command has the effect if I were to minimize you can see my directory dot text is just there Get power shell back open Run ls or get child item. You can see obviously it's not in this director anymore But we'll use our relative path dot forward slash or dot backslash Check it out. Now it's in our desktop because we just moved that if we wanted to copy item Super simple, right? Let's take a directory and again using a relative path the symbols two periods for the parent directory Let's just move it up in the file system Now if I were to move back I can ls and I have a copy of that directory dot text right there If I didn't want that file anymore, though Maybe you're used to the rm command if you're linux minded or you're used to the dell command if you're windows minded You can run remove hyphen item in that power shell pure way. Let's run remove item on directory dot text And now that's gone. We don't have that entry anymore. We don't have that file Some of these directories that windows likes to put here kind of by default I think are stupid and I never really use so we could remove some of those if we wanted to and you might be used to rm dir In power shell there is no difference between a directory that we're trying to remove or a file that we're trying to remove It all just calls it an item. So we can simply Remove item What is that one called save games? Let's do that This might ask us. Hey That actually has some contents inside of that There are files in folders that are inside of that directory or that item that we're working with Are you sure you want to remove all of it and you can supply? Yes, or enter y and work with it or any of these other options that power shell will give to you If you wanted to figure out, how can I just get it to shut up? Like stop asking me that check out the help for it It'll show you the aliases that we're working with And i'll try and scroll up here One of these options is tat confirm where it says, I don't care Do it do it all and same thing with tack recurse and tack force if it says like hey, we're not able to do this Whatever just ignore it We can try some of those out. So let's remove item tack confirm Oh, we still need to work through it. Okay. Let's just use recurse instead Oh, can't use some of those. I guess i'm not the administrator I'm not able to remove some of the sensitive i and i files whatever Again, that is the commandlet that we're using though remove hyphen item. That'll take the place of rm dl and rm dir So those are the commandlets that I wanted to show to you in this video Again, super simple stuff. We're just kind of navigating around the file system We're checking out how we can output and format our information within power shell Next we'll move on to some of the good stuff. We'll get into scripting We're getting the profiles variables execution policy stuff like that But we got to get this beginning stuff out of the way. So thank you guys for watching I hope you enjoyed this if you did please do like comment and subscribe There is a discord server that you can hang out and all of us are trying to learn trying to get better Just jump into the cyber security scene. Please do click that link join the discord server It's a great community so many smart people and they're much smarter than me So, uh, I'd like to see you guys in the next video. Let's see you on patreon. Let's see you on paypal All the other things. I'm really bad at outros. Thanks for watching You