Windows PowerShell [01] Introduction

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody my name is John Hammond and in this video I wanted to do something new but not entirely new kind of wanted to go back to the channels roots where I do a longer video series on one specific kind of technology or programming language and it's a tutorial series and learning thing rather than just a capture-the-flag video right up like I've kind of doing lately so this video I want to kick start the Windows PowerShell video series tutorial I'm really excited about it but before we get started I wanted to talk to you guys about circle CI so you've probably heard the terms continuous integration continuous delivery and continuous deployment and that is what circle CI is all about circle CI offers an awesome platform that lets you automate your development of any software code and projects that you're working on in a managed safe and tested environment they're working with some big players they have facebook spotify GoPro listed here and I'm sure there are plenty others and they offer a free trial version if you're interested in it you can check out the cloud implementation or the server implementation and they are all about helping you develop the next best thing one thing that I especially wanted to mention was that they offer support for Windows they have incredible documentation and they offer some fantastic stuff everything that they test within the CI pipeline is working on a virtual machine so it guarantees you have isolation of what you're working with it's using server core of Windows Server 2000 19 the latest stuff and they're using PowerShell that's the default shell but you can obviously customize that to bash and old-school cmd.exe offers a little bit of integration with docker and it's just awesome the syntax is in a super simple yamo configuration file and it could not be easier to test and develop your software within a CI CD pipeline if that all sounds awesome to you and I know it does please go check them out on their website circle CI comm take a look through that documentation and see how easy it is to set up this pipeline and give them a shout let me know that jon hamm and send you they're gonna make your development process so much easier ok so let's dive into some PowerShell I am working in a flat vanilla Windows 10 image I just updated it to the 1903 update and I need to put forth my usual disclaimer that I do at most of my videos in that I am not by any means of professional I'm not a Microsoft MVP by any stretch of the imagination so if I ever miss speak or if I have released some information to you that it's wrong and some of you guys are veterans and rockstars and totally No whoa John you must up on that let me know please say the word constructive criticism in the comments we're all here to learn and that's what I'm all about so please do just let me know hey John you're being an idiot but let's get started this is going to be an introductory video it's meant to be an introduction video so it's gonna be some light lifting what I first want to cover is just for one thing opening up our shell so I hit the start button or just the windows key in my keyboard I'm kind of a keyboard guy I'd like to be on the command line so I would just type in PowerShell or in that search bar there and you'll see it pops up okay Windows PowerShell is the app we can work through there are a couple others listed though you have Windows PowerShell ISE which is there I don't know that acronym integrated something environment software engineering it's a text editors not the right word but it's an IDE normally that integrated development environment for creating PowerShell code and PowerShell scripts we're gonna get into a lot more PowerShell scripts later on in the series for now just baby stuff trying to get our feet wet you also see Windows PowerShell with that parentheses x86 so what is that that's that 32 bit rendition of Windows PowerShell doesn't really matter which one we start the 64-bit one is just normally what we'll be working with just that we're running a 64-bit PC very very likely and of course they have that 32-bit version of ISE you can just click on that or hit enter to go ahead and start it up to note sometimes we're going to be doing some things later on the series hopefully we'll be working with commands it will need administrator privileges so if you ever want to open up PowerShell with administrator privileges you could obviously just right-click on that and hit run as administrator what I like to do personally is just CMD or PowerShell that's what this video series is on and I just hit control shift enter on my keyboard and that will go ahead and ask me with administrator privileges do you want to run this so there we go Windows PowerShell starts up and we are rock with the administrator PowerShell note that it puts us in windows system32 as our path if I were to open that up and simply my user account it puts me in once it gets there see users John so that's my user profile or kind of my home directory equivalent in the Linux world and that's the prompt right that's just what's going to tell us that we are in a directory if you ever want to change directory you can move with that CD command we've seen in every other system shell between bash or cmd.exe etc etc you can CD to period which is that symbol for the current directory so see our path had not changed if I were to CD pure a period that'll move us up a directory that means our parent directory so now we're in C users if I were to run a command like dir what you would normally expect in the cmd.exe world you'll note that ok here's a directory listing of the current directory that we're in so I can see John is an option there that's that folder I was just in and we can see D all the way to that and using that as a relative path that means from the directory I'm currently in we can move to the directory that is next to us or in the same folder and tree that we're in isolate into John and that works just fine for us and that was a relative path if I wanted to use an absolute path or going from the very very root of the file system or any drive that I'm working with you could specify all of the paths subsequent so I'd say CD C colon backslash users and I'll just go straight there and that's the absolute path rather than going up with the two periods using a relative path so that's that easy simple navigation around the PowerShell command line right you guys know the CD command but you'll notice that I ran the dir command and some of you PowerShell purists might already be angry at me because the dir command in PowerShell is not so much a command and me even saying the words command when I'm discussing PowerShell is already inherently wrong so power show refers to everything that you end up typing at the prompt as a command let so if I were to say something wrong like please subscribe cool yeah power show we'll try and track that down but suddenly it'll get angry at me it'll get that black background in red text my screen gets bloody PowerShell yells at me that says please subscribe is not recognized as the name of a command --let and that's what PowerShell refers to everything that's going to be working with ass nor is it a function or a script file or operable program check a name maybe you had just a stupid command you you mistyped something obviously that's not something we can run please subscribe is not unfortunately unfortunately not something we can just type into power channel no to do things automatically it's not a command ilat and that's what PowerShell wants to get across is that everything that you type in let prompt should be a command lit and commandlets in PowerShell normally have the syntax verb - now normally there are two words or three words it depends on the lengths get commands let's command let's get more and more complicated or you're doing more advanced stuff maybe there's more to what that syntax and looks like but generally you can base the look of a command based off of that verb noun structure verb - noun and they like to use the kind of camelcase structure however PowerShell is case insensitive it does not matter if you type in a command lit with random capitalization or that expected kind of camelcase of notation there so I'm using ctrl L by the way to clear my screen CLS works just as fine just as well clear might also do it yep and the reason that CLS and clear work the same way and the same way that dir works just as easily LS also works if you are kind of more of a UNIX or Linux guy but those aren't the commandlets that I was just talking about the command mode that we're looking at or what we're actually running when we run dir or LS is actually get - child item and that will list out the children of the current directory right but commands like dir or these the syntax here like dir and LS those are actually aliases for that get child item command line so if you want to see Wow okay there it's an alias right it's a nickname it's convenient shorthand thing if you're more used to being a Linux guy working with bash you just type in LS or are a more move and those commands are different from the usual cmd.exe copy or move or dl stuff like that if you want to see those aliases you can type in the command let get alias and that lists out a bunch of stuff right we could go through this we can take a look and there is a lot of information that's returned to us see all of these kind of nicknames for commands CLS is in there just as we saw cat might be used to that in the Linux world CP copy just as I was talking about and those all refer to copy item as the real commandment that you're running there but those are just aliases that you're running now notice that the output of these commandlets is kind of in a interesting format where they have are kind of formatted like a table or they're given kind of a header here with a piece of information that might vary for each thing that's returned to us the same thing that we saw when we ran dir or LS again I should be running the full get child item commandlets that's more PowerShell pure I am kind of inherently a Linux guy though as you've seen probably see from other videos so if I end up typing those LS or cat and said please don't get angry at me I know I should be using the PowerShell side but that habit will grow hopefully the same way yours will as we do more of this so I was just talking about though these kind of headers or the information title for each of the entries that's returned from us or returned to us when we've run a command lit so what are those things well this is where I wanted to talk about kind of the fundamental shift and what happens when you're using PowerShell versus bash or c nbthce or c shell or k shell or any other any other system show that you're probably used to powershell works with the input and output that's like coming out on the screen not in the normal text base stream orientation you know on linux you have standard output standard input and you can pipe and redirect those as you would normally in cmd.exe powershell turns that on its head we're no longer working with just plain text but we're working with objects we're working with C sharp and dotnet framework kind of the back end of Windows objects each of these is returned to us as some specific thing so when they go down the pipeline or when we're working in PowerShell and we're passing objects from one command to another as you would normally in a pipe and in Linux or in bash your piping objects into each other so let's let's try that let's let's see if we were to run get child item here are our things right here are the current directories and the user's folder and let's say I were to pipe that and pipe is that vertical bar right it's kind of above your Enter key the shift rotation the shift rendition of the backslash key and we can pipe it to something else we can pipe it to let's say select I'm select object I think is the actual full title name right so select object doesn't look like it did anything to our output it didn't really specify anything at all that's because select argument excuse me select object needs another argument or some other representation of what to do with the data or some configuration tweak as to how that programmer Commandments going to operate so the way that we can do that is by supplying an argument an argument is meant to be the information and data that follows a command or command let the command that's the very very first thing you type in here get child item or select object because we're piping them they look like they're kind of put together but they are in fact different analysts or commands the arguments or the parameters and I'll say those words often interchangeably are the things that you supply after they are separated and tokenized by a different space that separates them apart so let's say I wanted to select the object name and that will return just John or public as that is the name of what I'm actually receiving here now that's something that we supplied to select object name as so that's what we're focusing on that's what we want to filter and zoom in on but we can actually supply more information to select object I'll clear the screen here let's say we wanted to select - first one now that makes sense right I'm selecting the first object and I'm able to do that because of that - first and that's a parameter an argument that I'm supplying a new value for first one and once I hit enter now all I see is John public isn't there anymore you could do that very very same thing with like last or you could index and when you index it's zero based so index zero actually refers to the very first entry John in this case and if we wanted to zoom in on that we can keep piping more and more to grab a specific property out that we wanted we can select object name and just get John returned to us note here that PowerShell is still going to give us that kind of header oh sorry Ubuntu in my virtual machine it's kind of getting in the way there so we can drill down and figure out more and more properties or information regarding that object if you wanted to get more regarding that you could actually check out get member pipe it what you're working with pipe the objects that you're working within to get member and you can see more information as to what that object actually entails talks about properties which are like variables that for that object or methods which are like functions that that object can perform right like delete if we wanted to end up deleting that okay that's getting really annoying sorry you could get file if you want to see okay there's a new files in there or move things to them or just convert that to a string etcetera etcetera and you can see okay these are the arguments that that method or property might expect or what kind of type that property or variable is is it a boolean value is this string is it just text or stuff like that PowerShell is really really awesome about giving you kinds of types or structures for information like if you want to have an IP address there's a PowerShell property and format for an IP address you don't have to try and Cluj that together with your own regular expressions validation PowerShell will do that all for you and we'll play with that in the future for now I just wanted to get these ideas across and that you can explore an object more and more and get more information out of it that you wouldn't have seen before so we didn't see a root or parent displayed in that regular output when we just simply wanted to grab the first item here grab first one you don't see root or parent in there but if we wanted to select that select object parent then it will return it to us note that select is the alias or shorthand notion for select object so you can just use that if it's a little bit easier to type and quicker for you but when we're returning that information we're returning that in a very power shell like way there's a different way to do that if you kind of just got the object that you want to work with here let's say we got just this directory because we're selecting the first one in our current directory listing what we can do is actually encapsulate that in parentheses here an opening parenthesis at the very start and a closing parenthesis at the very end that will just say now I'm going to make this object as something that I can work with so we can run those methods or access those properties and kind of a more programming like way that you're used to maybe it more like a c-sharp style or syntax rather than the powershell pipeline we could if we wanted to write dot name and we'll retrieve just that property just that string here remember if we were using that with select name it gives us that PowerShell header and maybe that's not the output that you want if you're trying to avoid that one option one way you could go about that is just using that kind of c-sharp style by wrapping the object that you're working with in parentheses and then using a dot selector to work with things or you could do methods right you could try and run some of those things that we saw in get member get member is fantastic get member is awesome because I'll let you explore and track down some of the properties or variables or values or information that you're really looking for I think a lot of using powershell is a very exploratory action because you're just kind of discovering where in this web of windows stuff can I find the information I'm actually looking for that might be how you play and get to know PowerShell a little bit more so that is what I can think of for everything that I want to talk to you about and show you in this video we talked about what aliases are we talked about what a command or command late-- and arguments and parameters are and we took a look at what the get member command that would do for us lets us explore an object but before I go actually I thought of it now I want to show you how we can get help or learn a little bit more about a specific command line if I were to run get help on select object that will give us some more information as to what we can do with this it's like the man paid for PowerShell right the manual this is what we're actually working with here's the command look there and it shows you some arguments of parameters you could pass through it just as I talked about last or first or others here and we'll explore these more in depth but for now I just want to show you basically what get help can do for you because it will give you even examples if you wanted to get more information this is a shot in the dark here but let's run get help on get help okay yep cool it will tell us how we can get help you could actually ask for more information by using stuff like - full let's say let's get the full help on that select object command lit it tells us what it outputs what it inputs it even shows us more information on what all of these parameters do and it could give us examples in some cases if you don't know the name of the command lit that you're looking for or what you particularly want to be investigating or how you want to work with stuff you can try and get help on things like printer and you can separate these by stars or the asterisks because it'll act of like a wild card write anything surrounding the word printer on either end or if we were to add one only in star or asterisk at the very very end it says everything that starts with the word printer let's try with the asterisks around there that will show case these are all the commandlets that you could use maybe you wanted to run set printer or get printer or rename or add printer etc or you could do that with stuff like networking right get help on network and then you can grab more information by finding those different commandlets also PowerShell has a get command to command lit that will show you everything that you could potentially do within PowerShell and if you want to search or filter through that you absolutely could if you wanted to say get command on printer with those asterisks and stars around it to track stuff down so that's how you could navigate or explore or poke around in PowerShell we'll do more of that in the coming videos but I want to get this introductory stuff out first I want to get lay the foundation and kind of start tilling the ground for what we'll be doing in the later videos so thank you guys for watching I really really hope you enjoyed this I'm super excited about this series I hope it'll be a lot of fun I hope it'll be much higher quality than anything I've done before so please let me know leave a like comment on the video hit that subscribe button the bell thing I don't even know what it does it doesn't do anything join the discord server there's a lot of incredible people there shout out to all of you guys I cannot thank you enough for all the support that you give me and I'll see you in the next video [Music] [Music]
Info
Channel: John Hammond
Views: 330,665
Rating: undefined out of 5
Keywords: windows, powershell, microsoft, powershell scripting, cmd.exe, dos, cmdlet, powerup, powerview, empire, hacking with powershell, windows security, hardening windows, programming, stigs, emet, introduction, powershell basics, john hammond, hammond, cyber security, computer science, learn powershell, tutorial, powershell tutorials, powershell for beginners
Id: TUNNmVeyjW0
Channel Id: undefined
Length: 22min 42sec (1362 seconds)
Published: Fri Aug 30 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.