<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1678611822423757&amp;ev=PageView&amp;noscript=1">

Leveraging PowerShell Automation in the Cloud

Adam Bertram| October 15 2016

| security

powershell-automation-cloud

As part of this cloud transition, it's important to realize that even though you can't see a system it still needs to be managed. Let's talk about PowerShell automation.

These days, just about every CIO, IT manager and IT professional has his head in the cloud. Organizations have found that offloading various utilitarian services to the cloud allows them to focus more on delivering business value rather than just keeping the lights on. 

When deploying services to the cloud, whether it be a simple Infrastructure as a Service (IaaS) offering or Platform as a Service (PaaS), companies still need to focus on automation. Microsoft, Amazon and Google offload a lot of work but not everything. Let's focus on one way to manage resources in the cloud with PowerShell.Related Article: PowerShell Scripting and Open Management Infrastructure (OMI)

Most (if not all) cloud vendors support PowerShell to manage their services. They do this by providing PowerShell modules which are built to interact with their underlying APIs. Companies like Microsoft, Amazon and Google all have PowerShell modules. They provide these modules because many IT professionals use PowerShell to automate tasks in their organizations.

Getting started with PowerShell automation in the cloud is easy. Let's briefly cover what it takes to get a PowerShell module for each cloud vendor downloaded, installed and working for each of these major cloud vendors.

Microsoft and PowerShell

We'll start off with Microsoft. As you might expect, Microsoft's Azure cloud offering has a robust PowerShell module to do just about anything in Azure. The easiest way to download the AzureRM (Resource Manager) PowerShell module is to use the Install-Module cmdlets. Once run, PowerShellGet will find all the module dependencies and get everything set up for you.

Find-Module AzureRm | Install-Module

PowerShell

Once all modules have been downloaded, you'll then need to authenticate to Azure by running the Login-AzureRMAccount cmdlet. This will prompt to provide credentials and, once complete, you'll have access to your Azure subscription.

PowerShell

Amazon AWS and PowerShell

Amazon provides their PowerShell module via an MSI software installer. This requires downloading and installing outside of PowerShell. Once you've run the installer and accepted all the defaults, Amazon AWS Tools for PowerShell is installed. This will install a PowerShell module called AWSPowerShell.

Related Article: The PowerShell Script Orchestrator

The next step is to authenticate to your AWS account. You'll do this by using the Set-AWSCredentials command. However, you'll need to know an access key and secret key. If this is the first time using PowerShell to access AWS, the keys will have to be generated. To either generate or find existing keys, log into the AWS management console and go to My Account --> Security Credentials.

You will then see an area called Access Keys were these two values can be found. If you don't know your secret access key, you'll have to create another. Once you have these two values, run the Set-AWSCredentials command to save them.

Set-AwsCredentials -AccessKey XXXXXXX -SecretKey XXXXXX

Now you have everything you need to authenticate to your AWS account. At this point, you can run the various commands that come as part of the AWSPowerShell module.

Related Article: Advanced PowerShell Functions: Upping Your Game

Google and PowerShell

Finally, there's Google. To manage the Google cloud from PowerShell, download and install Cloud Tools for PowerShell. Once downloaded and installed, you'll now have all the Google Cloud PowerShell commands available. Once installation has completed, the gcloud init command will run and prompt for your Google credentials. Once this command has completed, you're ready to manage the Google Cloud platform.

Wrap Up

We only had time to get each PowerShell module downloaded and installed. However, at this point, you should now be connected to all three cloud services and ready to explore! As you've seen, all the major cloud vendors offer PowerShell support. Using PowerShell to automate cloud tasks allows you to combine cloud automation with many other common tasks that you and your team are already automating.

If your cloud vendor wasn't covered here, chances are they still have PowerShell support. Simply search for their name and PowerShell and it's likely they or the community has developed a project around PowerShell.

New Call-to-action

 

Topics: security

Leave a Reply

Your email address will not be published. Required fields are marked *

THIS POST WAS WRITTEN BY Adam Bertram

Adam Bertram is a 20-year veteran of IT. He’s currently an automation engineer, blogger, independent consultant, freelance writer, author, and trainer. Adam focuses on DevOps, system management, and automation technologies as well as various cloud platforms. He is a Microsoft Cloud and Datacenter Management MVP and efficiency nerd that enjoys teaching others a better way to leverage automation.

Free Trials

Getting started has never been easier. Download a trial today.

Download Free Trials

Contact Us

Let us know how we can help you. Focus on what matters. 

Send us a note

Subscribe to our Blog

Let’s stay in touch! Register to receive our blog updates.