powershell

Want to become a maintainer of PowervRA or PowervRO?

When Craig and I first created PowervRA and PowervRO in 2016 we only initially thought about using them for our own purposes, since we were on a project at the time which required heavy use of automation around vRA and vRO. When we decided to put them out into the community we never expected them to become as popular as they have done. It was a fun experience for us, both in learning about collaborating, developing and releasing a PowerShell module, and the benefits it was bringing to our own jobs.

Ansible, Windows and PowerShell: the Basics – Part 8, Rebooting & Waiting

In Part 8 of this series we’ll continue our journey with Ansible, Windows and PowerShell and look at how to handle reboots. Despite improvements in Windows over the years, it’s still pretty common as part of VM or application deployment to need to restart the VM and wait for it to be available before carrying on with some further steps. The following example will demonstrate how to use the win_reboot and win_wait_for modules to reboot a VM and wait for the RDP port 3389 to be available before carrying on.

Ansible, Windows and PowerShell: the Basics – Part 7, Utilising PowerShell DSC

In Part 7 of this series we’ll continue our journey with Ansible, Windows and PowerShell and look at how utilise PowerShell DSC. If you or your team already own some automation created using PowerShell DSC then it is possible to re-use that via an Ansible Playbook. Or maybe you think that you or they would prefer to create configuration automation going forward using a perhaps more familiar PowerShell DSC, then this could be a solution for you.

Ansible, Windows and PowerShell: the Basics – Part 6, Displaying Output from PowerShell Code

In Part 6 of this series we’ll continue our journey with Ansible, Windows and PowerShell and look at how we can display output from code in PowerShell scripts back in Ansible to help track the progress of a task. The following example will demonstrate how to send log info from a PowerShell script back to Ansible. Our job template in AWX is _5_log-output The contents of _5_log-output.yml are are follows:

Ansible, Windows and PowerShell: the Basics – Part 5, Example PowerShell Error Handling

In Part 5 of this series we’ll continue our journey with Ansible, Windows and PowerShell and look at how we can lay out code in PowerShell scripts in order to return error codes to Ansible to determine the success or failure of a task. In my experience different automation and orchestration toolsets can require you to return errors from PowerShell scripts in different ways. So far with Ansible I have found that returning an exit code of 0 (success) or 1 (failure) from the PowerShell script to Ansible will result in the success or failure of that task in the Playbook.

Ansible, Windows and PowerShell: the Basics – Part 4, Invoking PowerShell Code

In Part 4 of this series we’ll continue our journey with Ansible, Windows and PowerShell and look at how we can use Ansible to invoke PowerShell code directly. Our job template in AWX to test out the possible different scenarios is _3_invoke-powershell The contents of _3_invoke-powershell.yml are are follows: There are three main options we can take for approaching invoking PowerShell code, all using the win_shell module in some form.

Ansible, Windows and PowerShell: the Basics – Part 3, Windows Roles and Features

In Part 3 of this series we’ll continue our journey with Ansible, Windows and PowerShell and look at how we can use Ansible to prepare servers with Windows Roles and Features. The PowerShell story around support for Windows Roles and Features can be a little confusing, since there are two different sets of PowerShell cmdlets as well as the cmdline tools dism.exe and pkgmgr.exe. So knowing which tool to use to start with requires some effort itself.

Ansible, Windows and PowerShell: the Basics - Part 2, Install PowerShell Modules

In Part 2 of this series we’ll move on from the introductory topics and look at how we can use Ansible to prepare servers with any external PowerShell Modules they need from the PowerShell Gallery. Our job template in AWX is _1_install-psmodule The contents of _1_install-psmodule.yml are are follows: We can use the native Ansible module win_psmodule to do the work for us. In addition, we can ensure multiple modules are installed without needing a separate task for each one by looping using with_items.

Ansible, Windows and PowerShell: the Basics - Part 1, Windows Services

In Part 1 of this series we’ll warm up by taking a look at the lab setup I am using, configuring some basics in AWX and what’s possible with the Ansible win_service module to configure Windows services. Lab details: For Ansible, I’m using AWX deployed in containers based from the example documented here. Additionally, I have two Windows 2016 VMs. One to provide some basic Windows services such as DNS and Active Directory.

Ansible, Windows and PowerShell: the Basics - Introduction

Back in June of this year I presented a session at PowerShell Southampton on using Ansible and PowerShell together. There was a fair amount of interest in this topic both at the event and online afterwards, so I decided to follow it up here with a series of posts looking at the basics for someone getting started with Ansible. In particular using it to automate and configure Windows, where to use PowerShell for that task and sometimes where not to if there is native functionality already available within Ansible.