<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A. Mikkelsen</title>
	<atom:link href="http://www.amikkelsen.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.amikkelsen.com</link>
	<description>VMware ESX scripts, commands, tools and other nice to know things that will make your virtualization days easier!!!!</description>
	<lastBuildDate>Sun, 18 Jul 2010 20:23:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Upgrading ESXi 3.x/4.0 to 4.1 &#8211; “Failed to read the upgrade package metadata.xml”</title>
		<link>http://www.amikkelsen.com/?p=478</link>
		<comments>http://www.amikkelsen.com/?p=478#comments</comments>
		<pubDate>Sun, 18 Jul 2010 20:16:38 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[ESX Migrate/Upgrade]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[4.0]]></category>
		<category><![CDATA[4.1]]></category>
		<category><![CDATA[cim.vgz]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[esxi]]></category>
		<category><![CDATA[esxupdate]]></category>
		<category><![CDATA[failed to read the upgrade package medata.xml]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[hostupdate utility]]></category>
		<category><![CDATA[metadata.zip]]></category>
		<category><![CDATA[rcli]]></category>
		<category><![CDATA[remote cli]]></category>
		<category><![CDATA[unsupported]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=478</guid>
		<description><![CDATA[Friday I was at a customer to upgrade their ESXi 4.0 (free) to version 4.1.
This should have been an easy task, download CD, burn it and install.
This wasn&#8217;t the case, the new ESXi 4.1 wouldn&#8217;t install, it kept freezing during the extract of the cim.vgz file.
The problem occurred on both the Dell custom of ESXi [...]]]></description>
			<content:encoded><![CDATA[<p>Friday I was at a customer to upgrade their ESXi 4.0 (free) to version 4.1.<br />
This should have been an easy task, download CD, burn it and install.</p>
<p>This wasn&#8217;t the case, the new ESXi 4.1 wouldn&#8217;t install, it kept freezing during the extract of the cim.vgz file.<br />
The problem occurred on both the Dell custom of ESXi 4.0 U1 and the standard ESXi 4.1.<br />
We googled and googled but didn&#8217;t find a solution &#8211; in the end we blamed the error on the old bios version 1.1.4.</p>
<p>To my luck the customer still had the CD we installed the server with 9 months ago &#8211; ESXi 4.0.</p>
<p>We installed ESXi using the old CD and then everything was working &#8211; but we still needed to upgrade to ESXi 4.1.</p>
<p>So now what to do &#8230;&#8230;.</p>
<p>Normally you use the hostupdate utility or the Remote CLI but the hostupdate utility is not included in the free version of ESXi and the we didn&#8217;t want to install the Remote CLI on the computer.<br />
To my luck I had the hostupdate utility installed but i kept getting this error when trying to upgrade the ESXi host.</p>
<pre>“Failed to read the upgrade package metadata.xml”</pre>
<p><strong>The solution to our problem was:</strong></p>
<ol>
<li>Since it was a ESXi free with out support, we decided to use the &#8220;ESXi  command line interface&#8221;, witch is unsupported.<br />
Follow this guide to enable it (<a href="http://www.bauer-power.net/2010/04/vmware-esxi-hack-to-allow-ssh.html" target="_blank">http://www.bauer-power.net/2010/04/vmware-esxi-hack-to-allow-ssh.html</a>).</li>
<li>Download and extract the upgrade ZIP file from VMware.</li>
<li>From the VIclient, upload the extracted files to the host datastore, using the &#8220;datastore browser&#8221;<br />
- I uploaded the files to a folder named &#8220;upgrade&#8221;</li>
<li>Put the ESXi host in &#8220;Maintance Mode&#8221;<br />
- Since it is a ESXi, this can only be done when all VM&#8217;s are powered off.</li>
<li>Connect the the ESXi console using ex. Putty.exe.</li>
<li>Navigate to the upgrade directory.
<pre>cd /vmfs/volumes/local-datastore/upgrade</pre>
</li>
<li>Begin the upgrade process
<pre>esxupdate update -m metadata.zip
<a href="http://www.amikkelsen.com/images/esxi_upgrade_cos.jpg"><img class="alignnone" title="ESXi commandline" src="http://www.amikkelsen.com/images/esxi_upgrade_cos.jpg" alt="" width="602" height="247" /></a></pre>
</li>
<li>When the upgrade is finished, reboot the host.
<pre>reboot</pre>
</li>
<li>To verify the new build number:<br />
- Connect to the host using the VIclient<br />
- Select the host<br />
- Choose the &#8220;Summery&#8221; tab<br />
- Verify that the ESXi version number and build has been updated</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=478</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Powershell &#8211; vRanger Automated is now avaiable for download</title>
		<link>http://www.amikkelsen.com/?p=475</link>
		<comments>http://www.amikkelsen.com/?p=475#comments</comments>
		<pubDate>Tue, 22 Jun 2010 19:57:51 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[PowerCLI Scripts]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[vRanger]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=475</guid>
		<description><![CDATA[Just released the complete powershell script to control vRanger backup from vCenter.
Read about the script and it&#8217;s features here.
Download it here.
]]></description>
			<content:encoded><![CDATA[<p>Just released the complete powershell script to control vRanger backup from vCenter.</p>
<p>Read about the script and it&#8217;s features <a title="View features" href="http://www.amikkelsen.com/?p=437" target="_self">here</a>.</p>
<p>Download it <a title="Download File" href="http://www.amikkelsen.com/?dl_id=26" target="_self">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=475</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell &#8211; Check if a service is running</title>
		<link>http://www.amikkelsen.com/?p=472</link>
		<comments>http://www.amikkelsen.com/?p=472#comments</comments>
		<pubDate>Fri, 18 Jun 2010 08:22:30 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[servicce]]></category>
		<category><![CDATA[vcenter]]></category>
		<category><![CDATA[virtualcenter]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=472</guid>
		<description><![CDATA[If you ever have experienced that after your vCenter server reboots &#8211; due to Windows updates, the &#8220;VMware VirtualCenter Server&#8221; service is not starting?
I have seen it a few times and every time it&#8217;s during a weekend  
So to make sure your vCenter service (or other) is always running you could use this powershell [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever have experienced that after your vCenter server reboots &#8211; due to Windows updates, the &#8220;VMware VirtualCenter Server&#8221; service is not starting?</p>
<p>I have seen it a few times and every time it&#8217;s during a weekend <img src='http://www.amikkelsen.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>So to make sure your vCenter service (or other) is always running you could use this powershell script to check if a service is running, and if not start it.<br />
To make sure you know if the service wasn&#8217;t started after a reboot or other cause, I have added a mail function to the script <img src='http://www.amikkelsen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<pre class="brush: powershell;">
function FuncCheckService{
    param($ServiceName)
    $arrService = Get-Service -Name $ServiceName
    if ($arrService.Status -ne &quot;Running&quot;){
        Start-Service $ServiceName
        FuncMail -To &quot;to-email@domain.com&quot; -From &quot;from-mail@domain.com&quot;  -Subject &quot;Servername : ($ServiceName) service started.&quot; -Body &quot;Service $ServiceName started&quot; -smtpServer &quot;relay.mailserver.com&quot;
    }
}

function FuncMail {
    #param($strTo, $strFrom, $strSubject, $strBody, $smtpServer)
    param($To, $From, $Subject, $Body, $smtpServer)
    $msg = new-object Net.Mail.MailMessage
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $msg.From = $From
    $msg.To.Add($To)
    $msg.Subject = $Subject
    $msg.IsBodyHtml = 1
    $msg.Body = $Body
    $smtp.Send($msg)
}

FuncCheckService -ServiceName &quot;VMware VirtualCenter Server&quot;
</pre>
<p>Create a PS1 file and schedule it to run every 15 or 30 minutes.</p>
<p>It works great and is simple&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=472</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell &#8211; Configure NTP server list</title>
		<link>http://www.amikkelsen.com/?p=458</link>
		<comments>http://www.amikkelsen.com/?p=458#comments</comments>
		<pubDate>Thu, 17 Jun 2010 19:42:08 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[add-VMHostNtpServer]]></category>
		<category><![CDATA[add-VMHostService]]></category>
		<category><![CDATA[Get-VmhostFirewallException]]></category>
		<category><![CDATA[Get-VMHostNtpServer]]></category>
		<category><![CDATA[get-VMHostService]]></category>
		<category><![CDATA[ntp]]></category>
		<category><![CDATA[remove-VMHostNtpServer]]></category>
		<category><![CDATA[restart-VMHostService]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=458</guid>
		<description><![CDATA[If you want to configure a hosts NTP server list through PowerCLI you have a few cmdlet at your disposal.

Get-VMHostNtpServer
Remove-VMHostNtpServer
Add-VMHostNtpServer
Get-VMHostService
Set-VMHostService
Get-VmhostFirewallException
Restart-VMHostService

Get a list of NTP servers on a host.

Get-VMHostNtpServer -VMHost &#34;esx01.lab.local&#34;

To remove a specific NTP server from a host NTP server list.

Remove-VMHostNtpServer -VMHost &#34;esx01.lab.local&#34; -NtpServer '127.127.1.0' -Confirm:$false

To remove all NTP servers on a hosts NTP server [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to configure a hosts NTP server list through PowerCLI you have a few cmdlet at your disposal.</p>
<ul>
<li>Get-VMHostNtpServer</li>
<li>Remove-VMHostNtpServer</li>
<li>Add-VMHostNtpServer</li>
<li>Get-VMHostService</li>
<li>Set-VMHostService</li>
<li>Get-VmhostFirewallException</li>
<li>Restart-VMHostService</li>
</ul>
<p>Get a list of NTP servers on a host.</p>
<pre class="brush: powershell;">
Get-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot;
</pre>
<p>To remove a specific NTP server from a host NTP server list.</p>
<pre class="brush: powershell;">
Remove-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; -NtpServer '127.127.1.0' -Confirm:$false
</pre>
<p>To remove all NTP servers on a hosts NTP server list.</p>
<pre class="brush: powershell;">
$arrNTPList = Get-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot;
Remove-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; -NtpServer $arrNTPList -Confirm:$false
</pre>
<p>To add a single NTP server to a hosts NTP server list.</p>
<pre class="brush: powershell;">
Add-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; -NtpServer &quot;dk.pool.ntp.org&quot; -Confirm:$false
</pre>
<p>To add a a list of NTP servers to a hosts NTP server list.</p>
<pre class="brush: powershell;">
$arrNTPServers = (&quot;dk.pool.ntp.org&quot;,&quot;de.pool.ntp.org&quot;,&quot;us.pool.ntp.org&quot;)
Add-VMHostNtpServer -VMHost &quot;esx01.lab.local&quot; -NtpServer $arrNTPServers -Confirm:$false
</pre>
<p>To set the NTP deamon (service) to start automatic.</p>
<pre class="brush: powershell;">
Set-VMHostService -HostService (Get-VMHostservice -VMHost (Get-VMHost &quot;esx01.lab.local&quot;) | Where-Object {$_.key -eq &quot;ntpd&quot;}) -Policy &quot;Automatic&quot;
</pre>
<p>Open firewall to allow the NTP deamon to communicate with the NTP server.</p>
<pre class="brush: powershell;">
Get-VmhostFirewallException -VMHost &quot;esx01.lab.local&quot; -Name &quot;NTP Client&quot; | Set-VMHostFirewallException -enabled:$true
</pre>
<p>To restart the NTP deamon (service) after you have configured it &#8211; without restarting the host.</p>
<pre class="brush: powershell;">
$ntpd = Get-VMHostService -VMHost &quot;esx01.lab.local&quot; | where {$_.Key -eq 'ntpd'}
Restart-VMHostService $ntpd -Confirm:$false
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=458</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with the vRanger 4.5 vAPI (Powershell :-))</title>
		<link>http://www.amikkelsen.com/?p=437</link>
		<comments>http://www.amikkelsen.com/?p=437#comments</comments>
		<pubDate>Sun, 13 Jun 2010 21:52:22 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[PowerCLI Scripts]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[vRanger]]></category>
		<category><![CDATA[cmdlet]]></category>
		<category><![CDATA[vcenter]]></category>
		<category><![CDATA[vizioncore]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=437</guid>
		<description><![CDATA[Since Vizioncore came out with vRanger 4.x, last year, I been working on porting the VBS script &#8220;vRanger Script version 2.0&#8221; to Powershell.
During this time I have found several bugs/missing functionality in the vAPI.
Vizioncore have corrected the bugs with new releases of vRanger.
The first vRanger version where all vAPI cmdlets worked in was version 4.2.3.
Porting [...]]]></description>
			<content:encoded><![CDATA[<p>Since Vizioncore came out with vRanger 4.x, last year, I been working on porting the VBS script &#8220;<a href="http://www.amikkelsen.com/?p=74">vRanger Script version 2.0</a>&#8221; to Powershell.<br />
During this time I have found several bugs/missing functionality in the vAPI.<br />
Vizioncore have corrected the bugs with new releases of vRanger.<br />
The first vRanger version where all vAPI cmdlets worked in was version 4.2.3.</p>
<p><strong>Porting the script from VBS presented me with a few challenges.</strong></p>
<ul>
<li>A reported error in the Get-Date cmdlet in Powershel 2.0.<br />
Had to use a workaround.</li>
</ul>
<p><strong>A few words on the scrips functionality.</strong></p>
<ul>
<li>Control vRanger backups from vCenter (simple &#8211; one interface).</li>
<li>Perform a FULL backup of DiskO of a VM.</li>
<li>Perform a FULL backup of all disks of a VM.</li>
<li>Backup a VM on a specific weekday.</li>
<li>Control what week (Even/Odd).</li>
<li>Create a log file.</li>
<li>Delete previous backup files from repository.</li>
<li>Delete previous savepoints.</li>
<li>Send an email when the jobs are completed &#8211; incl. succes/errors.</li>
<li>Offload the files to tape &#8211; TSM</li>
<li>Send mail when TSM is finished offloading backup files.</li>
<li>And many more&#8230;..</li>
</ul>
<p>When I started coding the script, I found, that if I used functions for all functionality the script was easier to read. Using functions also supplied me with the opportunity of reusing functions &#8211; less work <img src='http://www.amikkelsen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>Some of the functions was created using examples posted and mailed by Scott Harold from <a href="http://www.quest.com" target="_blank">Quest</a> and <a href="http://www.thevesi.org" target="_blank">TheVesi./vEcoShell</a>.</p>
<p><strong>Prerequirements</strong></p>
<ul>
<li><a href="http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx" target="_blank">Powershell 1.0 or 2.0 form Microsoft</a>.</li>
<li><a href="http://www.vizioncore.com/products/vRangerPro/index.php" target="_blank">Vizioncore vRanger 4.x</a></li>
<li>A VMware vCenter server, a host and a few VMs.</li>
</ul>
<p><strong><span style="color: #ff0000;">The script can be downloaded <a title="Download File" href="http://www.amikkelsen.com/?dl_id=26" target="_self">here</a>.<br />
</span></strong></p>
<p><strong>A quick overview of the functions.</strong><br />
Include the right PSSnapins</p>
<pre class="brush: powershell;">
function LoadSnapin{
    Add-PSSnapin vRanger.API.PowerShell -ErrorAction SilentlyContinue
    Add-PSSnapin vmware.VimAutomation.core -ErrorAction SilentlyContinue
}

LoadSnapin
</pre>
<p>Delete all previous savepoints &#8211; from the repository.</p>
<pre class="brush: powershell;">
function RemoveAllSavePoints{
	param ($RASP_RepoName)
	$RASP_repoID = Get-Repository | where {$_.Name -eq $RASP_RepoName}
	$RASP_SPlist = Get-RepositorySavePoint -ID $RASP_repoID.Id

	foreach ($RASP_SP in $RASP_SPlist){
		#write $RASP_SP
		Remove-SavePoint -SavePointsToRemove $RASP_SP
	}
}

RemoveAllSavePoints &quot;Remote-Location&quot;
</pre>
<p>Is a backup job exist with the same name as the one to create &#8211; delete it.</p>
<pre class="brush: powershell;">
function Del-vRangerBackupJobs {
	param ($delJobName)
	$delTemplateID = Get-JobTemplate | where {$_.JobName -eq $delJobName}
	# Verify that a BackupJob named XXX is present before deleting it.
	if ($delTemplateID){
		#write $delTemplateID.JobName
		Remove-JobTemplate -id $delTemplateID.Id
	}
}

Del-vRangerBackupJobs &quot;$Wednesday-Even&quot;
</pre>
<p>Create the list of VMs to exclude.</p>
<pre class="brush: powershell;">
function Filter-VMbyCF {
    param ($customF, $val)
    foreach ($vm in $vmlist) {
        $vm.CustomFields | ForEach-Object {
            $cf = $_
            if ($_.Key -like $customF -and $_.Value -like $val){
                    return $vm.name
            }
        }
    }
}

function New-vRangerExcludeList {
    param ($exclude, $include)
    $excludeArray = @()
    $exclude | ForEach-Object {
        if ($include -notcontains $_.Name){
            $excludeArray += ($_.Config.Uuid)
        }
    }
    return $excludeArray
}

$vmlist = Get-VM
$tmplist = Get-Template
$vmlist= $vmlist + $tmplist
$vmFilter = Filter-VMbyCF $customField $CFValue
$vmlistview = $vmlist | Get-View
$excludeList = New-vRangerExcludeList -exclude $vmlistview -include $vmFilter
</pre>
<p>Create the new backup job.</p>
<pre class="brush: powershell;">
function New-vRangerBackupJob {
	param ($customJobName, $customCFValue, $customFieldName, $customRepoName, $customExcludeList, $customEmail)
        $jobDesc = &quot;This backup job is created by Logica for use in DR.  All VMs with a Custom Field labeled: $customFieldName with a value of: $customCFValue will be backed up&quot;
        $jobEntity = Get-InventoryEntity -Type VirtualCenter
	$jobRepos = Get-Repository | where {$_.Name -eq $customRepoName}
        $jobFlag = New-BackupFlag -CheckDestinationFreeSpace:$true -UseCompression:$true -PerformNetworkBackupOnFailure:$true

	# Check if all disks or just disk 0
	if ($customJobName -like &quot;*-All*&quot;){
		#write &quot;All - Disks&quot;
		#Add-BackupJobTemplate -JobName $customJobName -JobDescription $jobDesc -JobEntity $jobEntity -ExcludedVMList $customExcludeList -NotificationList $email -TargetRepository $jobRepos -Flags $jobFlag -NumberOfSavePoints 1 -SpaceSavingTechnologyTypeFlag None
		Add-BackupJobTemplate -JobName $customJobName -JobDescription $jobDesc -JobEntity $jobEntity -ExcludedVMList $customExcludeList -NotificationList $customEmail -TargetRepository $jobRepos -Flags $jobFlag -NumberOfSavePoints 1 -SpaceSavingTechnologyTypeFlag None -SpaceSavingCountThreshold 6 -SpaceSavingPercentSizeThreshold 50
	}
	else{
		#write &quot;Only Disk 0&quot;
		#Add-BackupJobTemplate -JobName $customJobName -JobDescription $jobDesc -JobEntity $jobEntity -ExcludedVMList $customExcludeList -NotificationList $email -IncludedDiskList 0 -TargetRepository $jobRepos -Flags $jobFlag -NumberOfSavePoints 1 -SpaceSavingTechnologyTypeFlag None
		Add-BackupJobTemplate -JobName $customJobName -JobDescription $jobDesc -JobEntity $jobEntity -ExcludedVMList $customExcludeList -NotificationList $customEmail -IncludedDiskList 0 -TargetRepository $jobRepos -Flags $jobFlag -NumberOfSavePoints 1 -SpaceSavingTechnologyTypeFlag None -SpaceSavingCountThreshold 6 -SpaceSavingPercentSizeThreshold 50
	}
}

New-vRangerBackupJob &quot;Wednesday-Even&quot; &quot;Wednesday-Even&quot; &quot;Backup&quot; &quot;Remote-Location&quot; $excludeList &quot;to@email.com&quot;
</pre>
<p>Start the backup job.</p>
<pre class="brush: powershell;">
function Run-BackupJob{
	param ($runJobName)
	$runTemplateID = Get-TemplateID $runJobName
	Run-JobsNow $runTemplateID
}

Run-BackupJob &quot;Wednesday-Even&quot;
</pre>
<p>Wait for the backup job to finish.</p>
<pre class="brush: powershell;">
function Get-TemplateID{
	param($tmpJobName)
	$arrTemplate = get-jobtemplate | where {$_.JobName -eq $tmpJobName}
	return $arrTemplate.ID
}

function WaitForJobToFinish{
	param ($strWaitJob)
	$strCompleted = &quot;NotStarted&quot;
        Start-Sleep -Seconds 300	# 5 minutes
	$jobTemplates = get-JobTemplate | where {$_.JobName -eq $strWaitJob}
	foreach ($job in $jobTemplates){
		do{
			$tasksinfo = get-job |where {$_.ParentJobTemplateID -eq $job.TemplateVersionID}
			foreach ($task in $tasksinfo){
				Start-Sleep -Seconds 300	# 5 minutes
				$strCompleted = $task.JobState

                # Make sure job is running - if not start it...
                if ($task.JobState -eq $NULL -or $task.JobState -eq &quot;NotStarted&quot;){
                    Run-BackupJob $strWaitJob
                    Start-Sleep -Seconds 120	# 2 minutes
                }
			}
		}
		while ($strCompleted -notmatch &quot;Completed&quot;)
	}
}

WaitForJobToFinish &quot;Wednesday-Even&quot;
</pre>
<p>Send TSM finished mail.</p>
<pre class="brush: powershell;">
function FuncMail {
	#param($strTo, $strFrom, $strSubject, $strBody, $smtpServer)
	param($To, $From, $Subject, $Body, $smtpServer)

	$msg = new-object Net.Mail.MailMessage
	$smtp = new-object Net.Mail.SmtpClient($smtpServer)
	$msg.From = $From
	$msg.To.Add($To)
	$msg.Subject = $Subject
	$msg.IsBodyHtml = 1
	$msg.Body = $Body
	$smtp.Send($msg)
}

FuncMail -To &quot;to@email.com&quot; -From &quot;from@email.com&quot; -Subject &quot;vRanger Pro: TSM backup finished&quot; -Body &quot;Your Body&quot; -smtpServer &quot;your.mailserver.com&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=437</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Smart and simple backup script with PowerCLI</title>
		<link>http://www.amikkelsen.com/?p=415</link>
		<comments>http://www.amikkelsen.com/?p=415#comments</comments>
		<pubDate>Mon, 24 May 2010 20:32:49 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[PowerCLI Scripts]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[backip]]></category>
		<category><![CDATA[backupscriot]]></category>
		<category><![CDATA[clone]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[powercli]]></category>
		<category><![CDATA[powershel]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[snapshot]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=415</guid>
		<description><![CDATA[A friend on the Danish VMUG pointed me towards this simple backup script, from GestaltIT.com.
http://gestaltit.com/all/tech/virtualization/simon/vmware-backup-powercli-script/
The script creates a snapshot of a VM (from a CSV file) and creates a Thin Provisioned clone based on the snapshot, on a specified datastore (from the CSV file).
This a smart and simple way to create a backup of a [...]]]></description>
			<content:encoded><![CDATA[<p>A friend on the Danish VMUG pointed me towards this simple backup script, from <a href="http://GestaltIT.com" target="_blank">GestaltIT.com</a>.<br />
<a href="http://gestaltit.com/all/tech/virtualization/simon/vmware-backup-powercli-script/" target="_blank">http://gestaltit.com/all/tech/virtualization/simon/vmware-backup-powercli-script/</a></p>
<p>The script creates a snapshot of a VM (from a CSV file) and creates a Thin Provisioned clone based on the snapshot, on a specified datastore (from the CSV file).</p>
<p>This a smart and simple way to create a backup of a list of VM&#8217;s.</p>
<p>It&#8217;s a must read for PowerCLI users.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=415</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vSphere 4.0 Hardening Guide Released</title>
		<link>http://www.amikkelsen.com/?p=409</link>
		<comments>http://www.amikkelsen.com/?p=409#comments</comments>
		<pubDate>Tue, 11 May 2010 08:18:55 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[vsphere]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=409</guid>
		<description><![CDATA[VMware has released their hardening guide for vSphere 4.0.
There is more than 100 guidelines to choose from, divided between

Introduction
Virtual Machines
Host (both ESXi and ESX)
vNetwork
vCenter
Console OS (for ESX only)

http://blogs.vmware.com/security/2010/04/vsphere-40-hardening-guide-released.html
]]></description>
			<content:encoded><![CDATA[<p>VMware has released their hardening guide for vSphere 4.0.</p>
<p>There is more than 100 guidelines to choose from, divided between</p>
<ul>
<li>Introduction</li>
<li>Virtual Machines</li>
<li>Host (both ESXi and ESX)</li>
<li>vNetwork</li>
<li>vCenter</li>
<li>Console OS (for ESX only)</li>
</ul>
<p><a href="http://blogs.vmware.com/security/2010/04/vsphere-40-hardening-guide-released.html" target="_self">http://blogs.vmware.com/security/2010/04/vsphere-40-hardening-guide-released.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=409</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A must have</title>
		<link>http://www.amikkelsen.com/?p=405</link>
		<comments>http://www.amikkelsen.com/?p=405#comments</comments>
		<pubDate>Thu, 29 Apr 2010 10:56:35 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[toolbar]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=405</guid>
		<description><![CDATA[For all us VMware fan boys/girls this toolbar is a must&#8230;

Download it from vmwaresupport.toolbar.fm
]]></description>
			<content:encoded><![CDATA[<p>For all us VMware fan boys/girls this toolbar is a must&#8230;</p>
<p><a href="HTTP://www.amikkelsen.com/images/vmwaretoolbar.JPG"><img class="alignnone" title="VMware Toolbr" src="HTTP://www.amikkelsen.com/images/vmwaretoolbar.JPG" alt="" width="545" height="29" /></a></p>
<h4>Download it from <a href="http://vmwaresupport.toolbar.fm" target="_blank">vmwaresupport.toolbar.fm</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=405</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Time keeping in a virtual enviroment</title>
		<link>http://www.amikkelsen.com/?p=396</link>
		<comments>http://www.amikkelsen.com/?p=396#comments</comments>
		<pubDate>Fri, 09 Apr 2010 09:09:49 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[ESXi]]></category>
		<category><![CDATA[vSphere (ESX)]]></category>
		<category><![CDATA[esx]]></category>
		<category><![CDATA[esxi]]></category>
		<category><![CDATA[timekeeping]]></category>
		<category><![CDATA[vm]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[vsphere]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=396</guid>
		<description><![CDATA[Time keeping in a virtual environment can be a challenge to setup.
To help you, VMware has maintained a KB on the subject.
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&#38;cmd=displayKC&#38;externalId=1318
The KB presents  best practices for achieving accurate timekeeping in Windows Guest  operating systems. These recommendations include a suggested  configuration for timesynchronization in the guest and on the host.
A more specific [...]]]></description>
			<content:encoded><![CDATA[<p>Time keeping in a virtual environment can be a challenge to setup.</p>
<p>To help you, VMware has maintained a KB on the subject.<a href="http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1318" target="_blank"></p>
<p>http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1318</a></p>
<p>The KB presents  best practices for achieving accurate timekeeping in Windows Guest  operating systems. These recommendations include a suggested  configuration for timesynchronization in the guest and on the host.</p>
<p>A more specific guide also exists for Windows and Linux servers:<br />
For Windows read:<br />
<a href="http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&amp;docType=kc&amp;externalId=1318&amp;sliceId=1&amp;docTypeID=DT_KB_1_1&amp;dialogID=73678717&amp;stateId=0%200%2078515868" target="_blank">http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&amp;docType=kc&amp;externalId=1318&amp;sliceId=1&amp;docTypeID=DT_KB_1_1&amp;dialogID=73678717&amp;stateId=0%200%2078515868</a><br />
For Linux read:<br />
<a href="http://kb.vmware.com/selfservice/microsites/microsite.do?cmd=displayKCPopup&amp;docType=kc&amp;externalId=1006427&amp;sliceId=1&amp;docTypeID=DT_KB_1_1" target="_blank"> http://kb.vmware.com/selfservice/microsites/microsite.do?cmd=displayKCPopup&amp;docType=kc&amp;externalId=1006427&amp;sliceId=1&amp;docTypeID=DT_KB_1_1</a></p>
<p>It&#8217;s great reading, but very nerdy <img src='http://www.amikkelsen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=396</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Must Have &#8211; Powershell PodCasts</title>
		<link>http://www.amikkelsen.com/?p=392</link>
		<comments>http://www.amikkelsen.com/?p=392#comments</comments>
		<pubDate>Thu, 18 Mar 2010 12:39:08 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[PodCasts (PS)]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[get-scripting]]></category>
		<category><![CDATA[podcast]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=392</guid>
		<description><![CDATA[A few weeks ago I came across a podcast on http://get-scripting.blogspot.com about Powershell.
I highly recommend that all people using powershell check it out.
Get the latest and the archived podcasts at
http://get-scripting.blogspot.com/search/label/podcast
]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I came across a podcast on <a href="http://get-scripting.blogspot.com" target="_blank">http://get-scripting.blogspot.com</a> about Powershell.</p>
<p>I highly recommend that all people using powershell check it out.</p>
<p>Get the latest and the archived podcasts at<br />
<a href="http://get-scripting.blogspot.com/search/label/podcast" target="_blank">http://get-scripting.blogspot.com/search/label/podcast</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=392</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New layout</title>
		<link>http://www.amikkelsen.com/?p=389</link>
		<comments>http://www.amikkelsen.com/?p=389#comments</comments>
		<pubDate>Mon, 15 Mar 2010 19:58:30 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=389</guid>
		<description><![CDATA[Today I had to change the theme because the old theme, wasn&#8217;t compatible with the latest version of Wordpress.org.
I hope you like it, I&#8217;ll try to personalize it during the next couple of weeks  .
]]></description>
			<content:encoded><![CDATA[<p>Today I had to change the theme because the old theme, wasn&#8217;t compatible with the latest version of Wordpress.org.</p>
<p>I hope you like it, I&#8217;ll try to personalize it during the next couple of weeks <img src='http://www.amikkelsen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=389</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Powershell &#8211; List all vCenter client sessions &amp; disconnect if inactive</title>
		<link>http://www.amikkelsen.com/?p=384</link>
		<comments>http://www.amikkelsen.com/?p=384#comments</comments>
		<pubDate>Wed, 10 Mar 2010 13:25:16 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Virtual Center]]></category>
		<category><![CDATA[discinnect]]></category>
		<category><![CDATA[inactive]]></category>
		<category><![CDATA[sessions]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=384</guid>
		<description><![CDATA[Today I needed to create a list of all users connected to a vCenter sever through the Client.
And during so I created a few variants  
This creates a list of all usernames connected to the vCenter server through a vCenter Client.
$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
foreach [...]]]></description>
			<content:encoded><![CDATA[<p>Today I needed to create a list of all users connected to a vCenter sever through the Client.<br />
And during so I created a few variants <img src='http://www.amikkelsen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>This creates a list of all usernames connected to the vCenter server through a vCenter Client.</strong></p>
<pre><span style="color: #0000ff;">$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
foreach ($sess in $sessMgr.SessionList){
   write "$($sess.UserName)"
}</span></pre>
<p><strong>If you want to see a witch clients have been idle for 60 minutes try this.</strong></p>
<pre><span style="color: #0000ff;">$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
foreach ($sess in $sessMgr.SessionList){
    if (($sess.LastActiveTime).addminutes(60) -lt (Get-Date)){
        write "$($sess.UserName)"
      }
}</span></pre>
<p><strong>If you the want to terminate the sessions that have been inactive  for more than 60 minute</strong></p>
<pre><span style="color: #0000ff;">$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
$oldSessions = @()
foreach ($sess in $sessMgr.SessionList){
    if (($sess.LastActiveTime).addminutes(60) -lt (Get-Date)){
        $oldSessions += $sess.Key
      }
}
$sessMgr.TerminateSession($oldSessions)</span></pre>
<p>You can modify the hell out of this script to suit your needs and be my guest&#8230;.</p>
<p>You can download the full script <a href="http://www.amikkelsen.com/?page_id=307" target="_self">here</a>.</p>
<p>The scripts are based on code found  at the PowerCLI community by <a href="http://www.lucd.info" target="_blank">LucD</a>.<br />
<a href="http://communities.vmware.com/message/914858#914858" target="_blank">http://communities.vmware.com/message/914858#914858</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=384</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ESXHealthScript release 49</title>
		<link>http://www.amikkelsen.com/?p=381</link>
		<comments>http://www.amikkelsen.com/?p=381#comments</comments>
		<pubDate>Fri, 26 Feb 2010 17:08:24 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[ESX HealthCheck]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[esx]]></category>
		<category><![CDATA[esxhealthscript]]></category>
		<category><![CDATA[health]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=381</guid>
		<description><![CDATA[Yesterday we released version 49 of the ESXHealthScript.
Kenneth Mazie. (kcmazie aka. kcmjr) has done a huge job in updating and adding new features to the script.

Added automatic detection for ESX 3 or ESX 4
Added corrections for changes with ESX4
Added Cisco CDP info listing (from user Carson)
Added corrections to v4 tomcat server

To read more about the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday we released version 49 of the <a href="https://sourceforge.net/projects/esxhealthscript/" target="_blank">ESXHealthScript</a>.</p>
<p>Kenneth Mazie. (kcmazie aka. <a href="https://sourceforge.net/users/kcmjr">kcmjr</a>) has done a huge job in updating and adding new features to the script.</p>
<ul>
<li>Added automatic detection for ESX 3 or ESX 4</li>
<li>Added corrections for changes with ESX4</li>
<li>Added Cisco CDP info listing (from user Carson)</li>
<li>Added corrections to v4 tomcat server</li>
</ul>
<p>To read more about the ESXHealthScript please visit the project web site.<br />
<a href="https://sourceforge.net/projects/esxhealthscript/">https://sourceforge.net/projects/esxhealthscript/</a></p>
<p>If you are using the script, and have ideas for new features/functions, please let us know on the projects website or even better post the needed code <img src='http://www.amikkelsen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=381</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>vLogView by Xtravirt</title>
		<link>http://www.amikkelsen.com/?p=367</link>
		<comments>http://www.amikkelsen.com/?p=367#comments</comments>
		<pubDate>Sun, 31 Jan 2010 22:41:16 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[vSphere (ESX)]]></category>
		<category><![CDATA[esx]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[vlogview]]></category>
		<category><![CDATA[vsphere]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=367</guid>
		<description><![CDATA[vLogView, helps you view and search all LOG files from each of your ESX hosts from a single application.
For more info and the latest download, visit http://xtravirt.com/xd10132

]]></description>
			<content:encoded><![CDATA[<p>vLogView, helps you view and search all LOG files from each of your ESX hosts from a single application.</p>
<p>For more info and the latest download, visit <a href="http://xtravirt.com/xd10132" target="_blank">http://xtravirt.com/xd10132</a></p>
<p><img class="alignnone size-medium wp-image-368" title="vlogview" src="http://www.amikkelsen.com/files/vlogview-300x171.jpg" alt="vlogview" width="300" height="171" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=367</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with PowerCLI</title>
		<link>http://www.amikkelsen.com/?p=357</link>
		<comments>http://www.amikkelsen.com/?p=357#comments</comments>
		<pubDate>Sun, 31 Jan 2010 20:45:37 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[copy-vmguestfile]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[invoke-vmscript]]></category>
		<category><![CDATA[powercli]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[vm]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=357</guid>
		<description><![CDATA[Last week I attended a Magirus course on administrating you VMware environment using PowerCLI, and below is some of the small scripts I created.
These code sniplets will help you manage your VMware environment and give you some ideas of how powerful the VMware PowerCLI really is.
I&#8217;m sure VMware will add even more CMDLETS to the [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I attended a Magirus course on administrating you VMware environment using PowerCLI, and below is some of the small scripts I created.</p>
<p>These code sniplets will help you manage your VMware environment and give you some ideas of how powerful the VMware PowerCLI really is.</p>
<p>I&#8217;m sure VMware will add even more CMDLETS to the PowerCLI in the feature.</p>
<p>Get the latest PowerCLI <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/windows_toolkit" target="_blank">here</a>.<br />
<strong>A function to load different PSSnapins.<br />
<span style="color: #ff0000;">Put it in the beginning of all you Powershell scripts,<br />
to load the different PSSnapin you need.<br />
</span></strong></p>
<pre><span style="color: #0000ff;">
function LoadSnapin{
  param($PSSnapinName)
  if (!(Get-PSSnapin | where {$_.Name   -eq $PSSnapinName})){
    Add-pssnapin -name $PSSnapinName
  }
}
LoadSnapin -PSSnapinName   "VMware.VimAutomation.Core"
</span></pre>
<p><strong>Clone a VM to template.</strong></p>
<pre><span style="color: #0000ff;">
$VMToClone = "vm_name"
$TemplateName = "TemplateName"
$Datacenter = "Training"
get-vm $VMToClone| stop-vm
New-Template -VM $VMToClone -Name $TemplateName
   -Location $(Get-Datacenter $Datacenter)
</span></pre>
<p><strong>Convert Template to VM &#8211; without changing the name.</strong></p>
<pre><span style="color: #0000ff;">
$TemplateName = "TemplateName"
Set-Template -Template $(get-template $TemplateName) -ToVM
</span></pre>
<p><strong>Convert VM to Template &#8211; without changing the name.</strong></p>
<pre><span style="color: #0000ff;">
$VMtoTemplate = "vm_name"
$vm = Get-VM $VMtoTemplate | Get-View
$vm.MarkAsTemplate()
</span></pre>
<p><strong>Deploying a VM from template.</strong></p>
<pre><span style="color: #0000ff;">
$strNewVMName = "NewVM_01"
$strTemplate = "TemplateName"
$strDestinationHost = "ESX01"
New-VM -Name $strNewVMName -Template $(get-template   $strTemplate)
   -VMHost $(Get-VMHost $strDestinationHost)
</span></pre>
<p><strong>Deploying a VM from template using a Customization Specification and using Thin provisioning.<br />
<span style="color: #ff0000;">Make sure the CustomSpec has been created beforehand.</span></strong></p>
<pre><span style="color: #0000ff;">
$strNewVMName = "NewVM_01"
$strTemplate = "TemplateName"
$strDestinationHost = "ESX01"
$strCustomSpec = "TEST-CustomSpec"
New-VM -Name $strNewVMName -Template $(get-template $strTemplate)
   -VMHost $(Get-VMHost $strDestinationHost) -DiskStorageFormat
   Thin -OSCustomizationSpec $(Get-OSCustomizationSpec $strCustomSpec)
</span></pre>
<p><strong>Moving a VM to a specific folder.</strong></p>
<pre><span style="color: #0000ff;">
$strDistinationFolder = "MyFolder"
$strDatacenter = "Training"
$VMToMove = "MyVM"
move-vm -VM $(get-vm $VMToMove) -Destination $(Get-Folder
    -Name $strDistinationFolder -Location $(Get-Datacenter $strDatacenter))
</span></pre>
<p><strong>Copying a file to a Windows VM (With or without network access)<br />
<span style="color: #ff0000;">Requires VMware tools to be running.</span></strong></p>
<pre><span style="color: #0000ff;">
$VM = get-vm -name "myVM"
$target = "C:\MY_DIR\"
$source = "C:\MY_DIR\test.txt"
Copy-VMGuestFile -Source $source -Destination $target -vm $VM
   -LocalToGuest -HostUser "root" -HostPassword "password"
   -GuestUser "myVM\administrator" -GuestPassword "password"
   -Force:$true
</span></pre>
<p><strong>Copying a file from a Windows VM (With or without network access)<br />
<span style="color: #ff0000;">Requires VMware tools to be running.</span></strong></p>
<pre><span style="color: #0000ff;">
$VM = get-vm -name "myVM"
$target = "C:\MY_DIR\"
$source = "C:\MY_DIR\test.txt"
Copy-VMGuestFile -Source $source -Destination $target -vm $VM
   -GuestToLocal -HostUser "root" -HostPassword "password"
   -GuestUser "myVM\administrator" -GuestPassword "password"
   -Force:$true
</span></pre>
<p><strong>Listing the content of &#8220;C:\Windows\System32&#8243; from a VM &#8211; remotely</strong></p>
<pre><span style="color: #0000ff;">
$VM = get-vm -name "myVM"
Invoke-VMScript -VM $VM -ScriptText "dir" -HostUser "root"
   -HostPassword "password" -GuestUser "myVM\administrator"
   -GuestPassword "password"
</span></pre>
<p><strong>Run msinfo32 on a guest VM and pipe the output to a TXT file &#8211; Using PowerShell.</strong></p>
<pre><span style="color: #0000ff;">
$VM = get-vm -name "myVM"
$script = '&amp;"$env:ProgramFiles\Common Files\Microsoft Shared\
   MSInfo\msinfo32.exe" /report "$env:Tmp\inforeport.txt"'
Invoke-VMScript -VM $VM -ScriptText $script -HostUser "root"
   -HostPassword "password" -GuestUser "myVM\administrator"
   -GuestPassword "password"
</span></pre>
<p><strong>Open the above output file in the guest VM &#8211; Using PowerShell.</strong></p>
<pre><span style="color: #0000ff;">
$VM = get-vm -name "myVM"
$script = '&amp;"notepad.exe" "$env:Tmp\inforeport.txt"'
Invoke-VMScript -VM $VM -ScriptText $script -HostUser "root"
   -HostPassword "password" -GuestUser "myVM\administrator"
   -GuestPassword "password" -ScriptType Powershell
</span></pre>
<p><strong>Run msinfo32 on a guest VM and pipe the output to a TXT file &#8211; Using batch commands.</strong></p>
<pre><span style="color: #0000ff;">
$VM = get-vm -name "myVM"
$script = '&amp;"%programfiles%\Common Files\Microsoft Shared\
   MSInfo\msinfo32.exe" /report "%tmp%\inforeport.txt"'
Invoke-VMScript -VM $VM -ScriptText $script -HostUser "root"
   -HostPassword "password" -GuestUser "myVM\administrator"
   -GuestPassword "password" -ScriptType Bat
</span></pre>
<p><strong>Open the above output file in the guest VM &#8211; Using batch commands.</strong></p>
<pre><span style="color: #0000ff;">
$VM = get-vm -name "myVM"
$script = '"notepad.exe"   "%Tmp%\inforeport.txt"'
Invoke-VMScript -VM $VM -ScriptText $script -HostUser "root"
   -HostPassword "password" -GuestUser "myVM\administrator"
   -GuestPassword "password" -ScriptType Bat
</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=357</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Interpret the output of ESXTOP in vSphere</title>
		<link>http://www.amikkelsen.com/?p=353</link>
		<comments>http://www.amikkelsen.com/?p=353#comments</comments>
		<pubDate>Wed, 06 Jan 2010 08:39:29 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[vSphere (ESX)]]></category>
		<category><![CDATA[esxtop]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[interpret]]></category>
		<category><![CDATA[statistic]]></category>
		<category><![CDATA[vsphere]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=353</guid>
		<description><![CDATA[If you need a good guide to Interpreting the statistic from ESXTOP then take a look at this guide from VMware.
http://communities.vmware.com/docs/DOC-9279
I&#8217;m using it to troubleshoot performance issues (poor response times) from clients in different locations, when using the remote console.
]]></description>
			<content:encoded><![CDATA[<p>If you need a good guide to Interpreting the statistic from ESXTOP then take a look at this guide from VMware.</p>
<p><a title="esxtop" href="http://communities.vmware.com/docs/DOC-9279" target="_blank">http://communities.vmware.com/docs/DOC-9279</a></p>
<p>I&#8217;m using it to troubleshoot performance issues (poor response times) from clients in different locations, when using the remote console.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=353</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restarting management Agent on ESX 3.x</title>
		<link>http://www.amikkelsen.com/?p=349</link>
		<comments>http://www.amikkelsen.com/?p=349#comments</comments>
		<pubDate>Wed, 25 Nov 2009 20:20:18 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[vSphere (ESX)]]></category>
		<category><![CDATA[agent]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[restart]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=349</guid>
		<description><![CDATA[Restarting the Management agents on ESX Server 3.x

Login to the ESX host using SSH (or from COS)
Type service mgmt-vmware restart.
CAUTION
Before restarting the Management Agent make sure that Automatic Startup/Shutdown is Disabled
For more info see
Restarting hostd (mgmt-vmware) on ESX Server Hosts Restarts Hosted Virtual Machines Where Virtual Machine Startup/Shutdown is Enabled (1003312)
Type service vmware-vpxa restart.
Exit the SSH [...]]]></description>
			<content:encoded><![CDATA[<h3>Restarting the Management agents on ESX Server 3.x</h3>
<ol>
<li>Login to the ESX host using SSH (or from COS)</li>
<li>Type <span style="font-size: x-small; font-family: Courier New;">service mgmt-vmware restart</span>.<br />
<strong><span style="color: #ff0000;">CAUTION</span></strong><br />
Before restarting the Management Agent make sure that Automatic Startup/Shutdown is Disabled<br />
For more info see<br />
<a href="http://kb.vmware.com/kb/1003312" target="_blank">Restarting hostd (mgmt-vmware) on ESX Server Hosts Restarts Hosted Virtual Machines Where Virtual Machine Startup/Shutdown is Enabled (1003312)</a></li>
<li>Type <span style="font-size: x-small; font-family: Courier New;">service vmware-vpxa restart</span>.</li>
<li>Exit the SSH session or logout of COS</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=349</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IBM/Lenovo Bios update/Embedded Controller with dead/no battery</title>
		<link>http://www.amikkelsen.com/?p=343</link>
		<comments>http://www.amikkelsen.com/?p=343#comments</comments>
		<pubDate>Tue, 24 Nov 2009 14:10:43 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[battery]]></category>
		<category><![CDATA[bios]]></category>
		<category><![CDATA[charged]]></category>
		<category><![CDATA[dead]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[ibm]]></category>
		<category><![CDATA[lenovo]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=343</guid>
		<description><![CDATA[Below solution is on you own risk.

Download the Bios/Embedded Controller from IBM/Lenovo (Diskette version)
Rename the file UPDTFLSH.EXE to UPDTFLSH.EXE.OLD
Create a copy of QKFLASH:EXE and rename it to UPDTFLSH.EXE
Boot the labtop from the diskette
Follow normal procedure for updating BIOS/Embedded Controller
DON&#8217;T TURN OFF THE PC OR REMOVE POWER
When the BIOS/Embedded Controller is updated the PC will trun [...]]]></description>
			<content:encoded><![CDATA[<p>Below solution is on you own risk.</p>
<ol>
<li>Download the Bios/Embedded Controller from IBM/Lenovo (Diskette version)</li>
<li>Rename the file UPDTFLSH.EXE to UPDTFLSH.EXE.OLD</li>
<li>Create a copy of QKFLASH:EXE and rename it to UPDTFLSH.EXE</li>
<li>Boot the labtop from the diskette</li>
<li>Follow normal procedure for updating BIOS/Embedded Controller</li>
<li>DON&#8217;T TURN OFF THE PC OR REMOVE POWER</li>
<li>When the BIOS/Embedded Controller is updated the PC will trun off</li>
<li>Poweron  and enter BIOS (F1) to verify that the new BIOS/Embedded Controller is installed.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=343</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading Windows 2008 from virtual HW 4 to 7 may cause problems</title>
		<link>http://www.amikkelsen.com/?p=341</link>
		<comments>http://www.amikkelsen.com/?p=341#comments</comments>
		<pubDate>Mon, 23 Nov 2009 22:21:22 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[ESX Migrate/Upgrade]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[vSphere (ESX)]]></category>
		<category><![CDATA[103109]]></category>
		<category><![CDATA[2008]]></category>
		<category><![CDATA[4]]></category>
		<category><![CDATA[7]]></category>
		<category><![CDATA[offline]]></category>
		<category><![CDATA[virtual hardware]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=341</guid>
		<description><![CDATA[Just found this very interesting article http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&#38;cmd=displayKC&#38;externalId=1013109 describing a problem with Windows 2008 and ESX 4 virtual hardware version 7.
In short the article states that you might have the disks go offline in a Windows 2008 VM if you

Upgrade virtual hardware from version 4 to 7
Installing a new VM with virtual hardware 7

There is two [...]]]></description>
			<content:encoded><![CDATA[<p>Just found this very interesting article <a href="http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1013109" target="_blank">http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1013109</a> describing a problem with Windows 2008 and ESX 4 virtual hardware version 7.</p>
<p>In short the article states that you might have the disks go offline in a Windows 2008 VM if you</p>
<ul>
<li>Upgrade virtual hardware from version 4 to 7</li>
<li>Installing a new VM with virtual hardware 7</li>
</ul>
<p>There is two ways to get around this (taken from the VMware KB 103109)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<div><span style="font-size: 10pt; font-family: Arial;">This can be resolved by changing the SAN Automount Policy on the system.</span> <span style="font-size: 10pt; font-family: Arial;">See the Microsoft article <a href="http://support.microsoft.com/kb/973834" target="_blank">http://support.microsoft.com/kb/973834</a> to change the SAN Policy to online.</span></div>
<div></div>
<div><span style="font-size: 10pt; font-family: Arial;">The SAN policy is defined within the VDS environment of the system and is represented by the following values:</span></div>
<ul>
<li><span style="font-size: 10pt; font-family: Courier New;">VDS_SP_UNKNOWN = 0&#215;0</span></li>
<li><span style="font-size: 10pt; font-family: Courier New;">VDS_SP_ONLINE = 0&#215;1</span></li>
<li><span style="font-size: 10pt; font-family: Courier New;">VDS_SP_OFFLINE_SHARED = 0&#215;2</span></li>
<li><span style="font-size: 10pt; font-family: Courier New;">VDS_SP_OFFLINE = 0&#215;3</span></li>
</ul>
<div><span style="font-size: 10pt; font-family: Arial;">For more information, see <a href="http://msdn.microsoft.com/en-us/library/bb525577%28VS.85%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/bb525577(VS.85).aspx</a>.</span></div>
<div></div>
<div><span style="font-size: 10pt; font-family: Arial;">On Windows Server 2008 Enterprise and Windows Server 2008 Datacenter, the default SAN policy is VDS_SP_OFFLINE_SHARED. On all other Windows Server 2008 editions, the default SAN policy is VDS_SP_ONLINE.</span></div>
<div></div>
<div><span style="font-size: 10pt; font-family: Arial;">To query current SAN policy from the command line, start DISKPART and issue a SAN command:</span></div>
<blockquote style="margin-right: 0px;" dir="ltr">
<div><span style="font-family: Courier New;"><span style="font-size: 10pt;">C:\&gt;DISKPART.EXE<br />
DISKPART&gt; san<br />
SAN Policy : Offline Shared</p>
<p></span><span style="font-size: 10pt;">DISKPART&gt; exit</span></span></div>
</blockquote>
<div><span style="font-size: 10pt; font-family: Arial;">Alternatively, you can set the disk to Online after the hardware version upgrade.</span></div>
<div></div>
<div><span style="font-size: 10pt; font-family: Arial;">To set the disk to Online:</span></div>
<ol>
<li><span style="font-size: 10pt; font-family: Arial;">Log in to your system as an Administrator.</span></li>
<li><span style="font-size: 10pt; font-family: Arial;">Click <strong>Computer Management</strong> &gt;</span> <span style="font-size: 10pt; font-family: Arial;"><strong>Storage</strong> &gt;</span> <span style="font-size: 10pt; font-family: Arial;"><strong>Disk Management</strong>.</span></li>
<li><span style="font-size: 10pt; font-family: Arial;">Right-click the disk and choose</span> <span style="font-size: 10pt; font-family: Arial;"><strong>Online</strong>.</span></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=341</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free virtualization fools</title>
		<link>http://www.amikkelsen.com/?p=338</link>
		<comments>http://www.amikkelsen.com/?p=338#comments</comments>
		<pubDate>Thu, 19 Nov 2009 21:19:35 +0000</pubDate>
		<dc:creator>A. Mikkelsen</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[esx]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[powergui]]></category>
		<category><![CDATA[powerwf]]></category>
		<category><![CDATA[virtualization]]></category>

		<guid isPermaLink="false">http://www.amikkelsen.com/?p=338</guid>
		<description><![CDATA[David Davis has put together a list of what he thinks is some of the best free virtualization tools avaiable.

VMware vSphere ESXi Free Edition and VMware Go
VMware vMA, vCLI (or command-line interface), PowerCLI, and scripts from the vGhetto script repository such as vSphereHealthCheck
Veeam Monitor (free edition), FastSCP, and Business View
Vizioncore Wastefinder, vConvert SC and Virtualization [...]]]></description>
			<content:encoded><![CDATA[<p>David Davis has put together a list of what he thinks is some of the best free virtualization tools avaiable.</p>
<ul>
<li><a href="https://www.vmware.com/tryvmware/index.php?p=free-esxi&amp;lp=1" target="_blank">VMware vSphere ESXi Free Edition and VMware Go</a></li>
<li>VMware <a href="http://www.vmware.com/support/developer/vima/" target="_blank">vMA</a>, <a href="http://www.vmware.com/support/developer/vcli/" target="_blank">vCLI</a> (or command-line interface), <a href="http://www.vmware.com/go/powercli" target="_blank">PowerCLI</a>, and scripts from the <a href="http://communities.vmware.com/docs/DOC-9852" target="_blank">vGhetto script repository</a> such as <a href="http://communities.vmware.com/docs/DOC-9842" target="_blank">vSphereHealthCheck</a></li>
<li>Veeam <a href="http://www.veeam.com/esxi-monitoring-free.html" target="_blank">Monitor (free edition)</a>, <a href="http://www.veeam.com/vmware-esxi-fastscp.html" target="_blank">FastSCP</a>, and <a href="http://www.veeam.com/vmware-business-view.html" target="_blank">Business View</a></li>
<li>Vizioncore <a href="http://www.vizioncore.com/free/vOptimizer/index.php" target="_blank">Wastefinder</a>, <a href="http://www.vizioncore.com/free/vConverter/index.php" target="_blank">vConvert SC</a> and <a href="http://www.vizioncore.com/free/vEcoShell/index.php" target="_blank">Virtualization EcoShell</a></li>
<li><a href="http://www.solarwinds.com/products/freetools/vm_monitor.aspx" target="_blank">SolarWinds&#8217; VM Monitor</a></li>
<li><a href="http://www.trilead.com/VM_Explorer/" target="_blank">Trilead VM Explorer</a></li>
<li><a href="http://www.tripwire.com/configcheck/" target="_blank">TripWire ConfigCheck</a></li>
<li><a href="http://www.configuresoft.com/compliance-checker.aspx" target="_blank">ConfigureSoft/EMC Compliance Checker</a></li>
<li><a href="http://www.esxguide.com/esx/" target="_blank">ESX Manager 2.3 from ESXGuide</a> (ESX 3i and 4i are not supported)</li>
<li>vKernel <a href="http://www.vkernel.com/products/SearchMyVM/" target="_blank">SearchMyVM</a>, <a href="http://www.vkernel.com/products/SnapshotMyVM/" target="_blank">SnapshotMyVM</a>, and <a href="http://www.vkernel.com/products/VKernelModeler/" target="_blank">Modeler</a></li>
<li><a href="http://hyper9.com/downloads.aspx" target="_blank">Hyper9 GuessMyOS Plugin, Search Bar Plugin, and Virtualization Mobile Manager</a></li>
<li>XtraVirt <a href="http://xtravirt.com/xd10130" target="_blank">vAlarm</a> and <a href="http://xtravirt.com/xd10132" target="_blank">vLogView</a></li>
</ul>
<p>I still think that he is missing a few, like</p>
<ul>
<li><a href="http://tinyurl.com/ygayony" target="_blank">Project Onyx</a> (Just released in Alpha)</li>
<li><a href="http://sourceforge.net/projects/esxhealthscript/" target="_blank">ESX HealthScript</a> (ESXi not supported)</li>
<li><a href="http://www.ultimatedeployment.org/" target="_self">Ultimate Deployment Appliance (UDA)</a></li>
<li><a href="http://www.virtu-al.net/2009/07/14/powercli-daily-report/" target="_blank">Daily ESX Report</a> (Script)</li>
<li><a href="http://www.syslogappliance.de/en/" target="_blank">Syslog Appliance</a></li>
<li><a href="http://www.powergui.org/entry.jspa?externalID=1802&amp;categoryID=290" target="_blank">PowerGUI VMware Power Pack</a></li>
<li><a href="http://www.powerwf.com/" target="_blank">PowerWF Studio</a></li>
</ul>
<p>See the full article at<br />
<a title="Free tools" href="http://searchservervirtualization.techtarget.com/tip/0,289483,sid94_gci1374471_mem1,00.html?track=NL-1429&amp;ad=735799&amp;asrc=EM_NLN_10017326" target="_blank">http://searchservervirtualization.techtarget.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.amikkelsen.com/?feed=rss2&amp;p=338</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
