April 18, 2012
Kudos to J.C. Hornbeck for this article which saved my arse today. I ended up doing some spring cleaning today removing old disabled accounts for people who have moved on. A little while later I noticed I was getting this error message when trying to do anything PowerShell related to VMM, and then the console itself.
Apparently, I had dun goofed and deleted the database owner of the VMM database from the domain. Simple enough after further research I ended up adding our service account as the DBO via the dialog below. If the user already exists in the database, you’ll just have to remove it prior.
Steps to resolve this:
- Right click on the affected database.
- Go to properties and select Files.
- Click the … button and select an account.
- IT WORKS!!!

posted in Hyper-V, Virtualization by Jason Ruiz | No Comments
April 10, 2012
Cat is out of the bag, I should be able to talk about this. Not much has changed in the interface, but there are several new features which are part of the now supported Server 8 OS and Hyper-V 3.
Storage:
Using Server 8 Hyper-V 3 hosts, you can now use SMB 2.2 shares to host VMs. You may also Live Migrate between CSV’s and SMB shares with no down time.
Performance hasn’t been stellar, I’m getting around 200-500 Mbps via a 2 1GbE LACP bonded interface with Jumbo Frames enabled, I know the storage server should perform better.
Networking:
I assume most of the work on this has not been completed, as the only available options are to configure the VM network itself, from my understanding there would be an underlying bond between the outside and inside networks, but I have not found the spot to configure this.

The new QoS feature in Hyper-V 3 has not shown its head in this version either.


Issues:
This is a CTP, they are not all created equal. That said, VMM 2012 SP1 has been crashing quite often in our lab and we have noticed several bugs so far. One of the most noticeable one is that the “Make this VM highly available” feature during migration does not work as intended. During my testing at one point the VM was no longer HA, running the Live Migration wizard and selecting that option did not turn on HA, I ended up powering it off and doing it once more which infact did turn on HA.
posted in Hyper-V, Storage, Virtualization by Jason Ruiz | No Comments
March 16, 2012
I can start talking about some stuff now, being under NDA for several Microsoft products currently. Luckily Server 8 is pretty much public now with all the features so I can speak openly about the simple things. Microsoft previously freely offered an iSCSI target for Windows as a separate download, but it is now built directly into Server 8 and it’s server management console. You can add it under the File Services role. Configuration is pretty straight forward, a normal set of wizard driven options. As you can see, Microsoft has made this plain and simple, so there’s not much to explain.
SimpleViewer requires JavaScript and the Flash Player.
Get Flash.
posted in Storage by Jason Ruiz | No Comments
March 16, 2012
Microsoft has also made Powershell CMDlets for their iSCSI target which are available after installing the role.
For a simple setup, it’s rather easy:
New-IscsiServerTarget -TargetName "NewTarget" -InitiatorIds IQN:iqn.1991-05.com.microsoft:host003-tpa02.domain.ltd,IQN:iqn.1991-05.com.microsoft:host004-tpa02.domain.ltd
New-IscsiVirtualDisk -DevicePath G:\iSCSIDisks\LUN1.vhd -Size 100GB
Add-IscsiVirtualDiskTargetMapping -TargetName NewTarget -DevicePath G:\iSCSIDisks\LUN1.vhd
And for the lazy man:
Function New-Target ($Name, $Initiators, $Size, $Path) {
New-IscsiServerTarget -TargetName "$Name" -InitiatorIds $Initiators
New-IscsiVirtualDisk -DevicePath $Path -Size $Size
Add-IscsiVirtualDiskTargetMapping -TargetName "$Name" -DevicePath $Path
}
posted in Scripting, Storage by Jason Ruiz | No Comments
March 7, 2012
After the week(s) of major downtime with Dreamhost and general lack of decent performance, I decided to bite the bullet and move on. I spent an hour or so browsing CheapVPSDeals I decided on RethinkVPS. I don’t know if there are any better deals I missed, but I’m generally happy with the under 10 bucks a month charge for unmetered bandwidth. I ended up configuring nginx for the first time to host the site and performance and memory are spot on with awesomeness.
posted in Uncategorized by Jason Ruiz | No Comments
February 8, 2012
I let this sit for awhile before deciding to finish it, from what I can see it works perfect for our environment.
function Get-Updates ($VMHost) {
$VMMServer = Get-VMMServer "SCVMM IP Adress"
$SCOMServer = "SCOM Server FQDN"
New-PSDrive -Name:Monitoring -PSProvider:OperationsManagerMonitoring -Root:\ | Out-Null
New-ManagementGroupConnection -ConnectionString:$SCOMServer | Out-Null
Set-Location "Monitoring:\$SCOMServer"
function StartMaintenance {
$SCOMAgent = Get-Agent | Where-object {$_.Name –match “$VMHost”}
Write-Host "Setting $VMHost to unavailable for placement"
Set-VMHost -VMHost $VMHost -AvailableForPlacement $FALSE | Out-Null
Write-Host "Placing host $VMHost into maintenance mode."
$SCOMAgent.HostComputer | New-MaintenanceWindow -StartTime (Get-Date) -EndTime ([DateTime]::Now).AddMinutes(180) -Comment "Windows Updates"
Disable-VMHost $VMHost -MoveWithinCluster | Out-Null
$Maintenance = Get-VMHost -VMMServer $VMMServer $VMHost | Select OverallState
if ($Maintenance -match "MaintenanceMode") {
Write-Host "Host is in Maintenance Mode"
}
Else {
Write-Host "Host did not successfully go into Maintenance Mode, retrying"
StartMaintenance
}
}
function EndMaintenance {
$SCOMAgent = Get-Agent | Where-object {$_.Name –match “$VMHost”}
Write-Host "Placing host $VMHost back into service."
Enable-VMHost $VMHost | Out-Null
Set-VMHost -VMHost $VMHost -AvailableForPlacement $TRUE | Out-Null
$SCOMAgent.HostComputer | Set-MaintenanceWindow -EndTime ([DateTime]::Now).AddMinutes(1) -Comment "Finished Windows Updates"
}
function CheckForReboot {
$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$VMhost)
$key = $baseKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\")
$subkeys = $key.GetSubKeyNames()
$key.Close()
$baseKey.Close()
If ($subkeys | Where {$_ -eq "RebootPending"}) {
Write-Host "Reboot is required: Restarting $VMHost"
Restart-Computer -ComputerName $VMHost -Force
sleep 180
}
Else {
Write-Host "No Reboot required."
}
}
function MigrateOfflineVMs {
$OfflineVMs = Get-VM -VMMServer $VMMServer -VMHost $VMHost | Select Status
$Hosts = Get-VMHost -VMHostGroup "HostGroup"
if ($OfflineVMs -match "PowerOff") {
Write-Host "There are offline VMs, migrating to another host"
$VMs = Get-VM -VMHost $VMHost | Where-Object {$_.Status -eq "PowerOff"}
ForEach ($VM in $VMs) {
$HostRatings = Get-VMHostRating –VMHost $Hosts –VM $VM -IsMigration | Sort-Object –descending Rating
if ($HostRatings[0].Rating –ne 0) {
$BestHost = Get-VMHost –ComputerName $HostRatings[0].Name
write-host “Moving $VM to $BestHost”
Move-VM –VM $VM –VMHost $BestHost | Out-Null
}
}
}
Else {
Write-Host "There are no VMs on this server currently."
}
}
function CheckHostStatus {
$HostState = Get-VMHost $VMHost
if (($HostState.ComputerState -match "Responding") -and ($HostState.ClusterNodeStatus -match "Running") -and ($HostState.VirtualServerState -match "Running") -and ($HostState.VirtualServerStateString -match "Running") -and ($HostState.CommunicationStateString -match "Responding") -and ($HostState.CommunicationState -match "Responding")) {
Write-Host "Host is responding"
}
Else {
Write-Host "Host is not operational!!!"
sleep 120
CheckHostStatus
}
}
function CheckWUInstall {
$WUInstallStatus = Get-Content "C:\Users\USERNAME\Desktop\Scripts\Logs\$VMHost.log" | Select-Object -Last 1
If ($WUInstallStatus -match "No Updates are available, nothing to do!") {Write-Host "No Updates are available, nothing to do!"}
else {InstallUpdates}
}
function InstallUpdates {
psexec \\$VMHost -s -c \\SHARESERVER\SHARE\wuinstall.exe /install /accepteula > "C:\Users\USERNAME\Desktop\Scripts\Logs\$VMHost.log"
CheckForReboot
CheckHostStatus
CheckWUInstall
}
StartMaintenance
MigrateOfflineVMs
InstallUpdates
CheckHostStatus
EndMaintenance
C:
}
posted in Hyper-V, Scripting, Virtualization by Jason Ruiz | No Comments
December 16, 2011
Lately a couple of our Cluster Shared Volumes have been hitting a high percentage of usage, to alleviate any issues, I wanted a simple way to find out which VMs had the largest disk usage on those volumes. I chose to query volumes that were over 70% usage and the top 5 storage hogging VMs from those.
Credit goes to this post as getting a proper output of the paths and percentage is a real pain with the Failover Clustering CMDLets.
function Get-LargestVMs {
function Get-LargeVMs ($Path) {
$Size = get-vm -vmmserver "IP" | Where-Object {$_.vmcpath -like "*$Path*"} | Select Name,TotalSize,Hostname | Sort-Object TotalSize -Descending | Select-Object -First 5 | Out-String
Write-Host $Size
}
$objs = @()
$csvs = Get-ClusterSharedVolume -Cluster "Cluster"
foreach ( $csv in $csvs )
{
$csvinfos = $csv | select -Property Name -ExpandProperty SharedVolumeInfo
foreach ( $csvinfo in $csvinfos )
{
$obj = New-Object PSObject -Property @{
Path = $csvinfo.FriendlyVolumeName
PercentFree = $csvinfo.Partition.PercentFree
}
$objs += $obj
}
}
$objs | foreach {
if ($_.PercentFree -le "30") {
Write-Host "################################################"
Write-Host $_.Path
Write-Host "Current percent free is"$_.PercentFree
Write-Host "################################################"
Get-LargeVMs $_.Path
}
else {
}
}
}
posted in Hyper-V, Scripting, Virtualization by Jason Ruiz | No Comments
December 1, 2011
I changed this around in my last script to verify the operational status of a host via SCVMM instead of the Hyper-V server itself.
function CheckHostStatus {
$HostState = Get-VMHost $VMHost
if (($HostState.ComputerState -match "Responding") -and ($HostState.ClusterNodeStatus -match "Running") -and ($HostState.VirtualServerState -match "Running") -and ($HostState.VirtualServerStateString -match "Running") -and ($HostState.CommunicationStateString -match "Responding") -and ($HostState.CommunicationState -match "Responding")) {
Write-Host "Host is operational"
}
Else {
Write-Host "Host is not fully operational"
sleep 120
CheckHostStatus
}
}
posted in Hyper-V, Scripting, Virtualization by Jason Ruiz | No Comments
October 10, 2011
I’m now in charge of roughly 30 Hyper-V servers, half in an HA cluster, and the rest are standalone. Rather than doing updating each server manually I decided to take it upon myself to automate it via PowerShell. In my environment, we use SCVMM and SCOM, so doing this is rather easy, we also have WSUS for filtering updates as we have run into a few issues before.
There are 2 pieces of software used in this as a workaround for a known issue with remotely calling the Microsoft Update Session API, WUInstall and PSexec.
Here is the code below:
Add-PSSnapin Microsoft.SystemCenter.VirtualMachineManager
Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client
$VMMServer = Get-VMMServer "SCVMM IP Adress" #<- Had issues with authentication while using the FQDN
$SCOMServer = "SCOM Server FQDN"
$VMHosts = Get-VMHost -VMMServer $VMMServer | Where-Object {$_.name -ge "Hostname"}
New-PSDrive -Name:Monitoring -PSProvider:OperationsManagerMonitoring -Root:\ | Out-Null
New-ManagementGroupConnection -ConnectionString:$SCOMServer | Out-Null
Set-Location "Monitoring:\$SCOMServer"
function StartMaintenance {
$SCOMAgent = Get-Agent | Where-object {$_.Name –match “$VMHost”}
Write-Host "Placing host $VMHost into maintenance mode."
$SCOMAgent.HostComputer | New-MaintenanceWindow -StartTime (Get-Date) -EndTime ([DateTime]::Now).AddMinutes(60) -Comment "Running Windows Updates"
Disable-VMHost $VMHost | Out-Null
}
function EndMaintenance {
$SCOMAgent = Get-Agent | Where-object {$_.Name –match “$VMHost”}
Write-Host "Placing host $VMHost back into service."
Enable-VMHost $VMHost | Out-Null
$SCOMAgent.HostComputer | Set-MaintenanceWindow -EndTime ([DateTime]::Now).AddSeconds(5) -Comment "Finished Windows Updates"
}
function InstallUpdates {
psexec \\$VMHost -s -c \\shareserver\share\wuinstall.exe /install /accepteula > "C:\Users\logon\Desktop\Scripts\Logs\$VMHost.log"
}
function CheckForReboot {
$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$VMhost)
$key = $baseKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\")
$subkeys = $key.GetSubKeyNames()
$key.Close()
$baseKey.Close()
If ($subkeys | Where {$_ -eq "RebootPending"}) {
Write-Host "Reboot is required: Restarting $VMHost"
Restart-Computer -ComputerName $VMHost -Force
sleep 120
}
Else {
Write-Host "No Reboot required."
}
}
function CheckVMStatus {
$VMStatus = Get-VM -VMMServer $VMMServer -VMHost $VMHost | Select Status
if ($VMStatus -match "HostNotResponding") {
Write-Host "SCVMM has not updated the status of the Virtual Machines yet"
sleep 120
CheckVMStatus
}
Else {
Write-Host "Powering on Virtual Machines"
Get-VM -VMMServer $VMMServer -VMHost $VMHost | Start-VM | Out-Null
}
}
function CheckHostStatus {
$Status = Get-Service -Computername $VMHost VMMS -erroraction silentlycontinue | select status
if ($Status -match "Running") {
Write-Host "Host is Up"
Write-Host "Waiting for SCVMM to populate VM state"
CheckVMStatus
}
Else {
Write-Host "Host is still rebooting"
sleep 120
CheckHostStatus
}
}
Foreach ($VMHost in $VMHosts) {
StartMaintenance
InstallUpdates
CheckForReboot
CheckHostStatus
EndMaintenance
}
posted in Hyper-V, Scripting, Virtualization by Jason Ruiz | No Comments
August 25, 2011
I was hunting for a new affordable whitebox all pieced together for me, IE a desktop that was inline with the HCL. I looked through Best Buy since they usually have decent deals and went to my local CompUSA store to scope things out. I ended up buying a Gateway DX4860 from Best Buy for just a bit over 600 with tax included.
What you get:
i5 Quad 2.8ghz CPU
8gb RAM(Max 16gb)
1tb Hard Drive
6 SATA Ports
Realtek 100/1000 NIC(Now supported during stock installation!)
posted in Home lab, Virtualization, VMware by Jason Ruiz | 7 Comments