This is a VM clone/”backup” script that I use in my home lab. I schedule this script to make a clone of important VMs (works with vCenter) and clones them to another datastore. Obveusly this is not a proper backup but if I make a config change or lose a datastore then this will (and…
Tag: Powershell
File deletion scripts
I get asked quite alot at work to monitor folders and delete files older then x days or stop them growing out of control. These folders are normaly FTP backups of things that do not age out. Like config backups (NSX im looking at you). There are a couple of ways to do this. The…
NetApp performance monitoring using Powershell
I recently had to run some monitoring commands to gather information while a backup was running. So I used Powershell. I needed to SSH on to the FAS and run the following: So why should I do that when I can get Powershell to do it. Here is a quick bit of Powershell to SSH…
Tutorial, Using Credentials
A common problem I have is that the account that runs a powershell script does not have the required rights on a remote computer to do its job. It could be because the remote “thing” only has local accounts or is a windows computer on a different domain. The old way of getting round this…
Report VM reconfigurations
One this that has always bugged me with vCenter UIs is seeing a reconfigure VM task but not being able to tell what was changed. Some times in an investigation this can be very important. While looking at Event objects one day I discovered an attribute called configchanges on a reconfigured event object. In there…
Tutorial, calculated property
Here is something that I have used for a while but had no idea what it was called. After a bit of googling, apparently its a calculated property. What is a calculated property? A calculated property is changing the name and/or value of an attribute as its copied to a new object or the screen….
Tutorial Functions
Powershell, like just about every other programming/scripting language has functions. These functions can be simple one liners or very complicated, depending on your needs. A very simple function is show below. This function has a name and a code block. It has no input and will only output to the screen. Why should I use…
MultiPing function
This is a function (3 functions) I have been meaning to write for a while. It is a Ping function that will ping more then one target and report what is responding, what is not and the time.To keep the display easy to read, if there is no state change then the last line is…
Powershell tutorial, Jobs part 1
Powershell code runs synchronously. This means that one line is processed at a time until the end of the script is reached. This is fine for most scripts but there will be situations where this type of execution is not ideal. A port scanner for example would take forever if it ran synchronously. When creating…
Powershell tutorial, Jobs part 2
Here is a Ping sweeper script using Powershell jobs to speed things up. The script works (at a high level) like this: I create an array of IP addresses to scan. I loop through each IP If I am running the max number of concurrent jobs, wait for some jobs to finish, add the results…