64bit DOS commands with a 32bit (two-bit) application

This week I worked with a group of people that have a monitoring application — basically a glorified task scheduler for 32bit DOS applications. Among other things, this application attempts to check Microsoft Cluster Services (MSCS) failover status and send emails (using BLAT.exe) in the event a cluster was unbalanced. The code was no longer working after moving to Windows 2008R2. While helping them debug code, I realized that the ‘cluster’ command was not producing any output; likely due to the 32bit mode scheduler. A quick Google search came up with a simple solution — use the Windows SYSNATIVE directory instead of SYSTEM32 (http://www.tipandtrick.net/2008/how-to-suppress-and-bypass-system32-file-system-redirect-to-syswow64-folder-with-sysnative/).

However, updating the code caused a slight problem because the sysnative path was not available on their down level clusters. Here is a very simple workaround, but one I thought worth mentioning:

if exist "C:\Windows\sysnative\cluster.exe" (
set clusterPath="C:\Windows\sysnative\cluster.exe"
) else (
set clusterPath=%windir%\system32\cluster.exe
)

echo %clusterPath%

This batch file code checks for the existence of the sysnative\cluster.exe and if it is not available fails back to the previous path. A very simple solution, but the customer is happy.

Posted in Scripting | Leave a comment

PowerCLI vCheck 5.40

The other day I noticed two bugs in version 5.38 of the vCheck script. This minor update resolves those bugs and adds a check for 4.1 hosts without Active Directory authentication configured.

# Version 5.40- bwuch: Host version greater than/equal 4.1.0 and AD Auth not configured
# Version 5.39- bwuch: bug fixes from 5.38 version

5.39 – Bug fixes to resolve issues with re-use of global variables in version 5.38 (a description of these bugs can be found here: http://enterpriseadmins.org/blog/scripting/powercli-vcheck-5-38/#comments)

5.40 – added check based completely on LucD’s Get-VMHostAuthentication function available here: http://www.lucd.info/2010/07/25/script-vsphere-4-1-ad-authentication/. This check looks for hosts running ESX/ESXi 4.1 or higher without Active Directory authentication setup. This check can be disabled by setting $ShowHostADAuth to $false

You can download the updated version here: vCheck5.40.ps1

Please feel free to leave a comment with any suggestions or problems you may encounter.

Posted in Scripting, Virtualization | 11 Comments

Export, Compare, and Synchronize Active Directory Schemas

I’ve had this link in my notes for a long time. I’ve only used it twice, but thought it was worth sharing. If you ever need to make a test Active Directory for some really crazy testing, and you’ve ever extended the schema, you may want those extended attributes. There is a really good article over at Microsoft Technet that walks through this process: http://technet.microsoft.com/en-us/magazine/2009.04.schema.aspx?pr=blog

I’ll generalize the steps…but this is basically what is going on:

  • Exporting the existing schema using LDIFDE
  • Comparision to another schema using AD DS/LDS Schema Analyzer
  • Exporting the schema differences (using AD DS/LDS Analyzer)
  • Importing the schema differences into the target forest

The instructions are pretty straight forward, so just take a look here if you are interested: http://technet.microsoft.com/en-us/magazine/2009.04.schema.aspx?pr=blog

Posted in Messaging, Scripting | 1 Comment

Configure virtual machine for nested ESX/ESXi with PowerCLI

I’ve been working with several scripts in a lab recently. Most of these labs require additional ESXi hosts (namely vCheck testing) so I’ve been propping up some nested ESXi virtual machines. When I create a virtual machine to run nested ESXi, I typically set three advanced configuration options:

monitor_control.restrict_backdoor = TRUE
monitor_control.vt32 = TRUE
SMBIOS.reflectHost = TRUE
  • The first option listed allows you to run virtual machines inside your nested ESXi installations.
  • The VT32 option is specifically geared for Intel hardware; if you are using AMD hardware you’ll probably want to use monitor_control.enable_svm = TRUE instead.
  • The final option is not really required; it simply makes the nested ESXi host look more like a physical server. If you do this on an HP server, the virtual ESXi host appears as an HP instead of being a VMware, Inc. Virtual Machine Platform.

While three copy/paste operations into the advanced settings window isn’t challenging or time consuming, I thought it would be better if this could be done with PowerCLI.


#Monitor Control/Restrict Backdoor
$extrarbd = New-Object VMware.Vim.optionvalue
$extrarbd.Key="monitor_control.restrict_backdoor"
$extrarbd.Value="TRUE"

#Monitor Control/VT32
$extravt32 = New-Object VMware.Vim.optionvalue
$extravt32.Key="monitor_control.vt32"
$extravt32.Value="TRUE"

#SMBIOS/Reflect Host
$extraref = New-Object VMware.Vim.optionvalue
$extraref.Key="SMBIOS.reflectHost"
$extraref.Value="TRUE"

#Create a Machine Config Spec using the three option values specified above
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += $extrarbd
$vmConfigSpec.extraconfig += $extravt32
$vmConfigSpec.extraconfig += $extraref

#Get a VM View collection of all the VMs that need to have these options
$vms = get-view -viewtype virtualmachine |where {$_.name -eq "mytestesxi01"}
foreach($vm in $vms){
$vm.ReconfigVM($vmConfigSpec)
}

I’ve used this on two virtual machines and it appears to work okay. Please feel free to drop a comment if you have any questions.

Posted in Scripting, Virtualization | 1 Comment

PowerCLI vCheck 5.38

It has been a little over 3 months since I’ve posted an update to vCheck. I still have some features and bug checks I’d like to add, but figured I’d share the current state. Here are the in-code comments for the new sections:

# Version 5.38- bwuch: bug fix with 'connectionstate' warning
# Version 5.37- bwuch: added SYMC to VCB check for Symantec Backup Exec 2010
# Version 5.36- bwuch: changed snapshot function
# Version 5.35- bwuch: Added section with Powered Off VMs showing the last powered on date/event.
# Version 5.34- bwuch: Added the CBT tracking code provided by rhys on vCheck comments
# Version 5.33- bwuch: Modified Cluster config check to vCheck output format http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/
# Version 5.32- bwuch: Hack to make report look better in Outlook.

For those of you looking for some detail, keep on reading:

5.32 – A single line of code was retro-fitted to make the email report look a little better in Outlook 2007/2010. You can read about that change here: http://enterpriseadmins.org/blog/scripting/minor-update-to-vcheck-5-31-beta-testers-required/

5.33 – I took the really cool looking cluster config check from the following site: http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/ and changed the output so it would appear in vCheck. This is a really cool looking report with solid data, but it doesn’t really look good on clusters with more than 3 or 4 hosts (due to the table resizing). If you want to disable/hide these checks, you need to set the variables on lines 182, 183 and 184 to $false.

5.34 – A user over at Virtu-Al.net posted some code in the comments that allows checking of Change Block Tracking (a backup mechanism based off the vStorage API for Data Protection). That code has been incorporated into this version.

5.35 – A user at Virtu-Al.net posted a request for powered off VMs with the time they were last powered on. The code was already available here http://blogs.vmware.com/vipowershell/2009/10/when-was-the-last-time-that-vm-was-powered-on.html so I incorporated it into vCheck result format.

5.36 – I changed the snapshot checks to make use of some PowerCLI advances; removing some custom functions that Alan had in the original vCheck and possibly improving performance for environments with large numbers of snapshots. The snapshot code is available independently here: http://enterpriseadmins.org/blog/scripting/vsphere-snapshot-report/

5.37 – A user posted a comment to the vCheck 5.31 thread stating that their backup product has snapshots named “SYMC*” that should appear in the VCB Garbage check. Updated code as requested.

5.38 – During some test runs prior to posting I encountered another PowerCLI warning related to changes in the functions in PowerCLI 4.1. I resolved that specific issue in this version.

You can download the updated version here: vCheck5.38.ps1

Please feel free to leave a comment with any suggestions or problems you may encounter.

Posted in Scripting, Virtualization | 13 Comments