Windows Powershell vs Command Prompt: What's The Difference Anyway?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
windows command prompt and blue command prompt also known as powershell what are the differences that's the point of this video they're both the same idea but powershell is just more advanced and that's the end of the video just kidding of course the video can't be that short because youtube would kill the video algorithmically so we're going to obviously get a little bit more detail into this and understand why you might want to use powershell over command prompt should you even bother learning powershell there are a lot of advantages to it actually and it is way more powerful so that's what we are going to go over this video so first let's actually just take a look at what microsoft itself says is the difference between the two and they say windows has two command shells the command shell which is command prompt cmd whatever you want to call it and powershell each shell is a software program that provides direct communication between you and the operating system or application providing an environment to automate it operations it also says powershell was designed to extend the capabilities of the command shell to run powershell commands called cmdlets cmdlitz i believe it's also commandlets are similar to windows commands but provide a more extensible scripting language you can run windows commands and powershell commandlets in powershell but the command shell can only run windows commands and not powershell commandlets now don't worry if you don't understand a lot of that you don't know what the heck i'm talking about with commandlets i'm going to get into that a little bit later and make it easy to understand but basically the only thing to understand at this point is that powershell is able to do pretty much everything the command prompt can do it can do pretty much all the same exact commands that you're used to but it can do more so really if you're familiar with both then there's really no reason to not just use powershell for everything because it can do everything with the same commands as cmd can but of course if you're only familiar with command prompt then you're not going to be using anything in powershell may be worth it to learn some powershell commands and then just use that for everything another very important thing you need to know is that powershell does not just refer to the powershell program that you run in windows it actually refers to an actual entire scripting programming language also called powershell whereas the command prompt pretty much just exists as a legacy environment for old dos commands just for backwards compatibility it's kind of there just because people used it and we're familiar with it but command prompt is extremely limited you see with the command prompt you type in a command it runs the command that's pretty much all there is to it whereas with powershell because it's an entire language and the powershell program supports the powershell scripting language you can actually do a bunch of the different commands and stuff that you would use with a programming language right in the powershell window so you for example could set variables create a function do all this right through the powershell window which with is not something you can do with command prompt you just basically type in commands in the command prompt whereas with powershell you could do all sorts of different weird stuff and just right through that window now i mentioned before that powershell is more powerful than command prompt but what do i mean by that so both command prompt and powershell are capable of controlling aspects of the operating system changing settings that sort of thing but powershell can do just way more settings than command prompt and like i said because command prompt is just a legacy environment powershell is what microsoft has been working on basically since windows 7 as the main command shell to be used for everything so anytime they add a new setting that they want to be changed by a command shell it's obviously going to be used in powershell so it can do way more whereas command prompt just gets more outdated by the day now both command prompt and powershell have just basic commands like showing a directory dir or something like that or changing directory super basic stuff for interacting with the shell deleting files but the difference is powershell also has these commandlets which are more advanced functions created by microsoft and then put in natively into powershell and it might seem intimidating at first because the commands in powershell the native ones at least are all different from command prompt but that's not exactly the case because they basically created these aliases which make the old commands do the same thing as the new commands we'll get into all that in a second but let's get to the commands in powershell so you understand what's going on so all the commands in powershell from my understanding have a certain structure so it's a verb noun structure so you'd say for example set dash location it's a verb and then a noun and all the commands are going to look like this however that doesn't necessarily mean that if you're already familiar with command prompt or even the linux bash that you have to learn all of these new commands and memorize them all just to be able to use powershell because of what are called aliases and that's basically just a link that says okay if someone types in cd for example the change directory and command prompt that is going to link to the set location command in powershell and it'll do the exact same thing so pretty much all of the old command prompt commands do the exact same thing in powershell you don't have to learn the new powershell command at all and another really important thing to remember is a lot of these command prompt commands you're probably familiar with already and are worried about being all different in powershell they might not even be commands at all because a lot of them are not commands but rather programs in the system 32 folder in windows for example when you run the ping command it's not exactly a command you're actually running ping.exe that's in the system 32 folder i know mind blown the same goes for other common programs like check disk disk part ipconfig and more these are all actual exe programs in the system 32 folder that you're running they're not just exclusive commands to command prompt so if you type these commands into the powershell it'll do the same exact thing and you can even see this when you look up the info in powershell about each individual command so you can actually use get command as a command to look up another command it'll tell you info about it so if you type get command ping it says command type is an application and it points to ping.exe to confirm what i just said and an example for an alias if you type get command cd which is the command prompt command you might know you can see it says it's a alias for the set location powershell native command so you can type either cd like you're used to or you can learn the new one and do set location and if we go even further and type get command set location we can see that this is an example of a command lit so that is a little bit more advanced function created by microsoft but for the more extremely basic commands like we can do the pause command get command pause and you can see that this is actually defined as a function so extremely basic and just built directly into the most basic level of powershell and you can also see there's plenty of other aliases for all your other commands you know for example the dur command is for get child item or if you want to see them all you can just type get dash alias and see all the aliases that exist but if you do this you'll probably notice that not all of these aliases are command prompt commands some of them are actually linux bash commands so yes if you're familiar with the linux bash command already then you again do not have to learn any of these new commands you can just use the alias for the existing bash command that you're already familiar with and it'll do the same exact thing for example the ls command which lists directory contents that also is an alias for the get child item just like cd is an alias for that command in the powershell now i already mentioned how there's a lot more functions and stuff that powershell can do but also how you actually work with these commands in powershell is a lot easier and different than in command prompt and that's because powershell uses what are called pipes to pipe data from one command into the other and let me explain what that even means so with command prompt you probably know you basically just type in a command it's all text as a string of text and then the command prompt will output a bunch of text as the output and if you want to use that output from a command prompt command it's just a string of text so you either have to copy it and then put it into a new command separately but with powershell you can actually take the output from one command and pipe it directly into the input of another command and that's because instead of powershell getting outputs in the form of just a string of text that you have to basically parse out or separate out and get the exact amount powershell actually can output results in an object and what is an object well kind of repeating myself again instead of it being a long string of all the text all blobbed into one thing it's kind of separated out the data is separated out into chunks that are kind of labeled in a way behind the scenes that the programming language can interpret and much easier get out the data exactly what it needs so you can think of it this way let me create this analogy say you want to tell someone to look up some piece of information about owls or something and you give them an encyclopedia and you're like i want to learn the average age of an owl or something like that now if you were to give this encyclopedia to them as the equivalent of a string that would be like just giving them the encyclopedia but the encyclopedia has no titles no table of contents no page numbers it's like literally all the text is just back to back in the encyclopedia it would be extremely hard to get through and find that piece of information you would have to specifically know exactly what you're looking for and kind of have a rough idea already where it is whereas if it's an object that would be the equivalent of giving them an encyclopedia that has all the things labeled and oh this is the page talking about owls all that sort of stuff so you can just get right to the information and extract just that bit out so anyway the consequence of this like i mentioned is that powershell can take that object or organized information from the output of one command and put it directly into another command without having to do any other extra work and the new command will automatically know how to take the part of the original output that is needed for this new command and it can just ignore whatever it else it doesn't need whereas you would have to specifically yourself pick out the information if it was just a string output like command prompt so it's way easier to do much more complex series of commands with powershell if you need to now let's talk about scripts though because i also mentioned that powershell is also the name of the scripting language of the same program but command prompt also is able to do scripts using what are called batch files but powershell uses ps1 files as the script extension and there should be no surprise here that batch files are way more limited than powershell scripts for example in batch scripts you can't even use nested if statements it can only be one if statement at a time and if you want it to be another one you have to use the go to command so you have all these random parts of code at different points in the file and then you have to go to each one it ends up just being spaghetti code bouncing all over the place hard to figure out what's going on it's a pain and i know this from experience because i wrote about script myself which is for a program called youtube dl it's a command line based program for downloading youtube videos it's pretty advanced but you have to use all these weird advanced parameters and stuff so i wrote a batch script that automatically can do exactly what i want anyway i wrote it in batch and i got it all working exactly how i wanted but it was kind of a pain because of the limitations i described with batches before i couldn't do nested if statements so i had to do these weird go-to commands and stuff and it was a pain then i decided to learn powershell enough as part of this video to rewrite the script in powershell and yes powershell does have some weird oddities with the syntax that i don't like for example you can't use the equal sign for a test you have to use dash eq which is stupid and not like any other program i've ever seen that's just dumb but overall powershell was clearly much more capable and powerful to do more advanced things and i was able to actually make the program the way i wanted instead of having to actually work around it with a batch file so the powershell script ended up being a lot more organized and will be a lot easier to modify in the future because i was able to write it in a way that was much more organized to myself instead of again having to write it in the way to make it just kind of work with batch and there's also some other oddities that you'll probably have to get used to for example if you want to run an exe file from the command shell program you can't just type the name of the exe file like you can a command prompt even if you're in the same directory you have to type dot slash to show that you want to use the current directory and then the exe file because for some dumb reason powershell doesn't assume that you want to run the file in the current directory it's in so that's just one thing you have to keep in mind so overall if you're just using the most bare bones basic commands in cmd and that is all you'll ever use i mean yeah you can just use command prompt and not miss anything in powershell but i would still suggest at least getting a little bit familiar with powershell so that you might realize in the future that there is something you can do with powershell that you never would have thought was even possible in command prompt so then you'll at least know and then you can keep using the same commands in powershell anyway so that pretty much just covers what i think is a really bird's eye view overview of the difference between command prompted powershell not gonna obviously get into super details because i probably would not be the best explainer of that kind of thing now if you guys want to keep watching though the next video i would recommend is me talking about the new windows terminal which was kind of just released by microsoft in the final version it basically makes it way easier to kind of manage powershell command prompt all that sort of stuff just watch the video and then that'll make sense so thanks so much for watching guys and i'll see in the next video
Info
Channel: ThioJoe
Views: 308,852
Rating: undefined out of 5
Keywords: technology, tech, powershell, windows powershell, command prompt, windows, cmd vs powershell, microsoft, powershell vs command prompt, powershell vs cmd, command prompt vs powershell, what is powershell, what is windows powershell, how to use powershell, why powershell
Id: H0gwnFV_SFs
Channel Id: undefined
Length: 13min 31sec (811 seconds)
Published: Sat Jul 25 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.