Using Custom PS Objects to Quickly Filter Data from Custom PS Modules

Many times when working with Powershell Modules, I’m presented with an object that contains data that I want, but it’s embedded inside nested hash tables, or isn’t quite storing the data in a way that’s useful for me to work with.

For example, let’s take the output of a function from Rubrik’s Powershell Module – “Get-RubrikSLA“. This command will output all the information about various backup policies, but doesn’t quite present it in a usable format for me (Say to output to a CSV file).

I’m interested in the frequencies of the backups, the name of the SLA Domain, and not much else. If we try to export the data right now using Select-Object we will see that the frequencies are inside an embedded hash table. When running “Export-CSV”, we’ll just be presented with this in our row –

Really, the data we are interested in is inside another has table called Daily. Drilling down, we can see that 'Daily' contains a the key;value pair Frequency,Retetention

The way to work around this limitation is to create a script that utilizes custom PS objects. This script will loop over the object we examined above, and push the data we want from each nested hash table, into a custom object called $slaOBjRecord . This object will then be added to an array, $sla_report_array.

Using this technique we end up with a result that looks like the table below, and can be used with export-csv without any issue.

Mass create VMWare Guests with PowerCLI

Need to create a bunch of VM’s at once in your VMWare vSphere environment? You can use the below script to do so. Just fill in the blanks in the $vmlist variable (A hash table in this case) to define the IP of the machine in question, as well as a corresponding name value. You will also want to modify the other values to fit your environment. Before running this you will also need to create a template VM to base your clone on, as well as creating a customization template.

Continue reading “Mass create VMWare Guests with PowerCLI”

Creating a portable VMWare Autodeploy instance on vCenter 6.5 appliance with PowerCLI

Autodeploy is a great tool that is integrated with VMWare vCenter and is available for your use if you have the proper licensing levels. There are a few ways to utilize Autodeploy, and this guide will focus on using the “stateful” (Install to disk) deployment method.

I’ve put together the steps needed to deploy this service in a UEFI based PXE-boot environment. The initial boot configuration steps are specifically written to work with Dell Servers and the IDRAC tool CLI. The boot order commands below will place your SD’s cards at the beginning of the boot sequence.

I should note that this method requires no modification of the customer environment (Including DHCP options), and is completely portable (no installs).

Update the boot order on your hosts to allow PXE booting to take second place. (SSH to IDRAC IP of each host to enter console commands below)

 

Enable AutoDeploy Services on vCenter

  • In the web interface navigate to Home > Administration > System Configuration > Nodes > vCenter Server > Related Objects and start “Auto Deploy”

 

Download and run Tiny PXE server

  • Copy TFTP Files from vCenter to TFTP Server file root
  • Set boot file name below depending on type of device (UEFI vs Bios mode)

 

This PXE server is fairly unique in the sense that it offers a “DCHP Proxy” option.  This allows you to temporarily deploy this server and intercept DHCP requests, adding on only the options you need (Option 66 and 67). There’s great detail on this functionality here

Upload ESXI image to software depot in vCenter (use vendor image zip file)

 

Create minimal host profile.

This host profile can come from an existing host, or a new host you deploy with a blank profile.

  • Set “stateful install to usb” option in your host profile that was previously created. This is This can be found under “Advanced Configuration Settings > System Image Cache Configuration” in the vCenter Web Interface.

  • Set Root Password (otherwise no password is set). This is found under “Security Configuration > Administrator Password” in the vCenter Web Interface.

Set deploy rules in Autodeploy to match hosts and apply host profile previously created

Enable new AutoDeploy Rule

 

 

If client environment contains WDS (Windows Deployment Services) – Set PXE Delay to allow for DHCP options override from our temporary PXE server

Hosts will show up in vCenter when the deployment process is complete.

A complete script combining the commands above will be posted here when completed.