MENU

Fun & Interesting

Learn PowerShell: Episode 2, Going Further

ABMedia 28,841 4 years ago
Video Not Working? Fix It Now

In this video, we're going to dig deeper into PowerShell and how to continue to take advantage of its capabilities. This video seamlessly flows on from the last to continue to enhance your knowledge in PowerShell and allow you to take advantage of it more. This video starts by explaining the unique file capabilities PowerShell has and the "PSDrive" system it uses to provide access to all files. The drive system in PowerShell allows you to explore many other parts of the system just like they were files and directories. This means you can continue to use commands such as "cd" (Set-Location), "ls" (Get-ChildItem) etc. in other parts of the system. For example, on a Windows machine, you may be able to explore the registry directly from PowerShell, and access everything in there as if the keys were directories and the entries were files. As this video progresses, we start to dig into commands. The idea of what commands are and how they are structured internally is a very useful thing that this video touches on. It also describes parameters, which are also known as arguments, and how they are important and are used to use commands. Parameters also exist in other command lines and as such not much is necessary here, however, this video does have a strong emphasis on the parts of parameters that are unique to PowerShell, so that you can learn how to fully use the commands available in PowerShell. As a part of this unique exploration, we'll look at the "Get-Help" command and how it can be used to get a listing of the parameters available on a given command and their names and the like that can be used to provide to them all the details needed. This will be demonstrated with a custom hypothetical command called "Subscribe-Channel" that accepts two parameters imagines you subscribing to a channel, with you providing a "ChannelName" and "NotificationLevel". In addition, this video will cover the parameter-based alternative to "Where" and how you can use bash-like syntax to achieve similar things in PowerShell. This allows you to use things that are less formal and standard than "Where", allowing faster use of PowerShell to achieve things. We purposefully left the formal "Where" out of Episode 1 to keep the episode focused on the central, cross-command mechanisms used. However, in this video, it was possible to finally explore these concepts in more detail and discover how things can be shortened used more command-specific parameters. After that, the video will take a dive into how you can discover commands. Firstly, command names are logical and easy to discover, unlike most other command-lines which have commands such as "htop" in them. Secondly, Tab can be used to help discover commands simply by writing the beginning part. This is also a feature in other command lines and as such as not fully expanded on. But, most importantly, it's possible to discover a command simply by writing any specific keyword that may be present and immediately find it. As this gets introduced, the ability to use "-like" in a "Where" clause as well as a specific parameter on "Get-Command" allow you to very quickly search for any command by a keyword, such as searching for a command that has "user" in the name, in an attempt to find all of the local users on the system. This can be done using wildcards, which are very briefly touched on but not explained too deeply as they are present in other command lines. Finally, we take a look at the general internal structure of PowerShell and how everything is linked together. There is the CLR (Core Language Runtime) at the very core, providing a solid foundation that the object system of PowerShell is built upon. Then, there is .NET which adds important and critical objects to the CLR for day-to-day activities. On top of this are "libraries", which extends .NET with their own custom objects and code, as well as PowerShell itself, which extends .NET with PowerShell objects and commands. Finally, there are "PowerShell Modules", which will be covered more in-depth in the future, and will allow you to extend PowerShell and make your own commands and the like, allowing for a much more powerful and extendable experience. Chapters: 0:00 Folder Navigation 1:55 Aliases 2:35 PS Drives 5:00 What are commands? 7:05 What are parameters? 9:55 Discovering Parameters 10:55 Non-standard Filtering 13:00 Discovering Commands 18:00 Internal Structure Thanks for watching our video, before are some general ABMedia links if you are interested: Website ► https://abco.live/ Discord ► https://abco.live/discord The Discord server is a place to chat with the creator of this video, as well as anyone who contributed to its development and has helped support ABWorld over the years. A huge thank you goes to @ndumiphotos (on Instagram) for the graphics used in the intro. #learnpowershell #powershell #programming

Comment