/Managing Azure via PowerShell

Managing Azure via PowerShell

 

Command lines and scripting skills are an important part of being an administrator with Azure.

Now there are ways of accessing your resources with an Azure with command lines.

One is Power Shell and the other is called CLI, which sometimes people called Bash as well.

Also A very important part of being an administrator is being able to simplify tasks, be able to repeat tasks, using a script.

If you want to create a Virtual Machine or create a user or to perform some reliable task, you might want to automate that tasks other than doing

similar works each time. You can do this using scripts very easily.

We’re all human. We all make mistakes. Advantage is using scripts is you can reduce errors when you do things repetitively.

Let’s talks about the PowerShell, The latest version of the PowerShell is version 7 (at the movement). Power Shell app has already installed in your Windows machine.

You can check the version with this command,

So my current version is version 5.1

So the first things you want to do is get the latest version.

The latest version of Power Shell is called Power Shell seven, and it is a cross platform version of Power Shell.

So no matter what operating system you have, you can find a Power Shell seven for your desktop.

Now need to install latest Power Shell on your computer, you’re need to download install a recent version of it.

We can find it from GitHub repository.

https://github.com/PowerShell/PowerShell

Now I go to the tags,

 

And now I select the latest version

No matter what system you have, that can be Linux Microsoft or Mac, there’s a package here for you.

Here, I run a 64 bit version of Windows, and so the version I use is the X64 for my package.

Now I download that and install it, and then I’ll get the most recent version of Power Shell on my system.

So I’m going to click on the MSI package here, and will go through the installer steps

 

Now, Power Shell should be inside of my system and I’m going go into the windows a menu in order to get it.

So let’s run this, run this as an administrator.

And also here I again verify my PowerShell version.

Now it’s time to install azure command module for the powershell.

By default, you’re not going to have any of the Azure commands installed.

You actually need to install the AZ module in order to work with this.

 

Install-Module -Name Az -AllowClobber -Force

When we install the Azure module into Power Shell we have to provide 2 properties.

One is allow Clobber. This is what’s going to allow the installation to overwrite some existing files.

And then the second command is slash force. This allows if you already have the AZ module

installed on your system, then you’re going force it to allow it to have two versions.

Now I can check the Azure module information

This show me versions of the AZ modules that I have installed.

So now I am going to connect with Azure using the PowerShell, before I run any command first I need to connect with Azure using the command,

and then I need to authenticate.

Now, Power Shell is going to show me, having logged in, it recognizes me, it has my subscription.

In my azure account currently I am running one VM,

Now when I say get VM, it’s going to go and find any Virtual Machine that I have on my account.

So this will show me VM that I have running against my account, and so now we know that this is a successful installation of

Power Shell installation of the AZ module connecting to my Azure account.

Now you can run any PowerShell scripts or command with this console to manage the Azure resources.

 

 572 total views,  2 views today