04.04.2019 - Recommended, TECHNICAL

Ironstone and Automation, Open Source, and PowerShell

Here at Ironstone automation plays a huge role in our work. Without automation there is no way we could be only 7 (!) people in the Operations team and manage the sheer quantity of tasks that we deal with every day.

In this context, automation is about creating tools using script, code, or existing automation solutions that make us do repetitive tasks in batch, often at schedules. A common task is creating Azure AD users based on data found in an Excel sheet.

 

PowerShell

In the world of Microsoft, automation is synonymous with PowerShell. Most of our automation is PowerShell. We use it for task like:

  • Azure Automation:
    - Various tasks with Azure Resources, like auto shutdown of VMs
    - Integrations between Microsoft and our 3rd party tools
  • Intune MDM, for doing things that Intune is not yet capable of.
  • Azure:
    - Automatic assessments for migration and similar operations
    - Deploying and doing various tasks regarding resources in Azure
    - Creating dynamic NSGs based on variable input
    - Generating custom dashboards, like our open source Printix Dashboard based on PowerShell and Power BI
  • Locally on our computers, for: 
    - Automatic install, update, removal of PowerShell updates
    - Automatic lossless compression of all image files on our Plex Server
    - Changing DNS and other network settings across all NICs

This is just a small list of examples of what we use PowerShell and automation for.

 

Open Source

As mentioned in previous section, we share some of our work around automation with the rest of the world. We understand and appreciate the power and possibilities of Open Source. We couldn't have done half of the things we do with automation and PowerShell if we didn’t have any source of inspiration and community. That’s why we also want to share some of our work for others to enjoy.

We've already shared our Printix Dashboard based on PowerShell and Power BI, made in cooperation with Printix. It's available here: https://github.com/printix/Power-BI.

 

Ironstone's "PowerShellModulesUpdater"

Today we want to share a new script with you. Our PowerShell guy has created this script around maintaining PowerShell modules on his local Windows 10 based workstation.

You can get it here: https://github.com/o-l-a-v/PowerShell-Projects/blob/master/PowerShellModulesUpdater/PowerShellModulesUpdater.ps1.

 

Disclaimer

This script comes with no guaranties. You are responsible for what you do on your computer. Ironstone and the script creator are NOT responsible for any damage it may cause.

 

Background

Ever since the script creator, yours truly, started at Ironstone in November 2017, I found that manually installing, updating, and removing obsolete or outdated PowerShell modules was a hassle. I started by creating a script for updating already installed PowerShell modules. It soon acquired more features, like:

  • Uninstall unwanted modules, given by an input variable.
  • Install wanted modules if not already installed, given by an input variable.
  • Uninstall outdated modules, if more than one version of a module is installed.

The PowerShell script had suddenly grown from a couple of lines to more than 400. My coding style and preferences had changed multiple times during these 1.5 years, and on Saturday March 9, I decided to rewrite the whole thing. The result is a (subjectively) tidy, customizable, useful, and time saving script. Everyone doing PowerShell inside Ironstone is using it, and from today, others can enjoy it too.

This is a perfect example of how PowerShell and Automation can help us in doing what would have been a very time consuming task prone to human errors.

 

License

This script is licensed under MIT. You are free to use, reuse, and distribute the code, but please make sure to credit the source.

 

User Guide

In short, all you need to do is:

  • View the script as Raw in GitHub, save it as "PowerShellModulesUpdater.ps1".
  • Open "PowerShell ISE" in 64 bit as admin. This program is preinstalled on all Windows clients from Windows 7 and up, at least.
  • Press play to run the script.

 Make sure to modify options for:

  • Install modules
    - Should the script install new modules? Controlled by the boolean "$InstallMissingModules"
    - What modules to you want to have installed on your system? Edit the string array "$ModulesWanted"
  • Update Installed modules
    - Should the script update installed modules? Controlled by the boolean "$InstallUpdatedModules"
  • Uninstall outdated modules
    - Should the script uninstall outdated modules? Controlled by the boolean " $UninstallOutdatedModules"
  • Uninstall unwanted modules
    - Should the script uninstall unwanted modules? Like "AzureRM", which has been replaced by "Az"? Controlled by the boolean "$UninstallUnwantedModules".
    - What modules you want removed is set in the string array "$ModulesUnwanted".

By default, all the booleans are set to $true and variables containing modules to install and uninstall will give you an environment ready for most tasks, which include interfering with Azure, Azure AD and more.

 

Final Thoughts

If you find any issues, or have ideas of how to improve the script, feel free to create issues on GitHub. If you want us to help you create automation for a task you want automated, feel free to contact  us!

 

Don't miss a single update

Subscribe to our newsletter