Coding

sVmotion VMware templates

Posted on

I am doing some VMware datastore shuffling and needed to move several templates to another datastore. For normal VMs, I have a script named “Move-VMThin.ps1” that moves the VMs and thins out the disks at the same time. I looked for something similar for templates, something that would allow me to migrate the template to […]

Coding

Reset the root password to a random value

Posted on

I recently began setting up some Linux servers at work and become concerned about access to the root user account. I have stressed the need for using SUDO, but the fact that people may know the root account was a gaping hole in accountability – if everyone logs in as root, how do I know […]

Coding

Export and Import VMware affinity rules

Posted on

More searching for migration of my VCenter and I found http://ict-freak.nl/2009/09/06/powercli-export-and-import-drs-rules-v2/ which allows me to export and import the affinity rules Export Get-Cluster -Name “TUK_UT_04” | Get-DrsRule | `Export-CliXml ‘d:tempAffinityRules.xml’ Import ForEach ($rule in (Import-CliXml ‘d:tempAffinityRules.xml’)){    New-DrsRule -Cluster (Get-Cluster -Name “TUK_UT_04”) `    -Name $rule.Name -Enabled $rule.Enabled `    -KeepTogether $rule.KeepTogether `    -VM (Get-VM -Id $rule.VmIds)}

Coding

Executing commands in a VM via powershell

Posted on

I got to thinking today that when you tell a VM to shutdown the OS, it is actually executing a command against the VM itself, not just in VMware. I decided to do a little searching to see what it takes to do something similar with other commands (such as srvinfo, or listing disk usage) […]

Coding

Powershell to disconnect CD and Floppy drives in ESX

Posted on

This script will enumerate all VMs and disconnect all CDs and Floppy drives get-cddrive -VM * |where {$_.ISOPATH -ne $null}|set-cddrive -nomedia -Confirm:$Falseget-cddrive -VM * |where {$_.HOSTDevice -ne $null}|set-cddrive -nomedia -Confirm:$Falseget-FloppyDrive -VM * |where {$_.FloppyImagePath -ne $null}|set-FloppyDrive -nomedia -Confirm:$Falseget-FloppyDrive -VM * |where {$_.HOSTDevice -ne $null}|set-FloppyDrive -nomedia -Confirm:$False

Coding

Syntax highlighting in blogger

Posted on

http://www.cyberack.com/2007/07/adding-syntax-highlighter-to-blogger.html List of brushes http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/ Brush name Brush aliases File name ActionScript3 as3, actionscript3 shBrushAS3.js Bash/shell bash, shell shBrushBash.js ColdFusion cf, coldfusion shBrushColdFusion.js C# c-sharp, csharp shBrushCSharp.js C++ cpp, c shBrushCpp.js CSS css shBrushCss.js Delphi delphi, pas, pascal shBrushDelphi.js Diff diff, patch shBrushDiff.js Erlang erl, erlang shBrushErlang.js Groovy groovy shBrushGroovy.js JavaScript js, jscript, javascript shBrushJScript.js […]

Coding

VBScript to list the OS Version of all computers in domain

Posted on

In a large environment, inventory information can quickly be out of date. Below is a script that searches AD for all computers and then reports the OS from each system. The OS information comes from the target computer, so firewalls and power state is important. ‘OSVersion.vbson error resume nextConst ADS_SCOPE_SUBTREE = 2strDomain = “mydomain.com”Set objConnection […]

Coding

VBScript to list file owner and other attributes

Posted on

Occasionally I need to look at the owner of a file or group of files. The below script helps me enumerate a folder and list the file attributes ‘GetOwner.vbsSet objShell = CreateObject (“Shell.Application”)Set objFolder = objShell.Namespace (“D:toolsAD”)Set objFSO = CreateObject(“Scripting.FileSystemObject”)Dim arrHeaders(13)For i = 0 to 13    arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)NextFor Each strFileName in objFolder.Items    […]

Coding

VBScript to enumerate domain computers

Posted on

Ever need to list all the computers in your Active Directory? This handy script will query AD and return all computer objects. A little tweaking and you can search for objects based on last modified time to ensure you are listing valid AD objects. ‘EnumComputers.vbsConst ADS_SCOPE_SUBTREE = 2strDomain = “mydomain.com”Set objConnection = CreateObject(“ADODB.Connection”)Set objCommand =   […]