Skip to main content


Showing posts from 2019

Powershell Cmdlet from which module?

Powershell is pretty much the scripting language that is in every system administrators bag. One of the problems that I have is that I have installed lots of different Powershell modules on my servers, workstations, VM you name it. Over time you kinda of lose track and end up with differs of different versions of modules on different boxes. As the team I am working in is quite young to scripting we have not really followed a process to write within our scripts to check which version of module people should have installed before executing the script so that the cmdlet will run. In the meantime you can run this handy command to quickly check what module and the version of  module you need to be able to use that particular cmdlet. Remember the same cmdlet may of been updated in a newer version too to have more features. So on the machine where your script/cmdlet has run successfully run the following command in Powershell; Get-Command -type cmdlet get-vm | select ModuleNa

Azure Resource Tag Support

I have been using Azure policy for the pass few months to help audit check if all my resources have the relevant tags that we need applied on. Unfortunately not all resources can be tagged in Azure and you may need to make a few changes so that your compliance report does not report the wrong information for you, especially if your management team have access to view the compliance. Here are few pointers to help make your compliance report more accurate: If your Azure policy is just checking on tags then you should set the mode for the policy to be "indexed". As "indexed" mode will only evaluate resources that support tags and location which will prevent your compliance report to not be shown as non compliance.  Use this site reference to help see if a particular resource can be tagged and reported in costing. This will help you to understand that not everything can have a tag to help you with cost reporting.

Moving Azure Resources

Whenever you deploy a resource into Azure you have to deploy them into a resource group. Over time you may discover that you need to move the resource to another resource group or even subscription. Example of a move could be, a particular VM now belongs to App B so you need to move it to the resource group where all the App B resources are.  Now not all resources can be moved to another resource group or subscription so here is this handy article from Microsoft where you can check if the resource can be moved between resource group or subscription. One key point to remember is that moving the resource does not actual move or c hange the location of the resource. You are only changing the location of where you are managing the resource from. So if you have deployed a VM in North Europe in resource folder A and decided to move this resource to resource folder B. The VM will continue to run

Powershell cmdlet syntax

Over the years I have been using powershell and Windows Powershell ISE as my default editor. Whenever I was stuck on not knowing the syntax for a cmdlet I would use the Commands windows and find my cmdlet then select Show Details You will get a expanded menu of all the possible syntax/s that are for the cmdlet. Selecting the question mark then brings up more detailed information such as description, syntax and examples. There are times where I work straight on the command line and discovered that there are equivalent commands available to help display this information Get-Command Connect-VIServer -Syntax This would output the syntax/s the cmdlet can accept Another useful command to use it  Get-Help Connect-VIServer -Examples This would output some examples to help you on how to use this cmdlet Below are a few more cmdlets which provides further information about a cmdlet which maybe useful Get-Help Connect-VIServer -Detail

Remember to save your resource pool tree

One of the things that you could lose when you disable DRS for a cluster is your resource pool trees and the settings your resource pools (Memory/CPU reservations etc). Settings such as anti-affinity/affinity, DRS automation level are not included. With so much automation taking place nowadays it is very easy to script something to enable or disable DRS via PowerCLI. A simple line like this  To turn OFF DRS : Get-Cluster -Name "cluster" | Set-Cluster -DrsEnabled: $false To turn ON DRS : Get-Cluster -Name "cluster" | Set-Cluster -DrsEnabled: $true One thing I noticed with this PowerCLI command is that it does not give you an option to save/export your resource pool tree structure and settings. I have seen people asking in VMTN how to use script to export your settings to a CSV file and there are plenty of ways. I am going to walk through how to backup and restore your resource pool tree via the HTML 5 client and