Tag Archives: PowerShell - Page 2

Virtual Machine Guest Disk Free Space – PowerCLI Email Report

I expanded upon a useful sharing from over at the VMware community site.

Below is some code you can use to run against vcenter to get an emailed report of all virtual machines with low free space. The VMs need to have vmware tools running for this report. Don’t worry, I’ll post a script to check on that too!

As a personal preference I like to create a service account with logon as batch rights on a system to run this script. I then provision this same service account with read only privileges to vCenter. Once those things are setup the powershell script can be ran from task scheduler (using least privileged, yay).

Another thing I like to do is to capture transcripts and outputs of any scripts I run. This way if I have an SMTP issue or lose the email, I can go back and check files to see what was in previous reports or any errors that the script encountered.

You will want to edit the vcenter server name, the output file path, and email addresses before using this script. The script will email any VMs with drives that have less than 10% free space, of course, you can customize that % as well.

 

Automating AWS with PowerShell

I often have to turn on instances or register them with load balancers. I had some trouble finding documentation on the AWS PowerShell modules but in the end I was able to get everything done via scripts.

Here are some examples that might help you out.

If you are not using IAM roles then you will need to pass credentials to the AWS powershell module to use. This is how you accomplish that (using least privileged IAM credentials I hope).

Query for EC2 instances by name

Power on an instance

Convert your already queried instance objects into objects that can be used with Elastic Load Balancers…

Use your ELB Instance objects to add or remove them from ELBs

 

Enable Ping reply with PowerShell

Windows ships with ICMP reply disabled in the firewall. Here is a quick 2 liner in powershell to enable ping replys.

 

Display and Save Wireless Mac Address with PowerShell

A while back I was working at a place where the desktop techs needed to send the wireless MAC address to the network security team. So during the build I wrote this powershell script to save the MAC address to a text document on the desktop and to open it up.

This was done in conjunction with MDT while it wrapped up the task sequence logged in as the built-in administrator .