Apr
17

NOS 4.0 PowerShell – Add All Your VMs To A Protection Domain

There has been some requests from customers including on the Nutanix Next Community Site asking for a way to automatically add all the VM’s to a protection domain or at least have a default. Good thing about still using per-VM replication in this use case is that we are not sending the vswap files across the network\WAN. If the data has been deduped already and sent over the wire, you wont have send that as well.

Using PowerShell you can accomplish this with just two lines of code, maybe 1 if your smarter than me (not hard!)


$unprotectedvms = Get-UnprotectedVms
foreach($x in $unprotectedvms){ Add-VmsByNamesToProtectionDoman -name PD-2 -Names $x.vmName}

Nutanix PowerShell

Thankfully you can remove them out of the protection domain easily too.

Oct
10

Two VMware View KB’s – HPET & Storage Accelerator with PowerShell Is A No Go

The first KB I find interesting but I thought I should post the second one because of my blog post on shutting down and bringing up a View environment for time sharing. Apparently if you use PowerShell to do update your pools the Use host caching option in the pool’s Advanced Storage Settings tab gets deselected.

Having HPET enabled in a Windows 7 virtual machine can cause View Agent to become unreachable

View Storage Accelerator becomes disabled when using Powershell to update Automated Pool

Mar
08

PowerShell Integration with VMware View – The hidden document

It’s times like this I am very happy to be on twitter. Today Matt Lesak posted a link to the PowerShell Integration with VMware View 5.0 document. He mentioned it was updated but I never remember even seeing it before so I happy to see this bad boy. The only document I can recall is the VMware View Integration document and PowerShell was only a small chapter in it.

The VMware View Integration has information on:

Integrating the Event Database
PowerShell
Customizing the LDAP
Intergrating with SCOM
PcoIP Session Statistics/WMI


PowerShell Integration with VMware View 5
is 20 pages of goodness including some great sample scripts on:

Add or Remove Datastores in Automatic Pools
Add or Remove Virtual Machines
Inventory Path Manipulation
Poll Pool Usage

The rest of the VMware View 5.0 documents can be found at: http://www.vmware.com/support/pubs/view_pubs.html

Enjoy the Midnight reading!

Nov
30

The Best VMware View PowerShell Variable – Inform the Users

Running a lot of persistent desktops can have it’s it challenges. While persistent desktops are easier on the infrastructure; like DNS, DHCP, and storage IO they’re a real pain to manage. Since windows is windows, you do need to reboot your windows virtual desktop or else it will eventually get slow by some memory leaking program. It’s kind of funny that all things that a user would put up with a physical desktop, but when it comes to VDI they except the world(this can be good). I think the high exception is because you have given them something that is new and that they’re unsure of.

To help move your users move along their VDI journey, you can tell them how long their virtual desktop has been running my emailing them. Hopefully by letting them know, maybe you can prevent a help desk ticket.

The below code has to run on the View Connection Broker. There might be a better way to get the user’s email address but I don’t know it. If you do please do tell!

Import-Module ActiveDirectory
#need to grab AD information later

$listOfvms = Get-DesktopVM -vc_id (Get-ViewVC -serverName "vCenter").vc_id
#Grab all the desktops that your connection brokers are using,this will pull replica's as well
foreach ( $vms in $listOfvms){

if ($vms.isInPool -eq "true")
{
#if the desktop is in a pool see how long it's been running
$wmi = Get-WmiObject -ComputerName $vms.Name -Query "SELECT LastBootUpTime FROM Win32_OperatingSystem"
$now = Get-Date
$boottime = $wmi.ConvertToDateTime($wmi.LastBootUpTime)
$uptime = $now - $boottime
$d =$uptime.days
$user = Get-ADUser $vms.user_sid #Get AD user info so we can build the email address
$userSID = $vms.user_sid #Best PowerShell Variable b\c it means you know which desktops have been assigned and are active by users

#If the desktop has been running for 7 days and desktop is being used by a user, send an email
if ($d -gt "7"-and $userSID -gt 1){
Write-Host $userSID
$mail = New-Object System.Net.Mail.MailMessage
$user = Get-ADUser $vms.user_sid
$mail = New-Object System.Net.Mail.MailMessage
$emailTo = $user.GivenName + "." + $user.SurName + "@domain.com"
$mail.To.Add($emailTo)
$mail.From = "noreply@domain.com"
Write-Host $mail.From
$mail.Subject = "Your VDI Desktop has been running for " + $d + " days"
$mail.Body = "Your " + $vms.name + " desktop has been running for " + $d + " days. If performance is slow please take the time restart your desktop. To restart your virtual machine please select the option from the Start menu. "
Write-Host $emailTo
$smtp = New-Object System.Net.Mail.SmtpClient("emailserver")
$smtp.Send($mail)
$emailTo = ""
}

$userSID = ""
}
}