From the course: Windows Server 2019 Essential Training

PowerShell - Server Tutorial

From the course: Windows Server 2019 Essential Training

Start my 1-month free trial

PowerShell

- [Instructor] In the October 2009 issue of TechNet magazine a senior consultant working for Microsoft wrote. "It's safe to say that the single most important skill, "a Windows administrator will need in the coming years "is proficiency with Windows PowerShell." during the early preview phases of Windows Server 2019, the online magazine Network World described it as a surprise that Server 2019 even had a GUI. Windows Server 2008 was the first to introduce a Windows Server with no Windows and every version since has included a version to install without the desktop experience. They called it Windows Server Core. In Windows Server 2016, the ability to switch back and forth between having a desktop and not was removed. Then when people started installing a preview of the semi-annual releases of Windows Server. They noticed that desktop experience was no longer an option it seems pretty clear that if anyone was waiting for a clear sign that it was time to learn PowerShell that writing is on the wall. PowerShell is made up of two different parts, first and foremost PowerShell is a scripting language. Microsoft provides cmdlets, functions, and scripts. To perform pretty much any management or administration task on Windows workstations and servers. Add to that, the growing community of admins that are constantly adding to the repositories and galleries of downloadable add-ons to PowerShell. For an even more customized experience, you can create your own functions and scripts and automate the various tasks that you have to do while administering your Windows servers The second part of PowerShell is an application, that you can use to run your PowerShell cmdlets, functions, and scripts. There is a command based shell specifically for running PowerShell, and there's also an interactive developers environment, PowerShell ISE that allows you to create and test functions and scripts. With an even more robust set of help and support. Here we are back on our Windows 2019 Server, that we installed and configured at the very beginning of the course, here I'm going to open PowerShell and I make a habit when I am setting up a new machine. Server or workstation, that has a desktop experience of pinning PowerShell to the taskbar. So I'm going to go head and click on the Start menu right click on Windows PowerShell, and under the More command, I'm going to go ahead and pin that to the taskbar, so that I have easy access to it later on. Let me go ahead and close the Start menu and now any time I run PowerShell I right click it and choose Run as Administrator. Even if I'm using ISE, which is the more supportive developer environment, I still choose to run it as administrator to make sure that I have the access that I need. To run scripts, and to access various system components on this server. But for now I'm just going to run PowerShell not the developer environment. I'm going to select to run it as an administrator. Once again, already being logged in as administrator that extra step may be unnecessary. But it's just a good habit to get into. I introduced the basic syntax of a PowerShell cmdlet when we renamed this computer, and Powershell has a command memory. So I'm going to up arrow twice just to once again review that cmdlet, the syntax in PowerShell is verb hyphen noun, that is the cmdlet. That is the start of our expression, any parameters start with hyphen and then the name of the parameter followed by whatever the value may be. If the value includes any spaces or any punctuation that might be confused for part of another command, or value or other expression then I could include this value in quotation marks, and you can use single quotation marks for things that only include spaces. Or double quotation marks for anything that could be confusing to Windows later on. There are a lot of cmdlets readily available to me. In fact if I were to just type Get-Command, I'm going to get a list that is several screens long of things that are already built in that I can use on this machine. But sometimes there's functionality that we want, that isn't included, say for example, I'd like cmdlets that will help me manage Azure components. If I were to go ahead and clear the screen, just to get a little more real estate here. I could type Get-Command and I could go ahead and put a wildcard in here, show me what I have available that has the word Azure in the command and there's the entire list, there's nothing. If I want to go and pull an entire collection of Azure commands, I can do that. I can install a module, now a module is a complete collection of cmdlets, functions, and scripts that have been put together either by Microsoft or by some other contributor in the community, and there's a huge repository of them at GitHub. If I type Install-Module and I put the the AzureAD module and don't specify where it's coming from, it's going to look at that GitHub repository, and since I've never installed modules on this machine before, I'm prompted to install PowerShellGet. Which is a tool that is used to go out and retrieve these various packages. I'm going to go ahead and say yes, I want to install that, and it will go ahead and check it out. Download it, install it, and then it will come back around to asking me about AzureAD. That's not a module that it was already familiar with, it's in a repository called PSGallery and I'm being asked whether or not it's okay to install this module. I'm going to go ahead and say yes and it will download and install this module full of Azure Active Directory, cmdlets, functions, and scripts. It seems to have run okay, let me go ahead and clear the screen one more time, and let's now take a look at what commands we have that have the word Azure somewhere in the command. This is one of the simplest ways to add to the functionality of your machine, using PowerShell. There are modules put together by Microsoft, as well as administrators and developers from all around the world that have shared what they've created. To make it so that you don't have to create everything from start. Windows PowerShell is a highly customizable, and highly powerful possibly the most useful management and administration tool available to you on any Windows server or workstation.

Contents