Debug powershell with write-host

A very basic command to output what’s stored in a variable to the command prompt in a powershell script. ┬áThis is part of a script to set IOPs on a VM located on a tintri storage array. ┬áThe script was failing every time it got to a specific VM, this allowed me to see what VM it was failing on.

if ($IsLive) { $vmName = $($_.Vmware.Name)
$vCenterName = $($_.Vmware.VcenterName)
$scs = $($_.Vmware.StorageContainers)
$minIOPs = $($_.QosConfig.MinNormalizedIops)
$maxIOPs = $($_.QosConfig.MaxNormalizedIops)
Write-Host “Updating: ” $vmName

This entry was posted in Scripting and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *