PowerShell/PowerCLI to Find ESX Hosts Needing a Reboot

Posted Posted in Information Technology, Virtualization

From Rob van den Nieuwendijk – How to find VMware ESX(i) servers that need a reboot using PowerCLI.  Rob provides a PowerShell/PowerCLI one-liner If you install patches to your ESX(i) servers you will probably have to reboot them. But if you don’t reboot them right after installing the patches, how can you find the servers that are patched and waiting for a reboot? VMWare ESX(i) servers that are waiting for a reboot have the “Reboot Required” message in the Summary tab in the VMware vSphere Client. But if you have hundreds of ESX(i) servers, you don’t want to click through […]

Invoke-VMScript: Running PowerShell on a Remote VM

Posted Posted in Information Technology, Virtualization

PowerCLI guru Luk Dekens has a new post that discusses when you can use Invoke-VMScript to run a PowerShell script on a VMware virtual machine. The Invoke-VMScript cmdlet can be a very useful cmdlet, but sometimes it will fail against one or more of your VMs. And it is not always immediately clear why the Invoke-VMScript cmdlet will not work against that specific VM. The cmdlet help contains a number of prerequisites, but how do you verify if all the prerequisites are fulfilled? I decided to create a function that would verify the prerequisites, and that would, if requested, which […]

PowerCLI 5.0.1 – vCloud Director Automation

Posted Posted in Information Technology, Virtualization

Via Alan Renouf – PowerShell PowerCLI v 5.0.1 includes support for vCloud Director Automation cmdlets. Normally with a .0.1 release you will see small bug fixes and performance increases. This is the case with this release, there are indeed bug fixes and performance increases but there is also something very exciting… PowerShell Cmdlets for managing VMware’s cloud solution – VMware vCloud Director. The latest bug fixes and other enhancements can be found in the change log here, this post will mainly cover what’s new from the vCD PowerCLI snapin or VMware.VimAutomation.Cloud snapin. (read more and see the list of cmdlets)

Creating an Excel Pivot Table Using PowerShell

Posted Posted in Development, Information Technology

Doug Finke has a new post about a PowerShell script he wrote to create an Excel Pivot Table. Out-ExcelPivotTable inspects the piped data, sets up the numeric properties as data fields and string properties as row fields (nested). Doug includes screenshot of the output, in case you are unfamiliar with Pivot Tables. The actual script he built can bedownloaded here. Sample Usage: Function New-Person ($dept, $name, [double]$salary, [int]$yearsEmployeed) { New-Object PSObject | Add-Member -PassThru Noteproperty Dept $dept | Add-Member -PassThru Noteproperty Name $name | Add-Member -PassThru Noteproperty Salary $salary | Add-Member -PassThru Noteproperty YearsEmployeed $yearsEmployeed } $( New-Person IT Doug […]

PowerShell and SQL Server

Posted Posted in Information Technology

Customers are always asking about using PowerShell to interact with their SQL servers.  One great source I’ve started following is Max Trinidad.  He has a very good grasp of both PowerShell and SQL Server administration.  Max has also contributed to codeplex with the SQLDevTools Module.  He wrote a blog postthat discusses some of the features. Here’s one of the function that’s part of my recentSQLDevTools Module – “Get-TSQLTableRecordCount” which is a good example of a multi-purpose command.   The main purpose of this function is to assist in displaying the record count of all tables in the database.  But, at the same time […]

Count Running Virtual Machines on Datastores

Posted Posted in Development, Information Technology, Virtualization

Found another good candidate for a PowerVI script atvNiklas.djungel.se. If you are running too many VM´s on your datastores in your vSphere environment you can have some problems, this if your SAN is not VAAI compliant and can handle SCSI locking etc. Alan Renouf has made a blog post about how to get a report about how many VM´s you have on every datastore, I have extended to only report on running VM´s as these are the interesting number.. (read more) I would alter his script slightly for use in PowerVI. #–name Virtual Machines Per Datastore #–multi –hideoutput #–origin PowerSE […]

Enabling and Disabling Hyper-Threading via PowerCLI

Posted Posted in Information Technology, Virtualization

I found an interesting discussion on the VMware Communities about managing hyper-threading settings via PowerCLI.  The discussion has a couple of useful scripts.  To find out if hyper-threading is enabled use this script: Get-Host | Select-Object Name,HyperthreadingActive To disable hyper-threading, use the connect-VIserver to connect directly to the host and use this script: ## host upon which to act $strMyHostName = “myhost.domain.com” ## get the View object for the HostCpuSchedulerSystem $viewHostCPUSchedulerSystem = Get-View (Get-View -ViewType HostSystem -Property ConfigManager.CpuScheduler -Filter @{“Name” = $strMyHostName}).ConfigManager.CpuScheduler ## disable hyperthreading $viewHostCPUSchedulerSystem.DisableHyperThreading() Note: DisableHyperThreading method is available in vSphere 4.1 and later.