You just have to hit tab after you've typed in the first 3 letters of the file/folder/cmdlet name...also you could convert your Powershell script into a Function and add it to your PSProfile (type "notepad $PROFILE" and save the resulting file to edit later). Then you can run the function with any name you want without navigating to the directory.
The reason why PS doesn't run an executable, even if you're in the directory for it is a safety feature that linux has had for many years. It prevents someone from dropping a malicious exe in the directory with the same name as a common command (like "ls" or "dir") that runs automatically instead of the built in command to do fun things like installing rootkits.
QBASIC: Who are you? Microsoft Disk Operating System: I'm you, but better. Microsoft Disk Operating System: Who are you? CMD Prompt: I'm you, but better.
I can't wrap my mind around how this guy went from telling people to pickle their iPhones in hand sanitizer for free mobile data to making actually informative, well-structured videos
I do miss those videos. It is hard to continue my commwnt themes I use to do. It was I put Maximum Overdrive into a thing and now it is trying to kill me.
He just got tired I guess, it was a different time, more people fell for that and he needed the views lol. It missed the joke if everyone knew it was fake
@@impmadness yeah plus with people not falling for it much anymore he was able to take advantage of that and move his second channel style videos to this one
The ./ is from Linux - and must be specified to execute within the current directory as opposed to an executable in $PATH. This is to help avoid name collisions.
Same thing for the "-eq" instead of "==" for equality test, look like its imported from bash, because behind the scene, the if statement is kinda a program
@@loc4725 Yep. Having the current working directory in PATH is a security no-no. I like how he made a big deal of pipes. People of a certain age, i.e. old gits like me, know that pipes have been around since the year dot, as has redirection. What is more, the concepts are much older than linux (a good thirty years at least). Really, Powershell is just the Bourne shell, albeit implemented slightly differently.
The things you find weird in Powershell are standard ways of doing things from Unix that have been around forever. Using -eq in an if statement is useful because you can use other things in place of it to do other tests. Instead of checking to see if a string or numeric value is equal to something else, you could test something like whether a file exists or what kind of file something is. That's strange for other kinds of languages but it makes good sense in a shell scripting language. As for having to specify the local directory with .\ to run a program in the current directory, that's a security feature that has also been around forever in Unix. Imagine you're sitting in your home directory and you want to run something like ping. The standard Windows version is in your $PATH but your current location isn't. Maybe something malicious put a bad version of ping in your home directory. You want the real one, not the dangerous one, so running things in the local directory is blocked unless directly specified and the system looks to the $PATH to find it.
I think there could also be an alias for "==" which would translate to "-eq". You wouldn't lose functionality but could potentially make the script more clear. I think I'll stick with Python for scripts though. I agree on your second point though, even if I found it a little annoying at first.
@@noxagonal OMG I can't believe we thought the same thing. I was also thinking of "==" for "-eq" One work around for this that I can think of is espanso.
Not running executables in the current directory by default is probably also a Unixism: if you default to running executables/scripts in the current directory, a malicious actor could put an executable named "ls" in a directory and if root were to go into that directory and try to get a listing of the files, they'd run that ls program with root privileges. For non-root users it's less of a problem but it would still be possible to have it, say, delete all the files in the user's home directory. Excluding the current directory from the path means that you have to specifically say "yes, I want to run the program in THIS directory", making it safer.
@@tompycz2225 Right, that just makes it even more confusing. XD Anyways, old convo. I'll stick with python because familiarity and for cross platform compatibility.
Command prompt also supports pipes. It just does text instead of objects which powershell does like you mentioned in the video. Just wanted to share that you can use piped output far before powershell ever existed.
The piping command I used the most, is probably |more Pipes screen output through more, to display one by one screen Useful when your command/program just print to screen, and has no option to stop for every full screen. Can't think of another piping command I have used and remember specifically. I know I have used some, but not enough to remember any of them. The closest thing, would be redirect output to printer { > prn }, or to text-file
1. There's nothing wrong at all with nested if-s in Batch: if 1 == 1 ( if 2 == 2 ( echo yas ) else ( echo no ) ) 2. You have to launch programs with *./* because otherwise it's a security vulnerability. Imagine you download some archive with many many files, you extract it and _cd_ into it. Then you run _dir_ but this archive already comes with its own dir.exe, which in turn could be malicious, so that's why current directory is not automatically added to your PATH.
I had the same thought. IIRC, a common problem with nested conditionals/loops in CMD is that all levels get evaluated at once, breaking what would otherwise be an intuitive experience. If you need to refer to something that changed in the meantime between the outer and the inner scope, you can use _setlocal enabledelayedexpansion_ to defer expansion/evaluation to when the program flow gets there, not to when the outer scope gets interpreted
Great informative video. I'm a systems administrator and I got my most recent job thanks to powershell. During my interview I displayed how I had automated the deployment and configuration of virtual machines to automatically spin up game servers all in powershell and python. Without powershell I wouldn't have the decent lifestyle I have today. This video is a great primer on the basic concepts of powershell, it was really well done. You're clearly knowledgeable about what you're talking about and well researched. Keep up the great work.
The "./" token is a PowerShell security feature that insures the intended application or script is run from the current directory and not an application of the same name in the system or user path that could be potential malware or incompatible application version that may be on a system. Not stupid.
To add to this video for those that are more technical. A lot of the syntax and aliases used by PowerShell were created to provide less of a learning curve for those of us more attuned to bash scripting/Linux terminals. If you look at a PowerShell script compared to a more advanced bash script you can see similarities other than the PowerShell-only commands. (echo instead of Write-Host and so on). With this knowledge, someone who is adept with either scripting language can fill in the blanks and learn the other with relative ease.
You'd be surprised how dependant many enterprises, SMBs, and some older CNC machines software are on the old conhost.exe and cmd.exe. Had Microsoft decided to fully remove them and replace it with PowerShell, it would be disastrous to services dependent on the 30yr+ old conhost and cmd.
@NitroNite72 well I was locking at "windows central" website, talking about how to make light and dark theme switch during different periods. That commend (that's supposed to be timed) changes theme on powershell even when windows isn't activated
@@thepyro7845 /s is used to signal the end of a use of sarcasm. it comes from HTML, where you start a body of text with and end it with , where "something-here" would really be something more descriptive, like the size the text should be, if it's a link, etc.
The reason for the "./program.exe" is to make it more similar to Linux syntax. In Linux, without the ./, the program is assumed to be in the /bin directory, so you need to explicitly state that your program is in the current folder. This is the same case in PowerShell.
The reason this was done in PowerShell was so that someone could not write a script (malicious or otherwise) with the same name as a PowerShell cmdlet, advanced function or alias (e.g. dir), and have the script run instead of the cmdlet, function or alias.
The reason is not to to be similar to linux, it's to combat a security threat. It just so happens that Linux also faces the same threat, so both addressed it in the same way. Similarity to linux is an effect, not the cause.
More than five years I have struggled a lot to fix my PC, even I lost some videos and a lot of files I had saved. I tried some maintenance but I got no solution even my window installation was corrupted and I have also lost two laptops b/c of these previously but now b/c of your support and other similar tutorials I have learned how to fix all the problems and my PC is clean and faster than I expected. Thank you for all your support and good advice's. GBU!
Those oddities in PowerShell you mentioned (like writing -eq instead of =) aren't really oddities because as it turns out this is how you write in bash (the most popular Linux command shell) as well. However, in bash you can also use a legacy method with = instead of -eq, for example, but the syntax is a little different. The same is the case with adding ./ before running a script.
The reason you have to type the " ./ ", is because by default, Powershell (and Bash + other shells) will look for commands in a commands folder, like where that PING.EXE was, for example. So you have to specify that you want to execute the command that is in your working directory.
Also prevents security issues in case you install some malware, and when you go to the directory where it's installed and you type in "dir" or "ls" it would run "dir.exe" (malware) or "ls.exe" (also malware).
This is just a 13 minute video... I can't believe that in only 13 minutes you were able to create the best video I have ever seen to explain Powershell basics to any of my peers in such a short time, this is honestly just amazing!
I drove my old XP into the ground to see how long it would last online after support stopped - over 2 yrs. I have had 10 now for 2 yrs and caught on well due to the fact that I was spending 25 hrs/week maintaining XP for about 8 months. I have been learning a lot about the complexity of 10 and it does impress me all in all. Thanks for the online help. 👍👍
I personally use command prompt, because it launches much faster and I am more familiar with it (first OS for me was XP, where there was no Power Shell). Also command prompt DOES support variables within command window using the SET command (e.g. set /a i=4+7), but it only supports 2 data types (strings and integers). And you CAN use nested if statements, but it requires to enable delayed expansion with variables called with !variablename! instead of %variablename% and it is quite messy anyway requiring you to group commands with parenthesis. Example: @echo off setlocal enabledelayedexpansion set /p value=Enter first value: set /p subvalue=Enter second value: if !value! == 42 ( if !subvalue! == 777 ( echo Lucky life ) else ( echo Unlucky life ) ) else ( echo No life ) endlocal exit /b Command prompt also does use some external commands (programs in System32 as you said, e.g. for.exe, ping.exe, etc.).
@@abdulelahfallatah Exits from a function/batch file without closing command prompt. Basically if the batch file is run from a command prompt window, it returns to command prompt unlike just "exit"
Powershell: Offers object oriented type commands (cmdlet) wich helps programmers the task of scripting and data formatting. On the contraire command prompt is basically powershell without cmdlets. Useful commands to start: get-command get-help get-member With this three commands you are good to go and learn Powerhell by yourself
@Lucas Zhu Windows Terminal doesn’t have powershell or cmd. It’s a terminal application that can run many CLI shells. It runs the same powershell.exe and cmd.exe from the System32 folder as the regular “cmd window”. In fact, the “old command prompt” isn’t a black terminal Window. When you launch “old” CMD, Windows launches the a built-in terminal app called “Windows Console Host” (conhost.exe), and then cmd.exe (the same one that the new Windows terminal uses) launches inside conhost.exe. When you launch “old” powershell, it, too, runs conhost.exe sets background color to blue and then launches PowerShell.exe inside conhost.exe Windows terminal is a replacement conhost.exe. The actual cmd.exe is the same old one and ISN’T open source. Powershell is open source
I just wanna make it clear to you friend (but please DON'T GET ME WRONG!) The Command prompt isn't JUST a tool for the old dos command that are basically for navigating through the operating system. You can actually use extensions that makes it a reliable tool for programming. I actually use it to code with python.
It feels weird that Windows 10 still has an MS-DOS shell decades after MS-DOS was released, honestly PowerShell should be the main, default command shell, while the MS-DOS shell should be an optional install, however backwards compatibility and all that...
The powershell is useless to me because I don't know what do do with it. Command prompt, I know how to work. My first action if PS opens? PS> cmd I don't need to do fancy ass scripting, I just need to execute a non-gui executable, like ffmpeg!
I have literally hundreds of batch files that are used constantly in my work-flow. I'm not a network admin, I'm a web developer. FOR ME, command prompt and batch files are a perfect match for what I do and what I need to do what I do. No aspersions to Powershell - just an example of crude-but-effective being in some instances VERY effective.
Main difference is that PowerShell and cmd works with differents shells in the background. One is older and has less capabilities (cmd) and the other one extents the capabilities of the old one with the use of cmdlets (PowerShell). As a matter of fact the purpose of a shell is to launch programs, which differs a lot from the porpuse of general programming languages which runs commands within a given enviroments (e.g Python interpreter or Java VM) so the concept of command is deprecated in the context of a bash. Instead the most basic syntax of a shell is in the form of . For example in the program is ls which is located given the enviromental variable $PATH, and refers to the argument of the programs which has no special meaning outside the progam.
This reminds me a lot of the differences between OS/2 shell and command shell in OS/2. Basically you can do just about anything you would do in command shell in OS/2 shell but a whole lot more. OS/2 was quite powerful in its day.
Wtf was that intro! Absolutely Genius! The way that you stylishly stuck your head out from behind the couch while unemotionally saying "Windows" with no context. Amazing.
It was pretty informative! The only reason I still prefer the cmd/batch language instead of powershell (excluding backwards compatibility), is loading times (and maybe resource consumtion). If you are using VMs or for whatever reason your PC is lagging, powershell takes ages to load up, while simple cmd starts in seconds. Thanks for the video!
My guess as to what the -eq thing is about, is that it looks like all variables in powershell are objects, since you don't have to declare types. In object oriented languages, you have to use a separate command for finding out equivocation, because the raw value for objects is their location in memory, not their contents.
Batch files don't actually run natively on CMD - they run though the NTVDM (New Technology Virtual DOS Machine). But CMD scripts (.cmd) are a thing so your point still stands. Basically .cmd is more modernized and faster (script is loaded into RAM all at once and executed line by line) while .bat is slower although easier to run (script is loaded line by line into RAM then executed as they are loaded). Makes sense of you think about machines back then compared to today.
@@sethadkins546 Right! to the end user (writer of said batch files/cmd scripts..) it's tomAYtoe VS tomAHtoe, LOL. My only actual point is that "scripts" are still a thing at "Ye Olde Command Prompt". 😛
Like anything in life, it's best to be well rounded. I mostly do PowerShell in my daily work life for work but never ever think that CMD doesn't have its place anymore. What I love about PowerShell is calling direct .NET namespaces for objects, having the option for many different file outputs, ISE/IDE environments. Til this day and I don't care what MS says, CMD is able to get some tasks done faster and more efficient than PS. For me personally, anything that is network related (ping, ipconfig, tracert, nslookup), CMD is still king. Test-Connection -computername is slow and majority of the DNS, Network cmdlets are all over place. They aren't as streamlined as other cmdlets. Both are great, learn both. Yes, PowerShell is the now and future but if you want to be awesome, spend time in CMD as well. It will make you appreciate both styles
Theo-kun... You're underestimating CMD, you're denying a lot of things it can actually do (such as creating variables and using nested if statements) But I enjoyed the video, thanks for the information :D
"PowerShell attempts to protect you from doing things unintentionally in two main ways: Requirement to run scripts by using a full path or relative path: When you run a script, you always need to provide the script's path. Providing the path helps you to know exactly what you're running. For example, there could be commands and aliases on your computer you don't intend to run, but that have the same name as your script. Including the path provides an extra check to ensure you run exactly what you want to run." - Microsoft Site (I cut the second one)
His point is how PS is better (more elegant) about it. For example, say you want to iterate all files in a folder and run a command on each one. In batch, you have to do some goofy tokenizing and parsing out of the dir command, because it just spits out a blob of text, where parts of it are not related to what you want (e.g. file size and attributes). PowerShell can just pipe a cmdlet version to a simple loop that understands the output without you having to "parse" it yourself.
PowerShell gets a lot of its functionality from the .NET Framework and .NET Core, depending on which version is running. You can use AppLocker to lock out people from directly calling .NET functions, but this often breaks many scripts-even those that ship with Windows. Good work, Thio! I am impressed with this video as you went over the fundamentals of PowerShsll quite well.
Also, to make things more confusing, there is _Windows PowerShell,_ which is no longer updated since version 5.1, and there is what used to be called _PowerShell Core,_ nowadays simply _PowerShell,_ which has received multiple important updates for bug-/security fixes and new/extended features, and is in active development. So you might come across a PS script and wonder "Why isn't this working for me?" -- you might have to install the new, shiny PowerShell instead of the old Windows PowerShell.
A couple things from a Systems Engineer. You're correct in saying that PowerShell can do everything cmd can do to an extent. There are things that cmd can do that PowerShell can't and vice versa. For example, if you right click on a shortcut and go to properties under "Target" if you need to add a parameter or switch to the exe that's all in cmd syntax. Also automating the installation of MSI files is typically done via CMD syntax. Great video though. Well explained
Thank you. I always saw powershell only as a program for some advanced people who worked with hundreds of computers in a corporate setup. After watching this I think it has some pretty cool uses for us as well.
PowerShell definitely shines when you have multiple machines that you need to configure the same way. If you need to keep the configuration the same without allowing changes to the installed Windows features, PowerShell can do that as well.
7:23 CMD also has pipes... And you can use powershell commands in cmd, by invoking powershell, the same way you would a ping.exe or whatever. Also I don't know why people call GOTO commands weird. They are incredibly easy to understand... Like an adventure book of coding. If someone is just starting out I would argue that GOTO is a lot easier to underatand than a bunch of function commands in powershell. Lastly, cmd doesn't have that annoying execution policy enabled by default, so IMO wrapping your powershell scripts into .cmd or .bat is the best way to go lol.
Technically, PowerShell is a .NET language, like C#, so all "objects" are .NET objects, and you can therefore use .NET objects directly in scripts. And that is also how PowerShell is cross-platform nowadays 🙂
I saw one of the joke videos about 4 years or so ago, since then I've become big fans of a lot of tech channels, linus, Austin evans....etc Because of that you've been in my recommendations for years but I just never realized that the content had changed to legitimate tips and info. I'm subscribed now but it makes me wonder how many more are like me.
2:47 Wrong. You can also create variables and functions in CMD To create a variable, you do: set VAR_NAME = VALUE And when you press Enter, it will exist for the current session There are 2 big differences between CMD and PowerShell: 1. PowerShell has a unique syntax that resembles in some way the C syntax (ifs, loops, functions, lines end with semicolons) 2. PowerShell runs on .Net Framework or .Net Core (depending on what's installed on your computer), which means that you have access to the entire .Net ecosystem, such as classes, which makes PowerShell very powerful
Yes you can but powershells pipe let's you manipulate the pipeline based on the members coming down the pipeline. Run a gci | gm and look at the members of a file. You can use any combination of the members to manipulate the output
The ./ execute was enforced in Unix/Linux to prevent bad guys from putting a bogus program in your current working directory that has the same name as the program you intended to use. The ./ is a safe guard so that you declare that you understand you are executing the program in your current working directory, not the program in your default execution path which you may have intended or thought you were going to execute.
I tend to use Cmd for simple manual stuff, I've done "for ages". Sometimes making *.bat for repeated simple tasks. If I know how to, and think is easy using CMD or *.bat, that's usually my "go to". As soon as there are more complex things, I rather figure out how to using PowerShell, and probably using script, to reuse next time.
Who remembers when this guy used to make satiric videos like “how do download more Ram”. Used to watch those videos wayyyy back in the day and just stumbled across your channel recently
There are a lot of comments re: incorrect or too shallow statements in the video and they are right. But I did not see anyone mentioning three cornerstone differences b/w PS & CMD that are entirely omitted in the video. 1. It's not "just" objects the PS cmdlets emit. It's .Net objects. DotNet is the programming platform and core of Microsoft's modern ecosystem. It is because of that you can do e.g. (get-date).DeyOfWeek(), not because PS is smart. Why is this important? Because in Powershell you are not limited with windows exes and cmdlets, you can actually _code_ using whole immence power of dotnet. Starting from things like [Math]::Max($a, $b) and 'test, string'.Split(","), and ending up with creating the (!) user interface with e.g. WinForms API, calling web services by using e.g, WebClient class, writing to a database... It's a complete programming language, not just shell script like CMD and (forgive me Linux users) bash. 2. Transparent adapters. There are weird things in PS when you do something like [xml]"". Normally it's a wrong statement because you can't just "cast" a string to some "xml" type. Turns out, you can. There are "adapters" which take (usually) a string and return you some sort of object this string represents. This is devops/sysadmin feature in the most cases as it allows you to manage Active Directory with [adsi], IIS services with [iis] or [iis6], don;t remember , and of course [WMI]. But there are ton of usages in other situations too like above mentioned [xml] or [json] etc. 3. Cross-platform(ity?). The dotnet is ported onto Linux. So is PS. You can write PS script once and run it on Windows, Linux, Mac... No other scripting language allows this.
I kinda like the fact that pwsh uses the dot-slash notation to run files in the current directory, and it makes sense from a developing point of view: if Microsoft did not require the dot-slash notation, they would have to test for the existence of the file in the current directory against the list of commands and cmdlets, wasting precious resources and potentially creating a conflict if there was a command or cmdlet with the same name. Also, bash does it this way as well. :)
I’ve done some PowerShell scripting and studied into it quite a bit. There’s a lot of support for it out there including module’s people are creating. One I’ve been in recently that automates lab environments in hyper-v for you. I can say for sure, the only people who make fun of it are those who haven’t studied it enough. If you’re in IT, learn it
@@tooru some other comments have reported that it was implemented in BASH as a way to avoid conflicts, and also to prevent accidentally executing files instead of commands, or vice versa. That's why it makes sense. They ported the concept from BASH into PowerShell
It has nothing to do with the way you do it in Lnux, even though the "limitation" is there as well. The real reason is security. Having to type the extra .\\ or ./ is to prevent you from accidentally running malicious files. If you issue a command the computer first checks if there is a file with that name in any directory of the PATH. If it were to check if a program exists in the current directory as well, a malicious person could simply put dri.exe in there and instead of not listing all files because you misstyped the dir command, it would actually run a malicious program. except if you mean the forward slash. That is simply because backslash is plain stupid.
Powershell is cool for many reasons. Aliases being one of the most useful. So for those who downloaded their entire Google Play Music library, you will see tons of .csv's. The decision to remove these is up to you depending on how you will use your library. I won't explain their use here. But I will give you a simple Powershell command to remove them all at once. From the parent folder of your Play Music Library files run the following: Get-ChildItem * -Include *.csv -Recurse | Remove-Item This is handy for any type of batch file removal. Just designate the file type. This is a powerful and cannot be undone. Files are permanently deleted. I suggest making a backup copy before running this command.
You've come a long way from the kid making spoof how to videos all those years ago. Didnt think you would be able to transition to a real channel, but kudos to you. You did it, and well. Great video
Command Prompt and PowerShell are basically interpreters of the PowerShell Language and the Batch Language respectively. While both languages are equally capable of doing theoretically everything, The PowerShell Language supports more than the Batch Language does making using it easier.
Command Prompt: Used to manage localhost PowerShell: Used to manage localhost and computers in network. PowerShell ISE: Used to create a script, manage localhost and computers in networks.
Hey, don't knock GoTo! Back in the days before Win95, I wrote a fairly complex (for the day) batch file that loaded on boot to more easily play DOS games so we didn't have to waste memory loading Windows and then the game. I made good use of If, error codes, and GoTo to make that work with all the games we had. Even today, GoTo is very handy to have in VBScript heavy Access Databases. Can't write 3,000 lines of script without throwing in a few GoTos.
As I understand it, the reason that you have to specify that you want an executable in your current directory is to save you from someone dropping a program that deletes all the files it has access to in your current directory and naming it ping.exe
Here's the link to the script I made for those wondering: github.com/ThioJoe/youtube-dl-easy
You just have to hit tab after you've typed in the first 3 letters of the file/folder/cmdlet name...also you could convert your Powershell script into a Function and add it to your PSProfile (type "notepad $PROFILE" and save the resulting file to edit later). Then you can run the function with any name you want without navigating to the directory.
The reason why PS doesn't run an executable, even if you're in the directory for it is a safety feature that linux has had for many years. It prevents someone from dropping a malicious exe in the directory with the same name as a common command (like "ls" or "dir") that runs automatically instead of the built in command to do fun things like installing rootkits.
Can I have a free pc I’m broke
Errors are red, my screen is blue, I think deleted system 32
🤔...was actually how I was looking at your video lmao!!!
CMD Prompt: "Who are you?"
Powershell: "I'm you, but bluer."
CMD Prompt: *color 1F*
Powershell: "..."
...but more advanced
Cmd is actually really dangerous due to it able to communicate directly with the OS
@@bultvidxxxix9973 PowerShell : But im new version of you...
QBASIC: Who are you?
Microsoft Disk Operating System: I'm you, but better.
Microsoft Disk Operating System: Who are you?
CMD Prompt: I'm you, but better.
I can't wrap my mind around how this guy went from telling people to pickle their iPhones in hand sanitizer for free mobile data to making actually informative, well-structured videos
I do miss those videos. It is hard to continue my commwnt themes I use to do. It was I put Maximum Overdrive into a thing and now it is trying to kill me.
I still don't trust him 😬
He just got tired I guess, it was a different time, more people fell for that and he needed the views lol. It missed the joke if everyone knew it was fake
@@impmadness yeah plus with people not falling for it much anymore he was able to take advantage of that and move his second channel style videos to this one
Well he actually worked on coding many infamous Windows 10 features so it makes sense that he understands it so well.
The ./ is from Linux - and must be specified to execute within the current directory as opposed to an executable in $PATH. This is to help avoid name collisions.
And for security reasons.
Same thing for the "-eq" instead of "==" for equality test, look like its imported from bash, because behind the scene, the if statement is kinda a program
yeah ./ is for linux
@@loc4725 Yep. Having the current working directory in PATH is a security no-no.
I like how he made a big deal of pipes. People of a certain age, i.e. old gits like me, know that pipes have been around since the year dot, as has redirection. What is more, the concepts are much older than linux (a good thirty years at least). Really, Powershell is just the Bourne shell, albeit implemented slightly differently.
You are a chad
The things you find weird in Powershell are standard ways of doing things from Unix that have been around forever. Using -eq in an if statement is useful because you can use other things in place of it to do other tests. Instead of checking to see if a string or numeric value is equal to something else, you could test something like whether a file exists or what kind of file something is. That's strange for other kinds of languages but it makes good sense in a shell scripting language.
As for having to specify the local directory with .\ to run a program in the current directory, that's a security feature that has also been around forever in Unix. Imagine you're sitting in your home directory and you want to run something like ping. The standard Windows version is in your $PATH but your current location isn't. Maybe something malicious put a bad version of ping in your home directory. You want the real one, not the dangerous one, so running things in the local directory is blocked unless directly specified and the system looks to the $PATH to find it.
I think there could also be an alias for "==" which would translate to "-eq". You wouldn't lose functionality but could potentially make the script more clear. I think I'll stick with Python for scripts though.
I agree on your second point though, even if I found it a little annoying at first.
@@noxagonal OMG I can't believe we thought the same thing. I was also thinking of "==" for "-eq"
One work around for this that I can think of is espanso.
Not running executables in the current directory by default is probably also a Unixism: if you default to running executables/scripts in the current directory, a malicious actor could put an executable named "ls" in a directory and if root were to go into that directory and try to get a listing of the files, they'd run that ls program with root privileges. For non-root users it's less of a problem but it would still be possible to have it, say, delete all the files in the user's home directory. Excluding the current directory from the path means that you have to specifically say "yes, I want to run the program in THIS directory", making it safer.
@@noxagonal there is == in bash, it just has different functionality. It's string equivalency.
@@tompycz2225 Right, that just makes it even more confusing. XD
Anyways, old convo. I'll stick with python because familiarity and for cross platform compatibility.
I'm learning english and this is the only channel I can understand everything without subtitles. You have a good diction.
English isn’t my native language as well and I totally agree with you☝️
I'm also not a native speaker and I find Thio's accent very understandable, although he speaks a little bit too fast 😅
If you're also into Linux I highly recommend DistroTube and OldTechBloke, they speak very clearly
I've been bouncing on my boys diction for hours to this.
Command prompt also supports pipes. It just does text instead of objects which powershell does like you mentioned in the video. Just wanted to share that you can use piped output far before powershell ever existed.
Yeh, Powershell users - put that in your pipe & smoke it.
You can also set variables, branch and loop, etc. It's just rather uglier. :-)
Please give me an example of piping the output of one command to another, and then piping that output to a third in cmd.exe.
The piping command I used the most, is probably |more
Pipes screen output through more, to display one by one screen
Useful when your command/program just print to screen, and has no option to stop for every full screen.
Can't think of another piping command I have used and remember specifically.
I know I have used some, but not enough to remember any of them.
The closest thing, would be redirect output to printer { > prn }, or to text-file
@@tazguy371 dir|sort|more
it's pretty useless to sort the current directory by day of month but it works
For those in a hurry
Powershell = blue command prompt with yellow font
*and more stuff to do, LOL!
With Linux terminal commands
Powershell can be customized. Right-click top of window> select properties and get crazy...kinda.
@@derrick_martin_g. can be done with everything that uses conhost.exe to display, so you can do it in cmd and most cli programs too
l m a o
The house and background looks lit
Because everything is white?
@@Freakazoid12345 the cushions are not white so whoops
you look lit today! :D
@@AyrisX86 Yes, I'm obviously not talking about the things that don't apply.
@@Freakazoid12345 bruh
1. There's nothing wrong at all with nested if-s in Batch:
if 1 == 1 (
if 2 == 2 (
echo yas
) else (
echo no
)
)
2. You have to launch programs with *./* because otherwise it's a security vulnerability. Imagine you download some archive with many many files, you extract it and _cd_ into it. Then you run _dir_ but this archive already comes with its own dir.exe, which in turn could be malicious, so that's why current directory is not automatically added to your PATH.
I commented on the dot-slash notation and didn't even consider this. It is a very valid point, good one!
I had the same thought. IIRC, a common problem with nested conditionals/loops in CMD is that all levels get evaluated at once, breaking what would otherwise be an intuitive experience. If you need to refer to something that changed in the meantime between the outer and the inner scope, you can use _setlocal enabledelayedexpansion_ to defer expansion/evaluation to when the program flow gets there, not to when the outer scope gets interpreted
Great informative video. I'm a systems administrator and I got my most recent job thanks to powershell. During my interview I displayed how I had automated the deployment and configuration of virtual machines to automatically spin up game servers all in powershell and python. Without powershell I wouldn't have the decent lifestyle I have today. This video is a great primer on the basic concepts of powershell, it was really well done. You're clearly knowledgeable about what you're talking about and well researched. Keep up the great work.
The "./" token is a PowerShell security feature that insures the intended application or script is run from the current directory and not an application of the same name in the system or user path that could be potential malware or incompatible application version that may be on a system.
Not stupid.
It's not an original "feature". It was copied from unix
That is indeed what it does, and it's still incredibly stupid. As is Unix for starting it.
To add to this video for those that are more technical. A lot of the syntax and aliases used by PowerShell were created to provide less of a learning curve for those of us more attuned to bash scripting/Linux terminals. If you look at a PowerShell script compared to a more advanced bash script you can see similarities other than the PowerShell-only commands. (echo instead of Write-Host and so on). With this knowledge, someone who is adept with either scripting language can fill in the blanks and learn the other with relative ease.
Microsoft: We are removing command prompt.
People in 2025: Only the OG remember command prompt.
They literally can't do that. They would break hundreds of thousands of devices, including critical equipment in hospitals and probably even oil rigs.
Some of us still remember the DOS prompt.
@@szymex8341 r/wooosh
You'd be surprised how dependant many enterprises, SMBs, and some older CNC machines software are on the old conhost.exe and cmd.exe.
Had Microsoft decided to fully remove them and replace it with PowerShell, it would be disastrous to services dependent on the 30yr+ old conhost and cmd.
wine cmd
You can't even watch star wars in powershell :/
But you can see in the cmd 😎
It still works in PowerShell.
@@trogdorstrngbd it's better in cmd powershell is for noobs
@@smft9147 well, I don't think so because thiojoe said that powershell is more advanced then cmd.
@@lavleshdubey3338 it is only real ones use cmd powershell is for noobs lmao
Big brain mode:
PS C:\Users\User> cmd
@TheThunderGuyS more like Linux + Windows
@TheThunderGuyS according to Saturniun YT, Windows > macOS > Linux
@@saturniunyttech679 TempleOS > Windows > macOS = Linux
@TheThunderGuyS it's my name dude, or should I say darude
Saturniun YT Me:
Linux > MacOS > Windows
Command Prompt: black
Powershell:
I'm blue
Da ba dee da ba di
Da ba dee da ba di
I use powershell for chocolatey.
Alberto C. Routwell stop right there
@@ThioJoe bruh
ThioJoe why? Do you not like the song?
*dat esh tee tee pee es colon slesh*
easy: one looks cool,and can change theme without activining windows.
other one looks anicent but its faster
/s
@NitroNite72 well I was locking at "windows central" website, talking about how to make light and dark theme switch during different periods. That commend (that's supposed to be timed) changes theme on powershell even when windows isn't activated
@@zsin128 So you locked it?
Sorry if i sound like a dick by saying this, but what does /s mean exactly?
@@thepyro7845 /s is used to signal the end of a use of sarcasm. it comes from HTML, where you start a body of text with and end it with , where "something-here" would really be something more descriptive, like the size the text should be, if it's a link, etc.
@@RotatingBuffalo ok thanks
difference : cmd is blocked by the school while powershell is not
The reason for the "./program.exe" is to make it more similar to Linux syntax. In Linux, without the ./, the program is assumed to be in the /bin directory, so you need to explicitly state that your program is in the current folder. This is the same case in PowerShell.
The reason this was done in PowerShell was so that someone could not write a script (malicious or otherwise) with the same name as a PowerShell cmdlet, advanced function or alias (e.g. dir), and have the script run instead of the cmdlet, function or alias.
The reason is not to to be similar to linux, it's to combat a security threat. It just so happens that Linux also faces the same threat, so both addressed it in the same way. Similarity to linux is an effect, not the cause.
More than five years I have struggled a lot to fix my PC, even I lost some videos and a lot of files I had saved. I tried some maintenance but I got no solution even my window installation was corrupted and I have also lost two laptops b/c of these previously but now b/c of your support and other similar tutorials I have learned how to fix all the problems and my PC is clean and faster than I expected. Thank you for all your support and good advice's. GBU!
Those oddities in PowerShell you mentioned (like writing -eq instead of =) aren't really oddities because as it turns out this is how you write in bash (the most popular Linux command shell) as well. However, in bash you can also use a legacy method with = instead of -eq, for example, but the syntax is a little different.
The same is the case with adding ./ before running a script.
them being on linux doesn't make them good. Weird way to think
I’m sorry but why don’t they just alias Write-Host to something more familiar, oh, idk, maybe like the word “echo” 😂❤
The reason you have to type the " ./ ", is because by default, Powershell (and Bash + other shells) will look for commands in a commands folder, like where that PING.EXE was, for example. So you have to specify that you want to execute the command that is in your working directory.
that makes alot of sense actualy
Also prevents security issues in case you install some malware, and when you go to the directory where it's installed and you type in "dir" or "ls" it would run "dir.exe" (malware) or "ls.exe" (also malware).
This is just a 13 minute video... I can't believe that in only 13 minutes you were able to create the best video I have ever seen to explain Powershell basics to any of my peers in such a short time, this is honestly just amazing!
I drove my old XP into the ground to see how long it would last online after support stopped - over 2 yrs. I have had 10 now for 2 yrs and caught on well due to the fact that I was spending 25 hrs/week maintaining XP for about 8 months. I have been learning a lot about the complexity of 10 and it does impress me all in all. Thanks for the online help. 👍👍
I personally use command prompt, because it launches much faster and I am more familiar with it (first OS for me was XP, where there was no Power Shell). Also command prompt DOES support variables within command window using the SET command (e.g. set /a i=4+7), but it only supports 2 data types (strings and integers). And you CAN use nested if statements, but it requires to enable delayed expansion with variables called with !variablename! instead of %variablename% and it is quite messy anyway requiring you to group commands with parenthesis.
Example:
@echo off
setlocal enabledelayedexpansion
set /p value=Enter first value:
set /p subvalue=Enter second value:
if !value! == 42 (
if !subvalue! == 777 (
echo Lucky life
) else (
echo Unlucky life
)
) else (
echo No life
)
endlocal
exit /b
Command prompt also does use some external commands (programs in System32 as you said, e.g. for.exe, ping.exe, etc.).
Else if is possible:
if 1==42 (
echo ok
) else if 1==1 (
echo ok
)
@Markus that example doesn't need enabledelayedexpansion.
@@unknownaccount4783 oh, didn't realize that
@@Kris_M yes, but I put it there if anyone wanted to define variables inside the if statement
@@abdulelahfallatah Exits from a function/batch file without closing command prompt. Basically if the batch file is run from a command prompt window, it returns to command prompt unlike just "exit"
Powershell: Offers object oriented type commands (cmdlet) wich helps programmers the task of scripting and data formatting. On the contraire command prompt is basically powershell without cmdlets.
Useful commands to start:
get-command
get-help
get-member
With this three commands you are good to go and learn Powerhell by yourself
7:15 cd is not the cmd command for bash's ls, dir is
Sathya yea I mis-spoke
In powershell cd is Set-Location
Dir is Get-ChildItem
ls is for linux
This comment needs more punctuation
How I use powershell...
"Start cmd"
I've never actually used PowerShell before..
(No one cares)
I only use powershell for ps1 scripts and stuff like that
😂
@Lucas Zhu Windows Terminal doesn’t have powershell or cmd. It’s a terminal application that can run many CLI shells. It runs the same powershell.exe and cmd.exe from the System32 folder as the regular “cmd window”. In fact, the “old command prompt” isn’t a black terminal Window. When you launch “old” CMD, Windows launches the a built-in terminal app called “Windows Console Host” (conhost.exe), and then cmd.exe (the same one that the new Windows terminal uses) launches inside conhost.exe. When you launch “old” powershell, it, too, runs conhost.exe sets background color to blue and then launches PowerShell.exe inside conhost.exe
Windows terminal is a replacement conhost.exe. The actual cmd.exe is the same old one and ISN’T open source.
Powershell is open source
I just wanna make it clear to you friend (but please DON'T GET ME WRONG!)
The Command prompt isn't JUST a tool for the old dos command that are basically for navigating through the operating system.
You can actually use extensions that makes it a reliable tool for programming.
I actually use it to code with python.
I'm always amazed by how much more information I actually get from your videos than I could ever expect, good job!
It feels weird that Windows 10 still has an MS-DOS shell decades after MS-DOS was released, honestly PowerShell should be the main, default command shell, while the MS-DOS shell should be an optional install, however backwards compatibility and all that...
Well powershell is default but you can change it in settings which I recommend everyone do cuz powershell low-key ass lmao
Reminds me of my first PC back in the day. I refused to buy a computer using only DOS commands, I finally came across a DOS Shell and bingo - sold
Powershell is default
@@smft9147 The real big brain move is to enable WSL and the use bash/csh/zsh/fish
The powershell is useless to me because I don't know what do do with it. Command prompt, I know how to work. My first action if PS opens? PS> cmd
I don't need to do fancy ass scripting, I just need to execute a non-gui executable, like ffmpeg!
I have literally hundreds of batch files that are used constantly in my work-flow. I'm not a network admin, I'm a web developer. FOR ME, command prompt and batch files are a perfect match for what I do and what I need to do what I do. No aspersions to Powershell - just an example of crude-but-effective being in some instances VERY effective.
Main difference is that PowerShell and cmd works with differents shells in the background. One is older and has less capabilities (cmd) and the other one extents the capabilities of the old one with the use of cmdlets (PowerShell).
As a matter of fact the purpose of a shell is to launch programs, which differs a lot from the porpuse of general programming languages which runs commands within a given enviroments (e.g Python interpreter or Java VM) so the concept of command is deprecated in the context of a bash. Instead the most basic syntax of a shell is in the form of . For example in the program is ls which is located given the enviromental variable $PATH, and refers to the argument of the programs which has no special meaning outside the progam.
This reminds me a lot of the differences between OS/2 shell and command shell in OS/2. Basically you can do just about anything you would do in command shell in OS/2 shell but a whole lot more. OS/2 was quite powerful in its day.
Wtf was that intro!
Absolutely Genius! The way that you stylishly stuck your head out from behind the couch while unemotionally saying "Windows" with no context. Amazing.
I used to not like Powershell's font but then Windows Terminal came out.
same, but I also didn't like the blue background
i like terminals font, anyways im pretty sure theyll add an option to chanhe it in a future update
@@octavylon9008 Powershell can be customized. Right-click top of window> select properties and get crazy...kinda.
@@Stridsvagn69420 Powershell can be customized. Right-click top of window> select properties and get crazy...kinda.
@@Stridsvagn69420 powershell is customisable tho
It was pretty informative!
The only reason I still prefer the cmd/batch language instead of powershell (excluding backwards compatibility), is loading times (and maybe resource consumtion). If you are using VMs or for whatever reason your PC is lagging, powershell takes ages to load up, while simple cmd starts in seconds.
Thanks for the video!
just switch to a Unix shell and see how much it helps ;)
@@NoOne-sy5fg well, I switch to Linux time to time instead :D
My guess as to what the -eq thing is about, is that it looks like all variables in powershell are objects, since you don't have to declare types. In object oriented languages, you have to use a separate command for finding out equivocation, because the raw value for objects is their location in memory, not their contents.
You CAN write scripts for the traditional "Command Prompt" - Batch files are a thing. "pipes" are also a thing in Command Prompt.
Batch files don't actually run natively on CMD - they run though the NTVDM (New Technology Virtual DOS Machine). But CMD scripts (.cmd) are a thing so your point still stands. Basically .cmd is more modernized and faster (script is loaded into RAM all at once and executed line by line) while .bat is slower although easier to run (script is loaded line by line into RAM then executed as they are loaded). Makes sense of you think about machines back then compared to today.
@@sethadkins546 Right! to the end user (writer of said batch files/cmd scripts..) it's tomAYtoe VS tomAHtoe, LOL. My only actual point is that "scripts" are still a thing at "Ye Olde Command Prompt". 😛
Teacher: opening another tab will close the main tab
Me with powershell doing math: i can’t hear you
Like anything in life, it's best to be well rounded. I mostly do PowerShell in my daily work life for work but never ever think that CMD doesn't have its place anymore.
What I love about PowerShell is calling direct .NET namespaces for objects, having the option for many different file outputs, ISE/IDE environments.
Til this day and I don't care what MS says, CMD is able to get some tasks done faster and more efficient than PS. For me personally, anything that is network related (ping, ipconfig, tracert, nslookup), CMD is still king. Test-Connection -computername is slow and majority of the DNS, Network cmdlets are all over place. They aren't as streamlined as other cmdlets.
Both are great, learn both. Yes, PowerShell is the now and future but if you want to be awesome, spend time in CMD as well. It will make you appreciate both styles
Did you tested new PowerShell? (PowerShell 7.0x)
It's .NET Core based and crossplatform. Maybe it's also less buggy? :-)
Theo-kun... You're underestimating CMD, you're denying a lot of things it can actually do (such as creating variables and using nested if statements)
But I enjoyed the video, thanks for the information :D
Agreed. Complete systems have been written in the Unix/Linix shells, and cmd isn't too far behind, if any. Pretty clumsy, but you get used to it.
And you can redirect output into other programs. Remember "type file.txt | more"?
@@abdulelahfallatah %[variable]% I'm pretty sure is just environment variables.
@@PaulJohnsonM Exactly, pipelines are even a thing in bash/zsh as well, but i think PS does it slightly differently.
"PowerShell attempts to protect you from doing things unintentionally in two main ways:
Requirement to run scripts by using a full path or relative path: When you run a script, you always need to provide the script's path. Providing the path helps you to know exactly what you're running. For example, there could be commands and aliases on your computer you don't intend to run, but that have the same name as your script. Including the path provides an extra check to ensure you run exactly what you want to run." - Microsoft Site (I cut the second one)
10:26 Of course you can use nested IF statements in batch files. Also ELSE and ELSE IF.
So as pipes :-)
r/foundthecmdfans
Piping from cmd-line " dir > dir.dat" - send output to file.
Good introduction. THANKS!
BTW - MSDOS commands will pipe output and input.
I do all sorts of piping with > | < in CMD. Always have....always will.....
@@abdulelahfallatah > writes the output to something. | is for piping. For example, echo 1 > C:\example.txt would write 1 to example.txt
| pipe
>make file from output
>>append output to file
His point is how PS is better (more elegant) about it. For example, say you want to iterate all files in a folder and run a command on each one. In batch, you have to do some goofy tokenizing and parsing out of the dir command, because it just spits out a blob of text, where parts of it are not related to what you want (e.g. file size and attributes). PowerShell can just pipe a cmdlet version to a simple loop that understands the output without you having to "parse" it yourself.
PowerShell gets a lot of its functionality from the .NET Framework and .NET Core, depending on which version is running. You can use AppLocker to lock out people from directly calling .NET functions, but this often breaks many scripts-even those that ship with Windows. Good work, Thio! I am impressed with this video as you went over the fundamentals of PowerShsll quite well.
"you have to use -eq which is stupid"
Me after 3 years of ksh 👀
Also, to make things more confusing, there is _Windows PowerShell,_ which is no longer updated since version 5.1, and there is what used to be called _PowerShell Core,_ nowadays simply _PowerShell,_ which has received multiple important updates for bug-/security fixes and new/extended features, and is in active development.
So you might come across a PS script and wonder "Why isn't this working for me?" -- you might have to install the new, shiny PowerShell instead of the old Windows PowerShell.
how to hack the government:
1. Open cmd
2. color 0a
you forgot "tree"
Ah yes obamium
@@gaveferia1421 dir -a
Lol
Open terminal
rm rf *
Revisiting your older videos, I appreciate the thorough and clear explanations. Thank you.
I really like this guy's presentation. Not too flashy, and easy to follow.
I use Cortana for all my windows commands
Microsoft should make a robot with Cortana built in. Make it thicc.
"Hey Cortana, format my C drive"
@@cscscscss Hey Cortana, I have a problem with my D drive.
Progamermovelol.
@@cscscscss 😂😂😂
A couple things from a Systems Engineer. You're correct in saying that PowerShell can do everything cmd can do to an extent. There are things that cmd can do that PowerShell can't and vice versa. For example, if you right click on a shortcut and go to properties under "Target" if you need to add a parameter or switch to the exe that's all in cmd syntax. Also automating the installation of MSI files is typically done via CMD syntax.
Great video though. Well explained
10:14 Not accurate enough
Command Prompt can run .bat and .cmd
PowerShell can run .bat , .cmd and .ps1
Thank you. I always saw powershell only as a program for some advanced people who worked with hundreds of computers in a corporate setup. After watching this I think it has some pretty cool uses for us as well.
PowerShell definitely shines when you have multiple machines that you need to configure the same way. If you need to keep the configuration the same without allowing changes to the installed Windows features, PowerShell can do that as well.
7:23 CMD also has pipes... And you can use powershell commands in cmd, by invoking powershell, the same way you would a ping.exe or whatever.
Also I don't know why people call GOTO commands weird. They are incredibly easy to understand... Like an adventure book of coding. If someone is just starting out I would argue that GOTO is a lot easier to underatand than a bunch of function commands in powershell.
Lastly, cmd doesn't have that annoying execution policy enabled by default, so IMO wrapping your powershell scripts into .cmd or .bat is the best way to go lol.
I remember pipes from DOS--combining text files, piping dir to a text file to get a list of files in your directory. Fun times!
Technically, PowerShell is a .NET language, like C#, so all "objects" are .NET objects, and you can therefore use .NET objects directly in scripts.
And that is also how PowerShell is cross-platform nowadays 🙂
You can even write Powershell scripts that could be mistaken for C# if you wanted to.
Learning powershell right now for work and this video is an absolute gem.
Where can we get that TH-cam DL script?
I saw one of the joke videos about 4 years or so ago, since then I've become big fans of a lot of tech channels, linus, Austin evans....etc
Because of that you've been in my recommendations for years but I just never realized that the content had changed to legitimate tips and info. I'm subscribed now but it makes me wonder how many more are like me.
command prompt has had pipes since before Windows was even invented. this feature has probably existed since MS-DOS 1.0
2:47 Wrong. You can also create variables and functions in CMD
To create a variable, you do: set VAR_NAME = VALUE
And when you press Enter, it will exist for the current session
There are 2 big differences between CMD and PowerShell:
1. PowerShell has a unique syntax that resembles in some way the C syntax (ifs, loops, functions, lines end with semicolons)
2. PowerShell runs on .Net Framework or .Net Core (depending on what's installed on your computer), which means that you have access to the entire .Net ecosystem, such as classes, which makes PowerShell very powerful
PS imo is closer to C# in terms of syntax
Pipes can also be used in Command Prompt.
Yes you can but powershells pipe let's you manipulate the pipeline based on the members coming down the pipeline. Run a gci | gm and look at the members of a file. You can use any combination of the members to manipulate the output
The ./ execute was enforced in Unix/Linux to prevent bad guys from putting a bogus program in your current working directory that has the same name as the program you intended to use. The ./ is a safe guard so that you declare that you understand you are executing the program in your current working directory, not the program in your default execution path which you may have intended or thought you were going to execute.
Same thing in PowerShell 👍
Finally someone making comparison videos the right way. Great work man!
You are the best TH-cam advice giver ever
Piping works in cmd too btw. Also you can just type powershell in the command prompt to get it.
I tend to use Cmd for simple manual stuff, I've done "for ages".
Sometimes making *.bat for repeated simple tasks.
If I know how to, and think is easy using CMD or *.bat, that's usually my "go to".
As soon as there are more complex things, I rather figure out how to using PowerShell, and probably using script, to reuse next time.
i really like yo house :D
me too :D
Plot twist: it's a random strangers house
Ye
i love how you talked about this on your couch.
Awesome sofa you got there
It's an ikea
@@ThioJoe but it's not blue with yellow! Are you sure?
@@QkeleQ10 like powershell!!!
Who remembers when this guy used to make satiric videos like “how do download more Ram”. Used to watch those videos wayyyy back in the day and just stumbled across your channel recently
CMD? - Nah...
Power shell? - WHY?!
bash? - Yeah... :D
6:46 another quality content which makes your videos worth watching !
Command prompt > powershell
The OG
Ye
@@abdulelahfallatah ? :/
@@abdulelahfallatah oh..
xD!!!
The new windows terminal with oh-my-posh looks awesome 👍🏻
I feel real Vsauce with these setups. I like it.
There are a lot of comments re: incorrect or too shallow statements in the video and they are right.
But I did not see anyone mentioning three cornerstone differences b/w PS & CMD that are entirely omitted in the video.
1. It's not "just" objects the PS cmdlets emit. It's .Net objects. DotNet is the programming platform and core of Microsoft's modern ecosystem. It is because of that you can do e.g. (get-date).DeyOfWeek(), not because PS is smart.
Why is this important? Because in Powershell you are not limited with windows exes and cmdlets, you can actually _code_ using whole immence power of dotnet. Starting from things like [Math]::Max($a, $b) and 'test, string'.Split(","), and ending up with creating the (!) user interface with e.g. WinForms API, calling web services by using e.g, WebClient class, writing to a database... It's a complete programming language, not just shell script like CMD and (forgive me Linux users) bash.
2. Transparent adapters. There are weird things in PS when you do something like [xml]"". Normally it's a wrong statement because you can't just "cast" a string to some "xml" type. Turns out, you can. There are "adapters" which take (usually) a string and return you some sort of object this string represents. This is devops/sysadmin feature in the most cases as it allows you to manage Active Directory with [adsi], IIS services with [iis] or [iis6], don;t remember , and of course [WMI]. But there are ton of usages in other situations too like above mentioned [xml] or [json] etc.
3. Cross-platform(ity?). The dotnet is ported onto Linux. So is PS. You can write PS script once and run it on Windows, Linux, Mac... No other scripting language allows this.
MS-DOS - The real performer
PowerShell - MS-DOS in drag
Cmdlets - drag accessories
I kinda like the fact that pwsh uses the dot-slash notation to run files in the current directory, and it makes sense from a developing point of view: if Microsoft did not require the dot-slash notation, they would have to test for the existence of the file in the current directory against the list of commands and cmdlets, wasting precious resources and potentially creating a conflict if there was a command or cmdlet with the same name.
Also, bash does it this way as well. :)
The last line of his PowerShell script calls cmd. XD
I’ve done some PowerShell scripting and studied into it quite a bit. There’s a lot of support for it out there including module’s people are creating. One I’ve been in recently that automates lab environments in hyper-v for you. I can say for sure, the only people who make fun of it are those who haven’t studied it enough. If you’re in IT, learn it
I tried, but the weird syntax is the problem.
@@kcvinu
lol I made this comment 3 years ago. I don't remember making it.
since powershell can run on windows and linux the ./ is b/c of the way files are run in linux
This makes a lot of sense.
that still doesn't explain why this is the way you do it
@@tooru some other comments have reported that it was implemented in BASH as a way to avoid conflicts, and also to prevent accidentally executing files instead of commands, or vice versa. That's why it makes sense.
They ported the concept from BASH into PowerShell
It has nothing to do with the way you do it in Lnux, even though the "limitation" is there as well.
The real reason is security. Having to type the extra .\\ or ./ is to prevent you from accidentally running malicious files. If you issue a command the computer first checks if there is a file with that name in any directory of the PATH. If it were to check if a program exists in the current directory as well, a malicious person could simply put dri.exe in there and instead of not listing all files because you misstyped the dir command, it would actually run a malicious program.
except if you mean the forward slash. That is simply because backslash is plain stupid.
Powershell is cool for many reasons. Aliases being one of the most useful.
So for those who downloaded their entire Google Play Music library, you will see tons of .csv's. The decision to remove these is up to you depending on how you will use your library. I won't explain their use here. But I will give you a simple Powershell command to remove them all at once.
From the parent folder of your Play Music Library files run the following:
Get-ChildItem * -Include *.csv -Recurse | Remove-Item
This is handy for any type of batch file removal. Just designate the file type. This is a powerful and cannot be undone. Files are permanently deleted. I suggest making a backup copy before running this command.
Cmd: Basically DOS in Windows NT
Powershell: If DOS and BASH had a baby.
And it came out with an extra chromosome
No... not even bash.. still not at linux level. It's still far away
That baby would simply be bash and we already have it.
You've come a long way from the kid making spoof how to videos all those years ago. Didnt think you would be able to transition to a real channel, but kudos to you. You did it, and well. Great video
Lol I feel so old having my CMD pinned on my task bar.
Your not alone
actually learnt powershell for this video. respect
0:03 POWERSHELL IS BLUE
Amazing video. High quality content including the way you present the material and the picture as well. You got a new subscriber!
Ngl he kinda scared me when he popped out from behind the couch
Command Prompt and PowerShell are basically interpreters of the PowerShell Language and the Batch Language respectively. While both languages are equally capable of doing theoretically everything, The PowerShell Language supports more than the Batch Language does making using it easier.
meanwhile me using zsh:
Command Prompt: Used to manage localhost
PowerShell: Used to manage localhost and computers in network.
PowerShell ISE: Used to create a script, manage localhost and computers in networks.
Hey, don't knock GoTo! Back in the days before Win95, I wrote a fairly complex (for the day) batch file that loaded on boot to more easily play DOS games so we didn't have to waste memory loading Windows and then the game. I made good use of If, error codes, and GoTo to make that work with all the games we had. Even today, GoTo is very handy to have in VBScript heavy Access Databases. Can't write 3,000 lines of script without throwing in a few GoTos.
As I understand it, the reason that you have to specify that you want an executable in your current directory is to save you from someone dropping a program that deletes all the files it has access to in your current directory and naming it ping.exe
But powershell requires .NET framework => slow startup
Microsoft removing CMD soon? Gonna switch fully to yori
is this true? powershell uses . net? anyway I use cmd,