PowerShell tab completion not only completes the command you've started, if give a few letters, it will cycle through every possible command that has those letters. If you pass up the one you want, goes in reverse order. Tab completion also will give you a list of all possible switches. Type in the command, put in one white space then the followed by the and it will cycle all the possibilities. In in the old PowerShell ISE or newer ISE, you get a context menu to appear that you can select the switch needed from the list. I put off PowerShell for the first few years, and only began to use it at the end of v2 with v3 coming out soon after I started learning. I absolutely love PowerShell for what you can get that isn't given (or not given easily) in Windows GUI. Case in point, the FQDN of a network computer. Get-ADComputer -Identity ComputerName will return five or so lines of the most common information of a computer object from Active Directory, one of which shows the OU path to finding the computer in AD. There is so much that can be done with simple commands in PowerShell. Once you learn a few, you will see how *most* can chain together via piping. I stress most, as some do no feed into other commands as one would hope or seem to expect. Where PowerShell shines is in simple scripting with a ForEach stepping through a list of objects and performing some task. Continuing on from the previous example of Get-ADComputer, you can specify an OU, then feed the results into a Get-Win32 (or newer Get-Cim) and pull things like the serial number stored in the machines BIOS, how much RAM is installed, Hard Drive space total and free to build a CSV that can be imported into Excel to help determine what hardware may be reaching end of life or need upgrading. The only limit to PowerShell is really our own limit to image what we can do with this tool.
Hi Gary, Another great explanation. I grew up with CP/M, MS DOS and several varieties of Unix-based shell. Over the last 20 years I have only used PowerShell when I really needed to as it always seemed excessively complicated and verbose. However, if I had learned the tips you gave earlier maybe I would not have been so reluctant to use it.
I've always found dos/command prompt to be too limited and PowerShell to be too overly-verbose. But, to be fair, I trod the sh->csh->ksh->bash path over the past 25 or so years, so they've become the standard against which I measure. All the same, your quick mini-tutorial really does explain useful PowerShell techniques a great deal, so thank you! 🐧👍
Yea I agree. Powershell clearly has power. But it’s very specific, very verbose , and I’m never doing anything with out “SHOW-COMMAND” and “GET-COMMAND | OUT-GRIDVIEW” running in the background along with online documentation. Because you can’t just remember such a verbose language. It’s consistently is nice and occasionally elegant. Btw “show-command|out-gridview” is blocking. If anyone has a trick to make it non blocking I’d sincerely appreciate it. Because it means I have to open a second terminal just for that, I’ve tried start job and run process and similar, I need the “&” operator equivalent
Gary here are 5 real commands people should really know 1- Show-command 2- Get-command l out-gridview 3- Get-help “command-name” Especially with the -examples flag “Get-help invoke-command -examples “ ALSO use help for concepts "Get-Help -about_" note the "-" flag and "_' underscore, then just keep hitting tab. 4- set up PowerShell to be user friendly-- $global:DebugPreference = “Continue” $InformationPreference = Continue $VerbosePreference = Continue This turns on a lot of feedback about whatPowershell is doing with each conmand or what’s wrong - really really helps learn, if you get sick of it change all three back to $InformationPreference= ‘SilentlyContinue’ -- *oddly continue requires no quotes but = ‘SilentlyContinue’ does *, other options are 'Stop' and "Inquire". For completeness there is also $ConfirmPreference and $WarningPreference with settings of None, Low, Medium and High. That will warn you if you might do something dangerous or foolish. No clue if it works well. 5- I put "$global:" in the first one intentionally. Obviously any variable has a dollarsign "$Variable". Try "$global:", "$env:" and even just "$" and hit tab to see whats already there and what settings are stored. Most all the settings are there somewhere. I think there are more prefixes to get to more but I cant recall them atm. 6-- Log everything you do in power shell so if you screw something up you can undo it “Start-Transcript -OutputDirectory ‘c:\yourchoice\always quote if spaces\ ‘ " 7 Most import bit last- and this is a lot so go through it. Powershell everything is an object or a cmdlet (overgeneralized like any complicated thing but lets go with it) Lets use files as an example- They are objects called "Items" - so are directories- more on that in a second. So, to see the files in the current directory we'd use "Get-ChildItem" This says get all the children files of this directory I am in. There are other Item commands Delete-Item, Move-Item, etc, see "Get-Alias to see more: which would also show us this common is also under "gci" and "dir" to match old command prompt. and especially check "Get-Command | Out-Gridview" to find other Item Modifying commands. Its usually where people start with powershell manipulating files. 7b-- You get a list back, powershell loves lists, and most things return lists. I couldnt do anything in powershell until I learned how to handle lists. Its critical. Now first- another trick -- try "Get-ChildItem -" or "gci -" with the "-" flag symbol, start hitting tab to see what flags that command might take. They vary a lot and are confusing. Especially filtering- check help this is too long already. But a simple few are -Directory -File and some others, This returns only the sub-directories. -Recurse is useful too. Short version, JUST USE TAB when stuck. But we get our list of anything. We need to pick one from the list. Like I said most commands generate lists. For this we need "select" or "Select-Object" - again basics here, we can stick to "-Index {number}" or use -First or -Last. The thing that confused me forever is that First and Last also expect numbers. In my opinion it should default to 1, but it doesnt. so we say "$File = gci | select -First 1" Three things to notice, we didnt get any output when assigning to a variable. Type $File and youll get it. And 2, we used the critically important message passing character in powershell "|". Its really the powershell secret sauce, otherwise not just difficult but sorta pointless. 3- you got the second file not the first. This is because computers start with 0 usually. If wed used "-First 5" wed have a new smaller list, If we used "$File = gci | select -First 0" or 1 tbf, now importantly we have selected a single object and can do things to it. There is a big difference to having a list and having an object in hand. You can treat lists sequentially or in parallel but this is 101 here. So we need to see what we can do with the object. For that use "gm" or "get-member" and itll show you things you can get from it. Properties you just use a dot. eg. "$File.Directory" tab works here to. we can also $File.MoveTo("C:\Users\me\myfilename"). Methods are harder. And in my case I copied a directory into a file, which is no doubt going to have odd outcomes. But thats enough for now Ok those were my major stumbling blocks learning. I have a lot of notes I took for myself and myself alone - so forgive errors. I wrote most of it, but in other cases I blatantly copied from Microsoft Documentation or Stack Overflow. But Ill share it here. First though Ill Recommend the official doc, which after years of being horrible, all Microsoft Documentation has gotten quite good over the last decade.
Lovely video. I used to script using DOS batch many moons ago. Now fully immersed in PowerShell and love it, 😂 Yes, content like this is nice. Thank you 🙏
Dude you haven't seen anything yet. Powershell is quite great in dealing with data and basic data-analysis. Lookup commands (Convertfrom-csv) and (out-gridview) and (convertfrom-json) Its also quite powerful in the web API realm. (invoke-webrequest) This is one of the biggest reasons that multiple Monitoring software often just default to utilizing Powershell scripts to get data and transform data. It's one of those languages that is extremely powerful yet underappreciated despite the weight it carries in the monitoring world and corners of the data-analysis realm And this is all before any modules and specialized packages are installed to aid in stuff
It is great for data analysis the problem is python got their first and is considered the gold standard. I do really like Powershell for Windows. Beyond that though I keep with Linux GNU Core utils and Python.
The great thing about pwsh is that it's not just a shell, it's a scripting language. There's so many times where you can just write 10 lines of pwsh instead of having to write an actual application. Especially with the likes of Azure functions.
Thanks for finally showing me how powershell is useful! I have just been using as a cmd prompt replacement, but these examples alone are very useful for debugging. I am going to start using cmdlets now, thanks for setting me on the path. 🙂
Hi Gary! So glad I watched the whole video! Thank you for the awesome simple content. I need to watch again and make some notes. Thank you for this lesson! 👍🙏
Good things to know before learning: You MUST set your execution policy, start PS in admin mode, learn how to import modules so you can reach and administer objects like EXO and tape drives.
I love PowerShell. I maintain a huge 911 system (larger than some countries) and it helps me stay out of the news. In my world, you fix things before they even fully break. PowerShell let's me see stuff.
Excellent! I could have learned this myself, if I wasn't such an idle dinosaur. However you have prompted me to look into this, install PS 7, observe that there's some interesting connection with Visual Code and resolve to look into SSH-ing from PS direct into a RPi rather than via PuTTY. Very educational!
Thanks a lot, trying to follow along in the hopes that finally the PS commands keep sticking in my mind. But I have to say, getting the latest PS version with winget from the command line ... and then a _window_ pops up wanting acknowledging - this is _such_ a windows thing to do. And then closing the ps window and starting again - it still shows the old version???
PowerShell is verbose, but have good gears to windows. In windows env I recommend use. But Nix universe is good stay with bash,Zsh , perl or python....
Most of these cases can be easily done in just CMD. The real killer feature of PS though is complex cases involving working with and passing data objects.
One easier manner to get what you last typed was to click on the Up Arrow or Down arrow button on the Keyboard. You can scroll thru the last commands you typed in.
This was fairly new to me. Was anyone else new to this surprised by the amount of processes running on their pc compared to Gary's? A lot of them were "svchost", had to look them up to see what they were about!
It's all the superfluous services running that each next Windows version just keeps ramping up. Got to eat the resources, or people won't have to upgrade the hardware as often!
PowerShell is useful; so I am not going to deny the need for PowerShell. However, it’s greatest strength is it’s greatest weakness. PowerShell used objects whereas Unix-like use a data stream. The great thing about objects is that it’s extremely easy to parse. The terrible thing about objects is that it makes “one-liners” near impossible. I find myself trying to type out a PowerShell command, stop, and then jump to a notepad to write a paragraph. Compare that with Unix-like, it takes me a one-line sentence. I do understand that parsing data in Unix-like can be difficult. That aside, PowerShell is very difficult to find any good tutorials. It’s also limited to whatever “commands” are available created. It also gets confusing when C#/.Net code creeps it’s way into a script. It makes it harder to see what all is happening in a given script.
W.r.t. to doing something in one-line in “Unix-like” but not being able to do so in PowerShell: I suspect that is more a question of PowerShell skill. I certainly know of a number of scenarios that I can do in one line that is just impossible in “Unix-like”
@@nicovandyk3856 no he has a point consider free -h to get all of your cpu and ram usage in linux. For Powershell if you want to see anything other than bytes you use the math object and set an expression. Not the same. But I will say Powershell has some excellent advanced features such as pulling data into a custom object and then outputting it to html for example with a one line command. Its also great when combined with PowerBi. But look my issue is there are already many tools in the Linux space that when combined give you waaay more control. Powershell is very useful but mainly if you want to confine yourself to dotnet and windows only.
@@williamevans6830 : Thanks! But do know PowerShell is available on Linux/Mac so you need not be confined to the Windows eco-system 😉 As for the numerous tools that exist in Lin/Unix - I sincerely see that more as a problem than anything (Not trying to flame/be wise-a$$ at all). Each of these are little independent programs of their own instead of an extendable library which is more API like, like is case with PowerShell. This API-like/library approach means that there is much more enforcement of standardization than was the case is ye-olden-days when Unix/POSIX was established. In those days everyone did things their own way and standardization more of a opt-in kinda thing - and still is to a large extent in Bash today. I mean, it is much easier for me to write my own compiled console app that works completely different from the rest of the Unix eco-system whereas it is much more difficult to do so in PowerShell where it is just much easier to stick to the standard (I worked in both btw)
@@nicovandyk3856 for these arguments I keep coming back to what Steve Jobs said about Microsoft. Being like McDonald’s it’s a case of careful what you wish for. Fragmentation isn’t good but then neither is something half baked. Powershells verbose way of doing things as can be seen is a pain in the a$$ you can work around it but after a while it becomes cumbersome. Not to mention that Ansible mixed with Terraform with a bit of Python sure might be a pain to get right at first but combined makes Powershell look average at best. Because like McDonald’s you’ll get great features but they’ll either be what’s expected or only enough for Microsoft to look competitive rather than them providing something that out does the competition in every way. Something which they are really not that good at doing.
Nice in linux powershell acts similar except the aliases are not there I had to build the aliases for ps and kill so I could use those commands in linux. That might be useful.
When you start passing complex objects down the pipeline and doing extremely complex stuff you come to realize how easy it can be compared to other shells Essentially, if you are an IT admin you got to know it
This is the quality of content that professors around the world should use as a benchmark. If they exceed this, wonderful but at least try to deliver legibility like this.
Thanks for another great and interesting vide, though a "Funny thing" happened to me when installing the "updated version" of the Powershell. Now I guess I must have "missed something", but to me everything looked if it was the same as in Your video, until I had installed the "7.26.." version. But after closing down my PowerShell (V.5.1,19041) and pressing the "Windows-key" and starting to type "pow" I now had 2 ""apps"" named "PowerShell"? One that was the "old PowerShell"(V.5.1.19...) which is installed in "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe". And the other one was the "New One", called "PowerShell 7 (x64)"(V.7.2.6) which had been installed in "C:\Program Files\PowerShell\7\pwsh.ex" Not that it directly "hurt anything" but it did surprise me somewhat...And I thought it might be worth mentioning, just in case it happens to someone else as well Best regards [[P.S, this happened 2022-09-08, running: Win10.Pro(64bit), V.21H2, Build:19044.1889]]
I've been learning PowerShell now for real as I developing on Windows so I needed something as good as Bash or Zsh and bash scripting language. Of course scripting can be replaced with python
am i missing something ... when i run the update method as described it all installs fine , but that creates a new powershell in a different directory alongside v 5. can i replace v 5 entirely ?
As far as I know, you can't. Windows PowerShell is default one installed on your PC. v5 is strictly Windows PowerShell, while v7 is Microsoft PowerShell (core), which has a lot of difference in term of features and cmdlets. Don't forget that there is some programs that relies on Windows PowerShell.
can anyone help - i did install as command shows then got usual pop windows of installation and yet later after shutting down and starting over powershell i still got old one. what i am doing wrong? maybe i should simply restart powershell not close it but i do not how.... Help please
I posted this below as a response but I’d very much like an answer to the question at the end so I reposted at the top. Powershell clearly has power. But it’s very specific, very verbose , and I’m never doing anything with out “SHOW-COMMAND” and “GET-COMMAND | OUT-GRIDVIEW” running in the background along with online documentation. Because you can’t just remember such a verbose language. It’s consistently is nice and occasionally elegant. Btw “show-command” is blocking. If anyone has a trick to make it non blocking I’d sincerely appreciate it. Because it means I have to open a second terminal just for that, I’ve tried start job and run process and similar, I need the “&” operator equivalent
Or I’d accept a version that does what both do- try both they look similar but slightly different things, show command is the more useful get-command is the better searcher
Powershell is amazingly powerful and occasionally elegant- but like literally everything Microstoft 10x more complicated than necessary- It’s also an incredibly verbose language. It’s a very precise language with minimal feedback. It has elements of sh and a good bit of Perl Syntax. I’ve spent a few years trying to get good at it and I’ve written several script-lets. It’s powerful for windows but it’s not friendly- beginner or otherwise I decided. I mean some of it is brilliant, but coercing object to the same general stereotype object is both intuitive and occasionally maddeningly absurd, coercing each commondlet to a verb-noun is brilliant but also sometimes absurd. It is , let’s be honest 1,000,000 times stronger than cmd, and sometimes you just need the cli to get to stuff not in the gui. Wish was an option- which ran vbscript and later JavaScript and now both. There’s batch scripting and when anyone writes a complicated batch script im so impressed I can’t speak. But it was powershell that won out. Wish is still there if you want to mess with it. Maybe , depending on your settings, because it became a popular way to install viruses And now it’s worse - it’s being updated! Monthly! Great- do the new cool rolling update thing- now I can be confused every month.
Sorry to say, then you only think that you have learned PowerShell but actually don’t know it $PS: Who was the authors of PowerShell? People that wanted to significantly improve on their old creation called… Bash (🎤 drop)
@Gary Explains *winget* is the SECOND "Linux Like" PACKAGE MANAGER for Windows my Good Gary 😁👍Friend (the FIRST one was *Chocolatey* and many of us STILL use it, and or both) Just Check the BUNCH of things Chris Titus Tech has done with PS in his YT channel and website (like the Win 10-11 *Debloat* PS scripts), PS can be incredibly _Usefull/Powerfull_ 😉✌ [and I FORGOT to say, he's a _LONGTIME Linux Server Guy_ ] GreeTs and G0D✝blessUall...!!!
When you do things at the very bottom of the screen, like type commands, they are hidden in the actual video if the mouse moves at all, or if you just clicked play. Very annoying feature of all web video players. Please don't do that.
Instead of trying to engineer this janky shell that’s trying to be as bash is to Linux, why not just replace the weird, creaky underpinnings of Windows with Linux and get the real thing?
PowerShell = Bash++ I assume a typical Linux guy that refuses to try it because it came from Microsoft that has never even tried it to realise that it is orders of magnitude more capable than Bash (Actually not even the same thing really). PS$: PowerShell was created years after Bash by the authors of Bash (Oops, mic 🎤 drop)
Since i'm a Linux ULTRA NooooooB 🤣🙃, I'm going let @Nico van Dyk do a Great job Explaining PS; _""PowerShell is actually the shell for .Net which makes it orders of magnitude more capable than Bash. You can access all .Net libraries and objects NATIVELY within PowerShell. So? Well, these libraries and objects are the exact same libraries/objects you can use in any .Net language like C#, Python, Ruby and yes, even C++. Do that in Bash… And no, that is not compiling a piece of code and the executing it; it is literally instantiating any .Net object from within PowerShell and interacting with it THROUGH A COMMAND LINE. The fact of using PowerShell as a OS command line (Like Bash/Command prompt) is kind of a side consequence of all OS commands being API calls. That is why everything in PowerShell is objects and the pipeline deals with objects (Not merely one-dimensional strings as is the case with bash)""_
Now now. It is insanely verbose and even if you use it in vscode the powershell linter complains if you use the alias commands. Which I hate. However if you work in or want to stay in the windows only world Powershell is an absolute Godsend.
PowerShell tab completion not only completes the command you've started, if give a few letters, it will cycle through every possible command that has those letters. If you pass up the one you want, goes in reverse order.
Tab completion also will give you a list of all possible switches. Type in the command, put in one white space then the followed by the and it will cycle all the possibilities. In in the old PowerShell ISE or newer ISE, you get a context menu to appear that you can select the switch needed from the list.
I put off PowerShell for the first few years, and only began to use it at the end of v2 with v3 coming out soon after I started learning. I absolutely love PowerShell for what you can get that isn't given (or not given easily) in Windows GUI.
Case in point, the FQDN of a network computer. Get-ADComputer -Identity ComputerName will return five or so lines of the most common information of a computer object from Active Directory, one of which shows the OU path to finding the computer in AD.
There is so much that can be done with simple commands in PowerShell. Once you learn a few, you will see how *most* can chain together via piping. I stress most, as some do no feed into other commands as one would hope or seem to expect.
Where PowerShell shines is in simple scripting with a ForEach stepping through a list of objects and performing some task. Continuing on from the previous example of Get-ADComputer, you can specify an OU, then feed the results into a Get-Win32 (or newer Get-Cim) and pull things like the serial number stored in the machines BIOS, how much RAM is installed, Hard Drive space total and free to build a CSV that can be imported into Excel to help determine what hardware may be reaching end of life or need upgrading.
The only limit to PowerShell is really our own limit to image what we can do with this tool.
Thanks for the info!
Hi Gary, Another great explanation. I grew up with CP/M, MS DOS and several varieties of Unix-based shell. Over the last 20 years I have only used PowerShell when I really needed to as it always seemed excessively complicated and verbose. However, if I had learned the tips you gave earlier maybe I would not have been so reluctant to use it.
I've always found dos/command prompt to be too limited and PowerShell to be too overly-verbose. But, to be fair, I trod the sh->csh->ksh->bash path over the past 25 or so years, so they've become the standard against which I measure.
All the same, your quick mini-tutorial really does explain useful PowerShell techniques a great deal, so thank you! 🐧👍
Yea I agree.
Powershell clearly has power. But it’s very specific, very verbose , and I’m never doing anything with out
“SHOW-COMMAND” and “GET-COMMAND | OUT-GRIDVIEW” running in the background along with online documentation. Because you can’t just remember such a verbose language. It’s consistently is nice and occasionally elegant.
Btw “show-command|out-gridview” is blocking. If anyone has a trick to make it non blocking I’d sincerely appreciate it. Because it means I have to open a second terminal just for that, I’ve tried start job and run process and similar, I need the “&” operator equivalent
Gary here are 5 real commands people should really know
1- Show-command
2- Get-command l out-gridview
3- Get-help “command-name”
Especially with the -examples flag
“Get-help invoke-command -examples “ ALSO use help for concepts "Get-Help -about_" note the "-" flag and "_' underscore, then just keep hitting tab.
4- set up PowerShell to be user friendly--
$global:DebugPreference = “Continue”
$InformationPreference = Continue
$VerbosePreference = Continue
This turns on a lot of feedback about whatPowershell is doing with each conmand or what’s wrong - really really helps learn, if you get sick of it change all three back to $InformationPreference= ‘SilentlyContinue’ -- *oddly continue requires no quotes but = ‘SilentlyContinue’ does *, other options are 'Stop' and "Inquire". For completeness there is also $ConfirmPreference and $WarningPreference with settings of None, Low, Medium and High. That will warn you if you might do something dangerous or foolish. No clue if it works well.
5- I put "$global:" in the first one intentionally. Obviously any variable has a dollarsign "$Variable". Try "$global:", "$env:" and even just "$" and hit tab to see whats already there and what settings are stored. Most all the settings are there somewhere. I think there are more prefixes to get to more but I cant recall them atm.
6-- Log everything you do in power shell so if you screw something up you can undo it
“Start-Transcript -OutputDirectory ‘c:\yourchoice\always quote if spaces\ ‘ "
7 Most import bit last- and this is a lot so go through it. Powershell everything is an object or a cmdlet (overgeneralized like any complicated thing but lets go with it)
Lets use files as an example- They are objects called "Items" - so are directories- more on that in a second. So, to see the files in the current directory we'd use "Get-ChildItem" This says get all the children files of this directory I am in. There are other Item commands Delete-Item, Move-Item, etc, see "Get-Alias to see more: which would also show us this common is also under "gci" and "dir" to match old command prompt. and especially check "Get-Command | Out-Gridview" to find other Item Modifying commands. Its usually where people start with powershell manipulating files.
7b-- You get a list back, powershell loves lists, and most things return lists. I couldnt do anything in powershell until I learned how to handle lists. Its critical. Now first- another trick -- try "Get-ChildItem -" or "gci -" with the "-" flag symbol, start hitting tab to see what flags that command might take. They vary a lot and are confusing. Especially filtering- check help this is too long already. But a simple few are -Directory -File and some others, This returns only the sub-directories. -Recurse is useful too. Short version, JUST USE TAB when stuck.
But we get our list of anything. We need to pick one from the list. Like I said most commands generate lists. For this we need "select" or "Select-Object" - again basics here, we can stick to "-Index {number}" or use -First or -Last. The thing that confused me forever is that First and Last also expect numbers. In my opinion it should default to 1, but it doesnt. so we say "$File = gci | select -First 1" Three things to notice, we didnt get any output when assigning to a variable. Type $File and youll get it. And 2, we used the critically important message passing character in powershell "|". Its really the powershell secret sauce, otherwise not just difficult but sorta pointless. 3- you got the second file not the first. This is because computers start with 0 usually.
If wed used "-First 5" wed have a new smaller list, If we used "$File = gci | select -First 0" or 1 tbf, now importantly we have selected a single object and can do things to it. There is a big difference to having a list and having an object in hand. You can treat lists sequentially or in parallel but this is 101 here.
So we need to see what we can do with the object. For that use "gm" or "get-member" and itll show you things you can get from it.
Properties you just use a dot. eg. "$File.Directory" tab works here to. we can also $File.MoveTo("C:\Users\me\myfilename"). Methods are harder. And in my case I copied a directory into a file, which is no doubt going to have odd outcomes. But thats enough for now
Ok those were my major stumbling blocks learning. I have a lot of notes I took for myself and myself alone - so forgive errors. I wrote most of it, but in other cases I blatantly copied from Microsoft Documentation or Stack Overflow. But Ill share it here. First though Ill Recommend the official doc, which after years of being horrible, all Microsoft Documentation has gotten quite good over the last decade.
Lovely video.
I used to script using DOS batch many moons ago.
Now fully immersed in PowerShell and love it, 😂
Yes, content like this is nice.
Thank you 🙏
shouldn't sl be aliased to steam-locomotive?
Thanks for a great video, please make more with Powershell.
Dude you haven't seen anything yet. Powershell is quite great in dealing with data and basic data-analysis. Lookup commands (Convertfrom-csv) and (out-gridview) and (convertfrom-json)
Its also quite powerful in the web API realm. (invoke-webrequest)
This is one of the biggest reasons that multiple Monitoring software often just default to utilizing Powershell scripts to get data and transform data.
It's one of those languages that is extremely powerful yet underappreciated despite the weight it carries in the monitoring world and corners of the data-analysis realm
And this is all before any modules and specialized packages are installed to aid in stuff
It is great for data analysis the problem is python got their first and is considered the gold standard. I do really like Powershell for Windows. Beyond that though I keep with Linux GNU Core utils and Python.
The great thing about pwsh is that it's not just a shell, it's a scripting language. There's so many times where you can just write 10 lines of pwsh instead of having to write an actual application. Especially with the likes of Azure functions.
Thanks for finally showing me how powershell is useful!
I have just been using as a cmd prompt replacement, but these examples alone are very useful for debugging.
I am going to start using cmdlets now, thanks for setting me on the path. 🙂
Hi Gary! So glad I watched the whole video! Thank you for the awesome simple content. I need to watch again and make some notes. Thank you for this lesson! 👍🙏
Glad it was helpful!
New PS learner here... THANKS! Really good!
Very enlightening, thank you!
Good things to know before learning: You MUST set your execution policy, start PS in admin mode, learn how to import modules so you can reach and administer objects like EXO and tape drives.
I love PowerShell. I maintain a huge 911 system (larger than some countries) and it helps me stay out of the news.
In my world, you fix things before they even fully break. PowerShell let's me see stuff.
YES! I LIKE YOU HENCE AM ALWAYS LEARNING SOMETHING NEW FROM YOU! STAY SAFE! ALWAYS LOVE!
Excellent! I could have learned this myself, if I wasn't such an idle dinosaur. However you have prompted me to look into this, install PS 7, observe that there's some interesting connection with Visual Code and resolve to look into SSH-ing from PS direct into a RPi rather than via PuTTY. Very educational!
Good job Gary. Powershell really is an acquired taste. It's so verbose, but I suppose in the right hands (not mine!!!) it can be very useful.
Thanks a lot, trying to follow along in the hopes that finally the PS commands keep sticking in my mind. But I have to say, getting the latest PS version with winget from the command line ... and then a _window_ pops up wanting acknowledging - this is _such_ a windows thing to do. And then closing the ps window and starting again - it still shows the old version???
Useful, thanks.
PowerShell is verbose, but have good gears to windows. In windows env I recommend use. But Nix universe is good stay with bash,Zsh , perl or python....
ssh and scp are shipped with Windows 10. They have nothing to do with PowersHell. You can run them from cmd too.
Most of these cases can be easily done in just CMD. The real killer feature of PS though is complex cases involving working with and passing data objects.
One easier manner to get what you last typed was to click on the Up Arrow or Down arrow button on the Keyboard. You can scroll thru the last commands you typed in.
Yeah, but you can even do that on the standard CMD prompt (and just about every Linux shell), nothing special about that.
This was fairly new to me. Was anyone else new to this surprised by the amount of processes running on their pc compared to Gary's? A lot of them were "svchost", had to look them up to see what they were about!
It's all the superfluous services running that each next Windows version just keeps ramping up. Got to eat the resources, or people won't have to upgrade the hardware as often!
PowerShell is useful; so I am not going to deny the need for PowerShell. However, it’s greatest strength is it’s greatest weakness. PowerShell used objects whereas Unix-like use a data stream. The great thing about objects is that it’s extremely easy to parse. The terrible thing about objects is that it makes “one-liners” near impossible. I find myself trying to type out a PowerShell command, stop, and then jump to a notepad to write a paragraph. Compare that with Unix-like, it takes me a one-line sentence. I do understand that parsing data in Unix-like can be difficult.
That aside, PowerShell is very difficult to find any good tutorials. It’s also limited to whatever “commands” are available created. It also gets confusing when C#/.Net code creeps it’s way into a script. It makes it harder to see what all is happening in a given script.
W.r.t. to doing something in one-line in “Unix-like” but not being able to do so in PowerShell: I suspect that is more a question of PowerShell skill. I certainly know of a number of scenarios that I can do in one line that is just impossible in “Unix-like”
@@nicovandyk3856 no he has a point consider free -h to get all of your cpu and ram usage in linux. For Powershell if you want to see anything other than bytes you use the math object and set an expression. Not the same. But I will say Powershell has some excellent advanced features such as pulling data into a custom object and then outputting it to html for example with a one line command. Its also great when combined with PowerBi. But look my issue is there are already many tools in the Linux space that when combined give you waaay more control. Powershell is very useful but mainly if you want to confine yourself to dotnet and windows only.
@@williamevans6830 : Thanks! But do know PowerShell is available on Linux/Mac so you need not be confined to the Windows eco-system 😉 As for the numerous tools that exist in Lin/Unix - I sincerely see that more as a problem than anything (Not trying to flame/be wise-a$$ at all). Each of these are little independent programs of their own instead of an extendable library which is more API like, like is case with PowerShell. This API-like/library approach means that there is much more enforcement of standardization than was the case is ye-olden-days when Unix/POSIX was established. In those days everyone did things their own way and standardization more of a opt-in kinda thing - and still is to a large extent in Bash today. I mean, it is much easier for me to write my own compiled console app that works completely different from the rest of the Unix eco-system whereas it is much more difficult to do so in PowerShell where it is just much easier to stick to the standard (I worked in both btw)
@@nicovandyk3856 for these arguments I keep coming back to what Steve Jobs said about Microsoft. Being like McDonald’s it’s a case of careful what you wish for. Fragmentation isn’t good but then neither is something half baked. Powershells verbose way of doing things as can be seen is a pain in the a$$ you can work around it but after a while it becomes cumbersome. Not to mention that Ansible mixed with Terraform with a bit of Python sure might be a pain to get right at first but combined makes Powershell look average at best. Because like McDonald’s you’ll get great features but they’ll either be what’s expected or only enough for Microsoft to look competitive rather than them providing something that out does the competition in every way. Something which they are really not that good at doing.
I agree with Nico, in PowerShell we call it pipelining and it's super powerful.
Nice in linux powershell acts similar except the aliases are not there I had to build the aliases for ps and kill so I could use those commands in linux.
That might be useful.
They still haven't implemented the AD PS functions brought in by the RSAT tools when running core under linux. A real PITA
When you start passing complex objects down the pipeline and doing extremely complex stuff you come to realize how easy it can be compared to other shells
Essentially, if you are an IT admin you got to know it
You do say some amusing things Gary, "You may get to like Windows..."
This is the quality of content that professors around the world should use as a benchmark. If they exceed this, wonderful but at least try to deliver legibility like this.
this is such an enjoyable video!!!
Glad you enjoyed it!
Thanks for another great and interesting vide, though a "Funny thing" happened to me when installing the "updated version" of the Powershell.
Now I guess I must have "missed something", but to me everything looked if it was the same as in Your video, until I had installed the "7.26.." version.
But after closing down my PowerShell (V.5.1,19041) and pressing the "Windows-key" and starting to type "pow" I now had 2 ""apps"" named "PowerShell"?
One that was the "old PowerShell"(V.5.1.19...) which is installed in "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe".
And the other one was the "New One", called "PowerShell 7 (x64)"(V.7.2.6) which had been installed in "C:\Program Files\PowerShell\7\pwsh.ex"
Not that it directly "hurt anything" but it did surprise me somewhat...And I thought it might be worth mentioning, just in case it happens to someone else as well
Best regards
[[P.S, this happened 2022-09-08, running: Win10.Pro(64bit), V.21H2, Build:19044.1889]]
@Gary Explains Analysis on the A16 please 🙏
I've never been able to get into it just because the .Net libraries are so large, so without Intellisense it's super hard to write commands.
I've been learning PowerShell now for real as I developing on Windows so I needed something as good as Bash or Zsh and bash scripting language. Of course scripting can be replaced with python
Wow i didn't know 1 day I'll say this but. Powershell look kind of good!
ihy has an alias of 'r' (without quotes). Makes it even easier
How to install Emacs? Can that be done through winget?
Great ! TA !
pwsh is amazing
Interesting how some people value short commands and some others value commands that are easy to read and understand
Strange, PSVersionTable does not work in powershell anymore. At least not on my 7.4
I just join your channel.. would like to see windows powershell lessons
am i missing something ... when i run the update method as described it all installs fine , but that creates a new powershell in a different directory alongside v 5. can i replace v 5 entirely ?
As far as I know, you can't. Windows PowerShell is default one installed on your PC. v5 is strictly Windows PowerShell, while v7 is Microsoft PowerShell (core), which has a lot of difference in term of features and cmdlets.
Don't forget that there is some programs that relies on Windows PowerShell.
can anyone help - i did install as command shows then got usual pop windows of installation and yet later after shutting down and starting over powershell i still got old one. what i am doing wrong? maybe i should simply restart powershell not close it but i do not how....
Help please
The new one has a different name. You need to launch "PowerShell 7".
It's a much better cmd, indeed. But even the last time I use Windows, I install and use MSYS instead.
What’s msys
Nice
aren't "cd" and "mkdir" bash commands?
Yes, and they are also MS-DOS commands, Windows CMD commands, and PowerShell commands.
I posted this below as a response but I’d very much like an answer to the question at the end so I reposted at the top.
Powershell clearly has power. But it’s very specific, very verbose , and I’m never doing anything with out
“SHOW-COMMAND” and “GET-COMMAND | OUT-GRIDVIEW” running in the background along with online documentation. Because you can’t just remember such a verbose language. It’s consistently is nice and occasionally elegant.
Btw “show-command” is blocking. If anyone has a trick to make it non blocking I’d sincerely appreciate it. Because it means I have to open a second terminal just for that, I’ve tried start job and run process and similar, I need the “&” operator equivalent
It needs to drop me back into the exact terminal I was in. No starting new instances after - I may have set up variables
Or I’d accept a version that does what both do- try both they look similar but slightly different things, show command is the more useful get-command is the better searcher
Powershell is amazingly powerful and occasionally elegant- but like literally everything Microstoft 10x more complicated than necessary- It’s also an incredibly verbose language. It’s a very precise language with minimal feedback. It has elements of sh and a good bit of Perl Syntax.
I’ve spent a few years trying to get good at it and I’ve written several script-lets. It’s powerful for windows but it’s not friendly- beginner or otherwise I decided. I mean some of it is brilliant, but coercing object to the same general stereotype object is both intuitive and occasionally maddeningly absurd, coercing each commondlet to a verb-noun is brilliant but also sometimes absurd.
It is , let’s be honest 1,000,000 times stronger than cmd, and sometimes you just need the cli to get to stuff not in the gui. Wish was an option- which ran vbscript and later JavaScript and now both. There’s batch scripting and when anyone writes a complicated batch script im so impressed I can’t speak. But it was powershell that won out. Wish is still there if you want to mess with it. Maybe , depending on your settings, because it became a popular way to install viruses
And now it’s worse - it’s being updated! Monthly! Great- do the new cool rolling update thing- now I can be confused every month.
So the new version of PowerShell is no longer only on Windows it is also on Linux and Mac os.
Indeed.
As Oliver said, "More, please sir".
I don't know why I am watching this. I only have Linux PC's. Still watching though.
Because PowerShell is available on Linux
Give powertype a try (I'm the creator)
I learned PowerShell just to find out that Bash is king. Sorry.
Sorry to say, then you only think that you have learned PowerShell but actually don’t know it
$PS: Who was the authors of PowerShell? People that wanted to significantly improve on their old creation called… Bash (🎤 drop)
@@nicovandyk3856I thought bash was designed for Linux and pwsh for Windows?
Azure Cloud also offers both Bash and Powershell in the CLI it’s pretty cool.
SSH keys
How to bash, Poweshelll… mic drop
I only ever use PowerShell to remove uninstallable apps from Windows.
@Gary Explains *winget* is the SECOND "Linux Like" PACKAGE MANAGER for Windows my Good Gary 😁👍Friend (the FIRST one was *Chocolatey* and many of us STILL use it, and or both)
Just Check the BUNCH of things Chris Titus Tech has done with PS in his YT channel and website (like the Win 10-11 *Debloat* PS scripts), PS can be incredibly _Usefull/Powerfull_ 😉✌ [and I FORGOT to say, he's a _LONGTIME Linux Server Guy_ ]
GreeTs and G0D✝blessUall...!!!
Smells like SPAM.
@@virtuallifeform Noooooo, Smells like NIRVANA (Teen Spirit) 😂🤣😜
When you do things at the very bottom of the screen, like type commands, they are hidden in the actual video if the mouse moves at all, or if you just clicked play. Very annoying feature of all web video players. Please don't do that.
Command aliases is a saving grace for the PowerShell. Now, if it wasn't such a slow and bloated piece of software...
First. Can i get a pin? 😃
No.
@@0deepak fine, i'm unsubscribing
Lol😂😂 power shell is quite powerful compared to cmd
Instead of trying to engineer this janky shell that’s trying to be as bash is to Linux, why not just replace the weird, creaky underpinnings of Windows with Linux and get the real thing?
That is a bit of a leap from a shell to the whole internals of Windows. Wow.
Or use PowerShell Core on Linux and run it from bash on the real thing but with proper object support so you can have the best of all worlds?
Step one: dont. Learn Linux bash instead.
PowerShell = Bash++
I assume a typical Linux guy that refuses to try it because it came from Microsoft that has never even tried it to realise that it is orders of magnitude more capable than Bash (Actually not even the same thing really).
PS$: PowerShell was created years after Bash by the authors of Bash (Oops, mic 🎤 drop)
Learn both.
Since i'm a Linux ULTRA NooooooB 🤣🙃, I'm going let @Nico van Dyk do a Great job Explaining PS;
_""PowerShell is actually the shell for .Net which makes it orders of magnitude more capable than Bash. You can access all .Net libraries and objects NATIVELY within PowerShell. So? Well, these libraries and objects are the exact same libraries/objects you can use in any .Net language like C#, Python, Ruby and yes, even C++. Do that in Bash… And no, that is not compiling a piece of code and the executing it; it is literally instantiating any .Net object from within PowerShell and interacting with it THROUGH A COMMAND LINE. The fact of using PowerShell as a OS command line (Like Bash/Command prompt) is kind of a side consequence of all OS commands being API calls. That is why everything in PowerShell is objects and the pipeline deals with objects (Not merely one-dimensional strings as is the case with bash)""_
where are your ears?
Eh?
Powershell is pure complicated garbage 🗑️🚮
Now now. It is insanely verbose and even if you use it in vscode the powershell linter complains if you use the alias commands. Which I hate. However if you work in or want to stay in the windows only world Powershell is an absolute Godsend.
Point and click for you then 🤣
Powershell is for getting stuff done at scale, if you can't understand it you probably shouldn't be doing it.
Microsoft tried to copy Unix shell
@@anjanbora7943 it's not even remotely close to bash, CMD and bash in the same league. Powershell is completely different
6:45 I just use
taskkill /f /im notepad.exe