<?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>Kasraeian</title>
	<atom:link href="http://www.kasraeian.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kasraeian.com</link>
	<description>vWorld</description>
	<lastBuildDate>Fri, 18 May 2012 10:10:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Using VMware PowerCLI (#006) – Deploy Template (v0.4)</title>
		<link>http://www.kasraeian.com/2012/05/using-vmware-powercli-006-deploy-template-v0-4/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-vmware-powercli-006-deploy-template-v0-4</link>
		<comments>http://www.kasraeian.com/2012/05/using-vmware-powercli-006-deploy-template-v0-4/#comments</comments>
		<pubDate>Fri, 18 May 2012 10:10:11 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[VCAP-DCA]]></category>
		<category><![CDATA[Add-PSSnapin]]></category>
		<category><![CDATA[Deploy]]></category>
		<category><![CDATA[Get-VICredentialStoreItem]]></category>
		<category><![CDATA[Move-VM -Destination]]></category>
		<category><![CDATA[New-VM -VMHost -Template]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Set-PowerCLIConfiguration]]></category>
		<category><![CDATA[Start-VM]]></category>
		<category><![CDATA[Template]]></category>
		<category><![CDATA[Using VMware PowerCLI]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware vSphere PowerCLI]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=2104</guid>
		<description><![CDATA[I&#8217;ve edited &#8220;DTS (v0.3)&#8221; so it can generate &#8220;.csv&#8221; and accept input from &#8220;.csv&#8221; file as well. Feel free to send your comment and idea and if you find any bug/problem in this script please let me know, I hope this version can do better work and be useful. ##################################################### function Header { CLS Write-Host [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve edited &#8220;DTS (v0.3)&#8221; so it can generate &#8220;.csv&#8221; and accept input from &#8220;.csv&#8221; file as well.<br />
Feel free to send your comment and idea and if you find any bug/problem in this script please let me know, I hope this version can do better work and be useful.</p>
<div id='wpdm_file_8' class='wpdm_file wpdm-only-button'><div class='cont'><div class='btn_outer'><div class='btn_outer_c'><a class='btn_left  has-counter' rel='8' title='Deploy Template (V0.4)' href='http://www.kasraeian.com/?wpdmact=process&did=OC5ob3RsaW5r'  >Download</a><span class='btn_right counter'>4 downloads</span></div></div><div class='clear'></div></div></div>
<pre class="brush: powershell; gutter: true; first-line: 1">#####################################################
function Header {
	CLS
	Write-Host "Name:`tDeploy Template Script (v0.4)"
}
#####################################################

# Adding PSSnapin
$pssnap = Get-PSSnapin | Sort-Object Name
$APS = "No"
$PSIndex = 1
1..$pssnap.Count | foreach {
	if ($pssnap[$PSIndex].Name -like "vmware.vimautomation.core") {
		$APS = "Yes"
	}
	$PSIndex++
}
if ($APS -eq "No") {
	Write-Host "Adding required PowerShell Snapin"
	Add-PSSnapin VMware.VimAutomation.Core
}

# Enabling multiple connection
$PCC = get-PowerCLIConfiguration
if ($test.DefaultVIServerMode -eq "single") {
	Write-Host "Changing `"Default VI Server Mode`""
	Set-PowerCLIConfiguration -DefaultVIServerMode Multiple
}

# vCenter Server Connection
Header
Write-Host ""
$Target = Read-Host ("Which vCenter Do you want connect to")
if ($global:DefaultVIServer.Name -eq $Target) {
	$CRMB = "Yes"
} else {
	$VICSI = Get-VICredentialStoreItem | Sort-Object Host
	$AI = "No"
	foreach ($item in $VICSI) {
		if ($Target -eq $item.Host) {
			$AI = "Yes"
		}
	}
	if ($AI -eq "No") {
		$cred = Get-Credential
		Write-Host "Connecting to $Target"
		$NCR = Connect-VIServer -Server $Target -Credential $cred
	} else {
		Write-Host "Connecting to $Target"
		$NCR = Connect-VIServer -Server $Target
	}
	if ($NCR.IsConnected -eq $true) {
		$CRMB = "Yes"
	} else {
		$CRMB = "No"
	}
}

# Automated Mode functions and process
function AutomatedMode {
	Header
	Write-Host "`nFor automated mode you need to present `".csv`" file in bellow format`nName,Template,VMHost,Datastore,ResourcePool,vApp,CustomizationProfile,StartState"
	$AFEA = Read-Host ("`nDo you have csv file matching above format (Y/N) [default = N]")
	Switch ($AFEA) {
		"y" {
			$CFP = Read-Host ("Please give the full path of `".csv`" file")
			if ($CFP -notlike "") {
				Import-Csv -Path $CFP | foreach {
					if ($($_.Name) -and $($_.Template) -and $($_.VMHost) -and $($_.Datastore) -notlike "") {
						if ($_.StartState -eq "Yes") {
							if ($_.CustomizationProfile -notlike "" -and $_.CustomizationProfile -notlike "none") {
								if ($($_.ResourcePool) -notlike "" -and $($_.ResourcePool) -notlike "none") {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) -ResourcePool $($_.ResourcePool) | Start-VM
								} elseif ($($_.vApp) -notlike "" -and $($_.vApp) -notlike "none") {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) | Move-VM -Destination $($_.vApp) | Start-VM
								} else {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) | Start-VM
								}
							} else {
								if ($($_.ResourcePool) -notlike "" -and $($_.ResourcePool) -notlike "none") {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -ResourcePool $($_.ResourcePool) | Start-VM
								} elseif ($($_.vApp) -notlike "" -and $($_.vApp) -notlike "none") {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) | Move-VM -Destination $($_.vApp) | Start-VM
								} else {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) | Start-VM
								}
							}
						} else {
							if ($_.CustomizationProfile -notlike "" -and $_.CustomizationProfile -notlike "none") {
								if ($($_.ResourcePool) -notlike "" -and $($_.ResourcePool) -notlike "none") {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) -ResourcePool $($_.ResourcePool)
								} elseif ($($_.vApp) -notlike "" -and $($_.vApp) -notlike "none") {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile) | Move-VM -Destination $($_.vApp)
								} else {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -OSCustomizationSpec $($_.CustomizationProfile)
								}
							} else {
								if ($($_.ResourcePool) -notlike "" -and $($_.ResourcePool) -notlike "none") {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) -ResourcePool $($_.ResourcePool)
								} elseif ($($_.vApp) -notlike "" -and $($_.vApp) -notlike "none") {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore) | Move-VM -Destination $($_.vApp)
								} else {
									New-VM -Name $($_.Name) -Template $($_.Template) -VMHost $($_.VMHost) -Datastore $($_.Datastore)
								}
							}
						}
					}
				}
				$TOS = Read-Host ("Would you like to create other series (Y/N)")
				if ($TOS -like "y") {
					MainBody{}
				} else {
					Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
					Exit
				}
			} else {
				Write-Host ("`nProvided information is not correct") -BackgroundColor Yellow -ForegroundColor DarkRed
				$Answer = Read-Host ("`nDo you want to try again (Y/N) [default = Y]")
				Switch ($Answer) {
					"n" {
						Header
						Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
						Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
						Exit
					}
					default {
						AutomatedMode{}
					}
				}
			}
		}
		default {
			Header
			$CNCFA = Read-Host ("`n[M] Manually create new `".csv`" file`n[Other keys] Exit`nPlease select from above items [default = Exit]")
			Switch ($CNCFA) {
				"m" {
					Header
					Write-Host "`nPlease provide below information, items with * are required in order to create new series of VMs"
					$Name = Read-Host ("Please enter naming patern*")
					$Template = Read-Host ("Please enter source template name*")
					$VMHost = Read-Host ("Please define target host*")
					$Datastore = Read-Host ("Please define target datastore*")
					$ResourcePool = Read-Host ("Please enter resource pool to place new VM(s)")
					$vApp = Read-Host ("Please enter vApp to place new VM(s)")
					$OSCP = Read-Host ("Please select OS customization specification")
					$StartState = Read-Host ("Please type `"Yes`" if you want to power on your VMs after their creation or `"No`" for manual process")
					$Qty = Read-Host ("How many VM(s) do you want to deploy")
					$SCF = Read-Host ("Please provide full address to save csv file")
					if ($Qty -ge 1) {
					    if ($Name -and $Template -and $VMHost -and $Datastore -and $SCF -notlike "") {
					        $i = 1
					        $FileContent = "Name,Template,VMHost,Datastore,ResourcePool,vApp,CustomizationProfile,StartState"
					        1..$Qty | foreach {
					            $NewContent = "`n$Name$i,$Template,$VMHost,$Datastore,$ResourcePool,$vApp,$OSCP,$StartState"
					            $FileContent = $FileContent + $NewContent
					            $i++
					        }
							Header
							Write-Host "`nNew `".csv`" file would be create containing bellow information on $SCF`n"
					        $FileContent
							$WCFA = Read-Host ("`nDo you want to save these information (Y/N)")
							Switch ($WCFA) {
								"y" {
									$FileContent | Out-File $SCF
								}
								"n" {
									$RWPA = Read-Host ("`n[N] Create new `".csv`" file`n[M] Main menu`n[Other keys] Exit`nPlease select from above items [default = Exit]")
									Switch ($RWPA) {
										"n" {
											AutomatedMode{}
										}
										"m" {
											MainBody{}
										}
										default {
											Header
											Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
											Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
											Exit
										}
									}
								}
							}
							$Answer = Read-Host ("`n[E] Edit `".csv`" file and back to main menu`n[M] Main menu`n[Other keys] Exit`nPlease select from above items [default = Exit]")
							Switch ($Answer) {
								"e" {
									Invoke-Item $SCF
									MainBody{}
								}
								"m" {
									MainBody{}
								}
								default {
									Header
									Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
									Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
									Exit
								}
							}
					    } else {
					        Write-Host ("`nAll required data is not provided`n") -BackgroundColor Yellow -ForegroundColor DarkRed
							$Answer = Read-Host ("`nDo you want to try again (Y/N) [default = Y]")
							Switch ($Answer) {
								"n" {
									Header
									Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
									Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
									Exit
								}
								default {
									AutomatedMode{}
								}
							}
					    }
					} else {
					    Write-Host ("You have provided wrong information, number of VM(s) to be deploy should more than 0") -BackgroundColor Yellow -ForegroundColor DarkRed
					    $Answer = Read-Host ("`nDo you want to try again (Y/N) [default = Y]")
						Switch ($Answer) {
							"n" {
								Header
								Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
								Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
								Exit
							}
							default {
								AutomatedMode{}
							}
						}
					}
				}
				default {
					Header
					Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
					Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
					Exit
				}
			}
		}
	}
}

# Interactive Mode functions and process
function InteractiveMode {
	# Template Selection
	Header
	Write-Host ""
	$Templates = Get-Template | Select Name | Sort-Object Name
	if ($Templates.count -ge 2) {
		$i = 1
		$Templates | %{Write-Host $i":" $_.Name; $i++}
		$SIndex = Read-Host "Enter a number ( 1 -" $Templates.Count ")"
		$STemplate = $Templates[$SIndex - 1].Name
	} elseif ($Templates.Name -notlike "") {
		$i = 1
		$Templates | %{Write-Host $i":" $_.Name; $i++}
		$TSMC = Read-Host ("You only have one template, do you want to use it (Y/N) [default = Y]")
		Switch ($TSMC) {
			"n" {
				Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
				Exit
			}
			default {
				$STemplate = $Templates.Name
			}
		}
	} else {
		Write-Host "No template found, please check vCenter server and try again.`n" -BackgroundColor Yellow -ForegroundColor DarkRed
		Exit
	}

	# Customization Profile Selection
	Header
	Write-Host ""
	$OSCPs = Get-OSCustomizationSpec | Select Name | Sort-Object
	if ($OSCPs.count -ge 2) {
		$j = 1
		$OSCPs | %{Write-Host $j":" $_.Name; $j++}
		Write-Host $j": None"
		$OSCPRC = $OSCPs.count + 1
		$OSIndex = Read-Host "Enter a number ( 1 -" $OSCPRC ")"
		$SOSCP = $OSCPs[$OSIndex - 1].Name
		if ($OSIndex -eq $j) { $SOSCP = "None" }
	} elseif ($OSCPs.Name -notlike "") {
		$j = 1
		$OSCPs | %{Write-Host $j":" $_.Name; $j++}
		Write-Host $j": None"
		$OSIndex = Read-Host "Enter a number ( 1 - 2 )"
		Switch ($OSIndex) {
			1 { $SOSCP = $OSCPs.Name }
			2 { $SOSCP = "None" }
		}
	} else {
		Write-Host ("Currently, you don't have any customization profile available.")
		$CPSMC = Read-Host ("[C] continue the process`n[A] Abort and came back latter`nPlease select from above list [default = C]")
		Switch ($CPSMC) {
			"a" {
				Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
				Exit
			}
			default {
				$SOSCP = "None"
			}
		}
	}

	# Host Selection
	Header
	Write-Host ""
	$VMHosts = Get-VMHost | Select Name | Sort-Object
	if ($VMHosts.count -ge 2) {
		$x = 1
		$VMHosts | %{Write-Host $x":" $_.Name; $x++}
		$VMHIndex = Read-Host "Enter a number ( 1 -" $VMHosts.Count ")"
		$SVMHost = $VMHosts[$VMHIndex - 1].Name
	} elseif ($VMHosts.Name -notlike "") {
		$x = 1
		$VMHosts | %{Write-Host $x":" $_.Name; $x++}
		$HSMC = Read-Host ("You only have one host, do you want to use it (Y/N)")
		if ($HSMC -like "y") {
			$SVMHost = $VMHosts.Name
		} elseif ($HSMC -like "n") {
			Write-Host ("`nAll process aborted by user!") -BackgroundColor Yellow -ForegroundColor DarkRed
			Read-Host ("`nPress any key to exit") -BackgroundColor Yellow -ForegroundColor DarkRed
			Exit
		}
	} else {
		Write-Host "No host found, please check vCenter server and try again."
		Read-Host ("`nPress any key to exit") -BackgroundColor Yellow -ForegroundColor DarkRed
		Exit
	}

	# Datastore Selection
	Header
	Write-Host ""
	$Datastores = Get-VMHost $SVMHost | Get-Datastore | Select Name,FreeSpaceGB,CapacityGB | Sort-Object CapacityGB
	if ($Datastores.count -ge 2) {
		$y = 1
		$Datastores | %{Write-Host $y":" $_.Name"`t`tCapacity (GB):" $_.CapacityGB"`t`tFree Space (GB):" $_.FreeSpaceGB; $y++}
		$DSIndex = Read-Host "Enter a number ( 1 -" $Datastores.count ")"
		$SDatastore = $Datastores[$DSIndex - 1].Name
	} elseif ($Datastores.Name -notlike "") {
		$y = 1
		$Datastores | %{Write-Host $y":" $_.Name"`t`tCapacity (GB):" $_.CapacityGB"`t`tFree Space (GB):" $_.FreeSpaceGB; $y++}
		$DSSMC = Read-Host ("You only have one host, do you want to use it (Y/N) [default = Y]")
		Switch ($DSSMC) {
			"n" {
				Write-Host ("`nAll process aborted by user!") -BackgroundColor Yellow -ForegroundColor DarkRed
				Exit
			}
			default {
				$SDatastore = $Datastores.Name
			}
		}
	} else {
		Write-Host "No datastore found, please check vCenter server and try again." -BackgroundColor Yellow -ForegroundColor DarkRed
		Exit
	}

	# Location Selection
	Header
	Write-Host ""
	$LSA = Read-Host "[R] Resource Pool`n[V] vApp`n[Other Keys] No Config (simple)`nPlease select location for placing new VM(s)"
	$SLocation = "Root"
	Switch ($LSA) {
		"r" {
			Write-Host ""
			$ARPs = Get-ResourcePool | Sort-Object Name
			if ($ARPs.count -ge 2) {
				$z = 1
				$ARPs | %{Write-Host $z":" $_.Name; $z++}
				$RPIndex = Read-Host "Enter a number ( 1 -" $ARPs.count ")"
				$SRP = $ARPs[$RPIndex - 1].Name
				$SLocation = $ARPs[$RPIndex - 1]
			} elseif ($ARPs.Name -notlike "") {
				$RPSMC = Read-Host ("You only have one resource pool ($ARPs.Name), do you want to use it (Y/N) [default = Y]")
				Switch ($RPSMC) {
					"n" {
						$SLocation = "Root"
					}
					default {
						$SLocation = $ARPs.Name
					}
				}
			} else {
				Write-Host ("Currently, you don't have any resource pool available.")
				$RPSMC = Read-Host ("[C] continue the process`n[A] Abort and came back latter`nPlease select from above list [default = C]")
				Switch ($RPSMC) {
					"a" {
						Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
						Exit
					}
					default {
						$SLocation = "Root"
					}
				}
			}
		}
		"v" {
			Write-Host ""
			$AVAs = Get-VApp | Sort-Object Name
			if ($AVAs.count -ge 2) {
				$k = 1
				$AVAs | %{Write-Host $k":" $_.Name;$k++}
				$VAIndex = Read-Host "Enter a number ( 1 -" $AVAs.count ")"
				$SVA = $AVAs[$VAIndex - 1].Name
				$SLocation = $AVAs[$VAIndex - 1]
				$SvApp = $AVAs[$VAIndex - 1]
			} elseif ($AVAs.Name -notlike "") {
				$VASMC = Read-Host ("You only have one resource pool ($AVAs.Name), do you want to use it (Y/N) [default = Y]")
				Switch ($VASMC) {
					"n" {
						$SLocation = "Root"
						$SvApp = "none"
					}
					default {
						$SLocation = $AVAs.Name
						$SvApp = $AVAs.Name
					}
				}
			} else {
				Write-Host ("Currently, you don't have any vApp available.")
				$VASMC = Read-Host ("[C] continue the process`n[A] Abort and came back latter`nPlease select from above list [default = C]")
				Switch ($VASMC) {
					"a" {
						Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
						Exit
					}
					default {
						$SLocation = "Root"
						$SvApp = "none"
					}
				}
			}
		}
		default {
			$SLocation = "Root"
		}
	}

	# Name Selection
	Header
	Write-Host ""
	$SName = Read-Host "Please enter VMs Naming Patern"

	# Getting VM count
	$NVMTD = Read-Host "How many VMs do you want to deploy"

	# Getting confirmation and deploying
	Header
	Write-Host "`nNew VM(s) would be created by bellow configuration
Source Template: $STemplate
Target Host: $SVMHost
Target Datastore: $SDatastore
OS Customization Profile: $SOSCP
VM naming pattern: $SName
Number of VM(s): $NVMTD
Would place on: $SLocation"

	# Action Menu
	$NVMDConf = Read-Host "`n[C] Create VM(s)`n[S] Create and start VM(s)`n[R] Restart whole process`n[M] Main menu`n[Other Keys] Exit`nPlease select action from list [default = Exit]"
	switch ($NVMDConf) {
		"c" {
			Switch ($SOSCP) {
				"None" { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore } }
				default { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore -OSCustomizationSpec $SOSCP } }
			}
			Switch ($SLocation) {
				"Root" { break }
				default { $NoOut = Get-VM | Where {$_.Name -like "$SName*"} | Move-VM -Destination $SLocation }
			}
			Write-Host "`n----- Created VMs -----" -NoNewline
			Get-VM | Where {$_.Name -like "$SName*"} | Select Name,PowerState,NumCPU,MemoryMB | Format-Table -AutoSize
			Write-Host "You need to manually start your VMs.`n" -BackgroundColor Yellow -ForegroundColor Blue
			$TOS = Read-Host ("Would you like to create other series (Y/N)")
			if ($TOS -like "y") {
				MainBody{}
			} else {
				Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
				Exit
			}
		}
		"s" {
			Switch ($SOSCP) {
				"None" { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore | Start-VM } }
				default { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore -OSCustomizationSpec $SOSCP | Start-VM } }
			}
			Switch ($SLocation) {
				"Root" { break }
				default { $NoOut = Get-VM | Where {$_.Name -like "$SName*"} | Move-VM -Destination $SLocation }
			}
			Write-Host "`n----- Created VMs -----"
			Get-VM | Where {$_.Name -like "$SName*"} | Select Name,PowerState,NumCPU,MemoryMB | Format-Table -AutoSize
			$TOS = Read-Host ("Would you like to create other series (Y/N)")
			if ($TOS -like "y") {
				MainBody{}
			} else {
				Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
				Exit
			}
		}
		"r" {
			InteractiveMode{}
		}
		"m" {
			MainBody{}
		}
		default {
			Header
			Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
			Write-Host "Thanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
			Exit
		}
	}
}

function MainBody {
	if ($CRMB -eq "Yes") {
		Header
		$ModeSelection = Read-Host ("`n[A] Automated Mode (csv)`n[I] Interactive Mode`n[Other keys] Exit`nPlease select from above list [default = E]")
		Switch ($ModeSelection) {
			"i" {
				Header
				InteractiveMode{}
			}
			"a" {
				Header
				AutomatedMode{}
			}
			default {
				Header
				Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
				Write-Host "`nThanks for using `"Deploy Template Script (v0.4)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
				Exit
			}
		}
	} else {
		Write-Host ("Error on connecting to vCenter Server") -BackgroundColor Yellow -ForegroundColor DarkRed
	}
}

MainBody

### EOF ###</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/05/using-vmware-powercli-006-deploy-template-v0-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using VMware PowerCLI (#005) &#8211; Deploy Template (v0.3)</title>
		<link>http://www.kasraeian.com/2012/05/using-vmware-powercli-005-deploy-template-v0-3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-vmware-powercli-005-deploy-template-v0-3</link>
		<comments>http://www.kasraeian.com/2012/05/using-vmware-powercli-005-deploy-template-v0-3/#comments</comments>
		<pubDate>Thu, 10 May 2012 11:27:58 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[VCAP-DCA]]></category>
		<category><![CDATA[Add-PSSnapin]]></category>
		<category><![CDATA[Deploy]]></category>
		<category><![CDATA[Get-VICredentialStoreItem]]></category>
		<category><![CDATA[Move-VM -Destination]]></category>
		<category><![CDATA[New-VM -VMHost -Template]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Set-PowerCLIConfiguration]]></category>
		<category><![CDATA[Start-VM]]></category>
		<category><![CDATA[Template]]></category>
		<category><![CDATA[Using VMware PowerCLI]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware vSphere PowerCLI]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=2082</guid>
		<description><![CDATA[Thanks &#8220;nWill&#8221; for his kind comment on my previous post, I found a problem on &#8220;v0.2&#8243; and in &#8220;v0.3&#8243; I tried to fixed some problems previous script had such as not being able to&#160;work properly in environment with only one &#8220;Template, Customization Specification, Host, Resource Pool or vApp&#8221;. I&#8217;ve added some description as well as [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks &#8220;nWill&#8221; for his kind <a href="http://www.kasraeian.com/2012/05/using-vmware-powercli-004-deploy-template-v0-2/#comment-1033" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/2012/05/using-vmware-powercli-004-deploy-template-v0-2/#comment-1033.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">comment</a> on my <a title="Using VMware PowerCLI (#004) – Deploy Template (v0.2)" href="http://www.kasraeian.com/2012/05/using-vmware-powercli-004-deploy-template-v0-2/" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/2012/05/using-vmware-powercli-004-deploy-template-v0-2/.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">previous post</a>, I found a problem on &#8220;v0.2&#8243; and in &#8220;v0.3&#8243; I tried to fixed some problems previous script had such as not being able to&nbsp;work properly in environment with only one &#8220;Template, Customization Specification, Host, Resource Pool or vApp&#8221;.<br />
I&#8217;ve added some description as well as defining some other condition but might still got some problem, so please let me know if you find any.&nbsp; <img src='http://www.kasraeian.com/wp-includes/images/blank.gif' alt=':wink:' class='wp-smiley smiley-20' /> </p>
<div id='wpdm_file_7' class='wpdm_file wpdm-only-button'><div class='cont'><div class='btn_outer'><div class='btn_outer_c'><a class='btn_left  has-counter' rel='7' title='Deploy Template (V0.3)' href='http://www.kasraeian.com/?wpdmact=process&did=Ny5ob3RsaW5r'  >Download</a><span class='btn_right counter'>13 downloads</span></div></div><div class='clear'></div></div></div>
<pre class="brush: powershell; gutter: true; first-line: 1">#####################################################
function Header {
	CLS
	Write-Host "Name:`tDeploy Template Script (v0.3)"
}
#####################################################

# Adding PSSnapin
$pssnap = Get-PSSnapin | Sort-Object Name
$APS = "No"
$PSIndex = 1
1..$pssnap.Count | foreach {
	if ($pssnap[$PSIndex].Name -like "vmware.vimautomation.core") {
		$APS = "Yes"
	}
	$PSIndex++
}
if ($APS -eq "No") { Add-PSSnapin VMware.VimAutomation.Core }

# Enabling multiple connection
$PCC = get-PowerCLIConfiguration
if ($test.DefaultVIServerMode -eq "single") {
	Set-PowerCLIConfiguration -DefaultVIServerMode Multiple
}

# vCenter Server Connection
Header
Write-Host ""
$Target = Read-Host ("Which vCenter Do you want connect to")
if ($global:DefaultVIServer.Name -eq $Target) {
	$CRMB = "Yes"
} else {
	$VICSI = Get-VICredentialStoreItem | Sort-Object Host
	$AI = "No"
	foreach ($item in $VICSI) {
		if ($Target -eq $item.Host) {
			$AI = "Yes"
		}
	}
	if ($AI -eq "No") {
		$cred = Get-Credential
		$NCR = Connect-VIServer -Server $Target -Credential $cred
	} else {
		$NCR = Connect-VIServer -Server $Target
	}
	if ($NCR.IsConnected -eq $true) {
		$CRMB = "Yes"
	} else {
		$CRMB = "No"
	}
}

function MainBody {
	# Template Selection
	Header
	Write-Host ""
	$Templates = Get-Template | Select Name | Sort-Object Name
	if ($Templates.count -ge 2) {
		$i = 1
		$Templates | %{Write-Host $i":" $_.Name; $i++}
		$SIndex = Read-Host "Enter a number ( 1 -" $Templates.Count ")"
		$STemplate = $Templates[$SIndex - 1].Name
	} elseif ($Templates.Name -notlike "") {
		$i = 1
		$Templates | %{Write-Host $i":" $_.Name; $i++}
		$TSMC = Read-Host ("You only have one template, do you want to use it (Y/N) [default = Y]")
		Switch ($TSMC) {
			"n" {
				Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
				exit
			}
			default {
				$STemplate = $Templates.Name
			}
		}
	} else {
		Write-Host "No template found, please check vCenter server and try again.`n" -BackgroundColor Yellow -ForegroundColor DarkRed
		exit
	}

	# Customization Profile Selection
	Header
	Write-Host ""
	$OSCPs = Get-OSCustomizationSpec | Select Name | Sort-Object
	if ($OSCPs.count -ge 2) {
		$j = 1
		$OSCPs | %{Write-Host $j":" $_.Name; $j++}
		Write-Host $j": None"
		$OSCPRC = $OSCPs.count + 1
		$OSIndex = Read-Host "Enter a number ( 1 -" $OSCPRC ")"
		$SOSCP = $OSCPs[$OSIndex - 1].Name
		if ($OSIndex -eq $j) { $SOSCP = "None" }
	} elseif ($OSCPs.Name -notlike "") {
		$j = 1
		$OSCPs | %{Write-Host $j":" $_.Name; $j++}
		Write-Host $j": None"
		$OSIndex = Read-Host "Enter a number ( 1 - 2 )"
		Switch ($OSIndex) {
			1 { $SOSCP = $OSCPs.Name }
			2 { $SOSCP = "None" }
		}
	} else {
		Write-Host ("Currently, you don't have any customization profile available.")
		$CPSMC = Read-Host ("[C] continue the process`n[A] Abort and came back latter`nPlease select from above list [default = C]")
		Switch ($CPSMC) {
			"a" {
				Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
				exit
			}
			default {
				$SOSCP = "None"
			}
		}
	}

	# Host Selection
	Header
	Write-Host ""
	$VMHosts = Get-VMHost | Select Name | Sort-Object
	if ($VMHosts.count -ge 2) {
		$x = 1
		$VMHosts | %{Write-Host $x":" $_.Name; $x++}
		$VMHIndex = Read-Host "Enter a number ( 1 -" $VMHosts.Count ")"
		$SVMHost = $VMHosts[$VMHIndex - 1].Name
	} elseif ($VMHosts.Name -notlike "") {
		$x = 1
		$VMHosts | %{Write-Host $x":" $_.Name; $x++}
		$HSMC = Read-Host ("You only have one host, do you want to use it (Y/N)")
		if ($HSMC -like "y") {
			$SVMHost = $VMHosts.Name
		} elseif ($HSMC -like "n") {
			Write-Host ("`nAll process aborted by user!") -BackgroundColor Yellow -ForegroundColor DarkRed
			Read-Host ("`nPress any key to exit") -BackgroundColor Yellow -ForegroundColor DarkRed
			exit
		}
	} else {
		Write-Host "No host found, please check vCenter server and try again."
		Read-Host ("`nPress any key to exit") -BackgroundColor Yellow -ForegroundColor DarkRed
		exit
	}

	# Datastore Selection
	Header
	Write-Host ""
	$Datastores = Get-VMHost $SVMHost | Get-Datastore | Select Name,FreeSpaceGB,CapacityGB | Sort-Object CapacityGB
	if ($Datastores.count -ge 2) {
		$y = 1
		$Datastores | %{Write-Host $y":" $_.Name"`t`tCapacity (GB):" $_.CapacityGB"`t`tFree Space (GB):" $_.FreeSpaceGB; $y++}
		$DSIndex = Read-Host "Enter a number ( 1 -" $Datastores.count ")"
		$SDatastore = $Datastores[$DSIndex - 1].Name
	} elseif ($Datastores.Name -notlike "") {
		$y = 1
		$Datastores | %{Write-Host $y":" $_.Name"`t`tCapacity (GB):" $_.CapacityGB"`t`tFree Space (GB):" $_.FreeSpaceGB; $y++}
		$DSSMC = Read-Host ("You only have one host, do you want to use it (Y/N) [default = Y]")
		Switch ($DSSMC) {
			"n" {
				Write-Host ("`nAll process aborted by user!") -BackgroundColor Yellow -ForegroundColor DarkRed
				exit
			}
			default {
				$SDatastore = $Datastores.Name
			}
		}
	} else {
		Write-Host "No datastore found, please check vCenter server and try again." -BackgroundColor Yellow -ForegroundColor DarkRed
		exit
	}

	# Location Selection
	Header
	Write-Host ""
	$LSA = Read-Host "[R] Resource Pool`n[V] vApp`n[Other Keys] No Config (simple)`nPlease select location for placing new VM(s)"
	$SLocation = "Root"
	Switch ($LSA) {
		"r" {
			Write-Host ""
			$ARPs = Get-ResourcePool | Sort-Object Name
			if ($ARPs.count -ge 2) {
				$z = 1
				$ARPs | %{Write-Host $z":" $_.Name; $z++}
				$RPIndex = Read-Host "Enter a number ( 1 -" $ARPs.count ")"
				$SRP = $ARPs[$RPIndex - 1].Name
				$SLocation = $ARPs[$RPIndex - 1]
			} elseif ($ARPs.Name -notlike "") {
				$RPSMC = Read-Host ("You only have one resource pool ($ARPs.Name), do you want to use it (Y/N) [default = Y]")
				Switch ($RPSMC) {
					"n" {
						$SLocation = "Root"
					}
					default {
						$SLocation = $ARPs.Name
					}
				}
			} else {
				Write-Host ("Currently, you don't have any resource pool available.")
				$RPSMC = Read-Host ("[C] continue the process`n[A] Abort and came back latter`nPlease select from above list [default = C]")
				Switch ($RPSMC) {
					"a" {
						Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
						exit
					}
					default {
						$SLocation = "Root"
					}
				}
			}
		}
		"v" {
			Write-Host ""
			$AVAs = Get-VApp | Sort-Object Name
			if ($AVAs.count -ge 2) {
				$k = 1
				$AVAs | %{Write-Host $k":" $_.Name;$k++}
				$VAIndex = Read-Host "Enter a number ( 1 -" $AVAs.count ")"
				$SVA = $AVAs[$VAIndex - 1].Name
				$SLocation = $AVAs[$VAIndex - 1]
			} elseif ($AVAs.Name -notlike "") {
				$VASMC = Read-Host ("You only have one resource pool ($AVAs.Name), do you want to use it (Y/N) [default = Y]")
				Switch ($VASMC) {
					"n" {
						$SLocation = "Root"
					}
					default {
						$SLocation = $AVAs.Name
					}
				}
			} else {
				Write-Host ("Currently, you don't have any vApp available.")
				$VASMC = Read-Host ("[C] continue the process`n[A] Abort and came back latter`nPlease select from above list [default = C]")
				Switch ($VASMC) {
					"a" {
						Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
						exit
					}
					default {
						$SLocation = "Root"
					}
				}
			}
		}
		default {
			$SLocation = "Root"
		}
	}

	# Name Selection
	Header
	Write-Host ""
	$SName = Read-Host "Please enter VMs Naming Patern"

	# Getting VM count
	$NVMTD = Read-Host "How many VMs do you want to deploy"

	# Getting confirmation and deploying
	Header
	Write-Host "`nNew VM(s) would be created by bellow configuration
Source Template: $STemplate
Target Host: $SVMHost
Target Datastore: $SDatastore
OS Customization Profile: $SOSCP
VM naming pattern: $SName
Number of VM(s): $NVMTD
Would place on: $SLocation"

	# Action Menu
	$NVMDConf = Read-Host "`n[C] Create VM(s)`n[R] Create and run VM(s)`n[B] Restart whole process`n[Other Keys] Exit`nPlease select action from list [default = Exit]"
	switch ($NVMDConf) {
		"c" {
			Switch ($SOSCP) {
				"None" { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore } }
				default { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore -OSCustomizationSpec $SOSCP } }
			}
			Switch ($SLocation) {
				"Root" { break }
				default { $NoOut = Get-VM | Where {$_.Name -like "$SName*"} | Move-VM -Destination $SLocation }
			}
			Write-Host "`n----- Created VMs -----" -NoNewline
			Get-VM | Where {$_.Name -like "$SName*"} | Select Name,PowerState,NumCPU,MemoryMB | Format-Table -AutoSize
			Write-Host "You need to manually start your VMs.`n" -BackgroundColor Yellow -ForegroundColor Blue
			$TOS = Read-Host ("Would you like to create other series (Y/N)")
			if ($TOS -like "y") {
				MainBody{}
			}
		}
		"r" {
			Switch ($SOSCP) {
				"None" { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore | Start-VM } }
				default { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore -OSCustomizationSpec $SOSCP | Start-VM } }
			}
			Switch ($SLocation) {
				"Root" { break }
				default { $NoOut = Get-VM | Where {$_.Name -like "$SName*"} | Move-VM -Destination $SLocation }
			}
			Write-Host "`n----- Created VMs -----"
			Get-VM | Where {$_.Name -like "$SName*"} | Select Name,PowerState,NumCPU,MemoryMB | Format-Table -AutoSize
			$TOS = Read-Host ("Would you like to create other series (Y/N)")
			if ($TOS -like "y") {
				MainBody{}
			}
		}
		"b" {
			MainBody{}
		}
		default {
			Write-Host ("`nAll process aborted by user!`n") -BackgroundColor Yellow -ForegroundColor DarkRed
			break
		}
	}
}

if ($CRMB -eq "Yes") {
	MainBody{}
	Write-Host "`nThanks for using `"Deploy Template Script (v0.3)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
} else {
	Write-Host ("Error on connecting to vCenter Server") -BackgroundColor Yellow -ForegroundColor DarkRed
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/05/using-vmware-powercli-005-deploy-template-v0-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using VMware PowerCLI (#004) – Deploy Template (v0.2)</title>
		<link>http://www.kasraeian.com/2012/05/using-vmware-powercli-004-deploy-template-v0-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-vmware-powercli-004-deploy-template-v0-2</link>
		<comments>http://www.kasraeian.com/2012/05/using-vmware-powercli-004-deploy-template-v0-2/#comments</comments>
		<pubDate>Mon, 07 May 2012 01:01:03 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[VCAP-DCA]]></category>
		<category><![CDATA[Add-PSSnapin]]></category>
		<category><![CDATA[Deploy]]></category>
		<category><![CDATA[Get-VICredentialStoreItem]]></category>
		<category><![CDATA[Move-VM -Destination]]></category>
		<category><![CDATA[New-VM -VMHost -Template]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Set-PowerCLIConfiguration]]></category>
		<category><![CDATA[Start-VM]]></category>
		<category><![CDATA[Template]]></category>
		<category><![CDATA[Using VMware PowerCLI]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware vSphere PowerCLI]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=2067</guid>
		<description><![CDATA[Well, This is a second edition,enhanced or debugged version of my previous &#8220;Deploy Template&#8221; script. I tried to make it a little more user-friendly and added capability of selecting the location (Resource Pool/vApp) which user/admin can place their newly created VM(s) as well as capability of powering on VM(s) after their creation. Also this script [...]]]></description>
			<content:encoded><![CDATA[<p>Well, This is a second edition,enhanced or debugged version of my previous &#8220;<a title="Using VMware PowerCLI (#003) – Deploy Template" onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/2012/05/template-deploy-script/.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/2012/05/template-deploy-script/" target="_blank">Deploy Template</a>&#8221; script.<br />
I tried to make it a little more user-friendly and added capability of selecting the location (Resource Pool/vApp) which user/admin can place their newly created VM(s) as well as capability of powering on VM(s) after their creation.<br />
Also this script can be run from normal &#8220;Microsoft PowerShell&#8221; window just if you have installed &#8220;<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview.png')" onmouseout="removepreview()" href="http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">VMware vSphere PowerCLI</a>&#8221; on your system and it will take care of adding needed snappin. <img src='http://www.kasraeian.com/wp-includes/images/blank.gif' alt=':wink:' class='wp-smiley smiley-20' /> </p>
<p>Your comment and feedback would help me to make it faster, better and more straight forward and I&#8217;d be really happy to receive them.  <img src='http://www.kasraeian.com/wp-includes/images/blank.gif' alt=':wink:' class='wp-smiley smiley-20' />  Again you can download the saved code bellow or check and copy/paste it to &#8220;.ps1&#8243; file.</p>
<p><strong>Update #1:</strong></p>
<p>Current version (v0.2) will work correctly only if environment contains more than one item in each section (templates, customization profile, &#8230;); I&#8217;m working on it to fix this problem and will update this post as soon as I finished the correction and tests.  [May 7, 2012 - 4:57 PM]</p>
<p><strong>Update #2:</strong></p>
<p>I&#8217;ve updated my script to fix &#8220;some problem&#8221; it got as mentioned by &#8220;nWill&#8221; and post it <a title="Using VMware PowerCLI (#005) – Deploy Template (v0.3)" href="http://www.kasraeian.com/2012/05/using-vmware-powercli-005-deploy-template-v0-3/" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/2012/05/using-vmware-powercli-005-deploy-template-v0-3/.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">here</a>. [May 10, 2012 - 4:05 PM]</p>
<div id='wpdm_file_6' class='wpdm_file wpdm-only-button'><div class='cont'><div class='btn_outer'><div class='btn_outer_c'><a class='btn_left  has-counter' rel='6' title='Deploy Template (V0.2)' href='http://www.kasraeian.com/?wpdmact=process&did=Ni5ob3RsaW5r'  >Download</a><span class='btn_right counter'>14 downloads</span></div></div><div class='clear'></div></div></div>
<pre class="brush: powershell; gutter: true; first-line: 1">#####################################################
function Header {
	CLS
	Write-Host "Name:`tDeploy Template Script (v0.2)"
}
#####################################################

# Adding PSSnapin
$pssnap = Get-PSSnapin | Sort-Object Name
$APS = "No"
$PSIndex = 1
1..$pssnap.Count | foreach {
	if ($pssnap[$PSIndex].Name -like "vmware.vimautomation.core") {
		$APS = "Yes"
	}
	$PSIndex++
}
if ($APS -eq "No") { Add-PSSnapin VMware.VimAutomation.Core }

# Enabling multiple connection
$PCC = get-PowerCLIConfiguration
if ($test.DefaultVIServerMode -eq "single") {
	Set-PowerCLIConfiguration -DefaultVIServerMode Multiple
}

# vCenter Server Connection
Header
Write-Host ""
$Target = Read-Host ("Which vCenter Do you want connect to")
if ($global:DefaultVIServer.Name -eq $Target) {
	$CRMB = "Yes"
} else {
	$VICSI = Get-VICredentialStoreItem | Sort-Object Host
	$AI = "No"
	foreach ($item in $VICSI) {
		if ($Target -eq $item.Host) {
			$AI = "Yes"
		}
	}
	if ($AI -eq "No") {
		$cred = Get-Credential
		$NCR = Connect-VIServer -Server $Target -Credential $cred
	} else {
		$NCR = Connect-VIServer -Server $Target
	}
	if ($NCR.IsConnected -eq $true) {
		$CRMB = "Yes"
	} else {
		$CRMB = "No"
	}
}

function MainBody {
	# Template Selection
	Header
	Write-Host ""
	$Templates = Get-Template | Select Name | Sort-Object Name
	$i = 1
	$Templates | %{Write-Host $i":" $_.Name; $i++}
	$SIndex = Read-Host "Enter a number ( 1 -" $Templates.Count ")"
	$STemplate = $Templates[$SIndex - 1].Name

	# Customization Profile Selection
	Header
	Write-Host ""
	$OSCPs = Get-OSCustomizationSpec | Select Name | Sort-Object
	$j = 1
	$OSCPs | %{Write-Host $j":" $_.Name; $j++}
	Write-Host $j": None"
	$OSIndex = Read-Host "Enter a number ( 1 -" $OSCPs.Count+1 ")"
	$SOSCP = $OSCPs[$OSIndex - 1].Name
	if ($OSIndex -eq $j) {
		$SOSCP = "None"
	}

	# Host Selection
	Header
	Write-Host ""
	$VMHosts = Get-VMHost | Select Name | Sort-Object
	$x = 1
	$VMHosts | %{Write-Host $x":" $_.Name; $x++}
	$VMHIndex = Read-Host "Enter a number ( 1 -" $VMHosts.Count ")"
	$SVMHost = $VMHosts[$VMHIndex - 1].Name

	# Datastore Selection
	Header
	Write-Host ""
	$Datastores = Get-VMHost $SVMHost | Get-Datastore | Select Name,FreeSpaceGB,CapacityGB | Sort-Object CapacityGB
	$y = 1
	$Datastores | %{Write-Host $y":" $_.Name"`t`tCapacity (GB):" $_.CapacityGB"`t`tFree Space (GB):" $_.FreeSpaceGB; $y++}
	$DSIndex = Read-Host "Enter a number ( 1 -" $Datastores.count ")"
	$SDatastore = $Datastores[$DSIndex - 1].Name

	# Location Selection
	Header
	Write-Host ""
	$LSA = Read-Host "[R] Resource Pool`n[V] vApp`n[Other Keys] No Config (simple)`nPlease select location for placing new VM(s)"
	$SLocation = "None"
	Switch ($LSA) {
		"r" {
			Write-Host ""
			$ARPs = Get-ResourcePool | Sort-Object Name
			$z = 1
			$ARPs | %{Write-Host $z":" $_.Name; $z++}
			$RPIndex = Read-Host "Enter a number ( 1 -" $ARPs.count ")"
			$SRP = $ARPs[$RPIndex - 1].Name
			$SLocation = $ARPs[$RPIndex - 1]
		}
		"v" {
			Write-Host ""
			$AVAs = Get-VApp | Sort-Object Name
			$k = 1
			$AVAs | %{Write-Host $k":" $_.Name;$k++}
			$VAIndex = Read-Host "Enter a number ( 1 -" $AVAs.cout ")"
			$SVA = $AVAs[$VAIndex - 1].Name
			$SLocation = $AVAs[$VAIndex - 1]
		}
		default { $SLocation = "Root" }
	}

	# Name Selection
	Header
	Write-Host ""
	$SName = Read-Host "Please enter VMs Naming Patern"

	# Getting VM count
	$NVMTD = Read-Host "How many VMs do you want to deploy"

	# Getting confirmation and deploying
	Header
	Write-Host "`nNew VM(s) would be created by bellow configuration
Source Template: $STemplate
Target Host: $SVMHost
Target Datastore: $SDatastore
OS Customization Profile: $SOSCP
VM naming pattern: $SName
Number of VM(s): $NVMTD
Would place on: $SLocation"

	# Action Menu
	$NVMDConf = Read-Host "`n[C] Create VM(s)`n[R] Create and run VM(s)`n[Other Keys] Exit`nPlease select action from list"
	switch ($NVMDConf) {
		"c" {
			Switch ($SOSCP) {
				"None" { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore } }
				default { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore -OSCustomizationSpec $SOSCP } }
			}
			Switch ($SLocation) {
				"None" { break }
				default { $NoOut = Get-VM | Where {$_.Name -like "$SName*"} | Move-VM -Destination $SLocation }
			}
			Write-Host "`n----- Created VMs -----" -NoNewline
			Get-VM | Where {$_.Name -like "$SName*"} | Select Name,PowerState,NumCPU,MemoryMB | Format-Table -AutoSize
			Write-Host "You need to manually start your VMs.`n" -BackgroundColor Yellow -ForegroundColor Blue
		}
		"r" {
			Switch ($SOSCP) {
				"None" { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore | Start-VM } }
				default { $NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore -OSCustomizationSpec $SOSCP | Start-VM } }
			}
			Switch ($SLocation) {
				"None" { break }
				default { $NoOut = Get-VM | Where {$_.Name -like "$SName*"} | Move-VM -Destination $SLocation }
			}
			Write-Host "`n----- Created VMs -----"
			Get-VM | Where {$_.Name -like "$SName*"} | Select Name,PowerState,NumCPU,MemoryMB | Format-Table -AutoSize
		}
		default {
			Write-Host ("All process aborted by user!") -BackgroundColor Yellow -ForegroundColor DarkRed
			break
		}
	}
}

if ($CRMB -eq "Yes") {
	MainBody{}
	Write-Host "Thanks for using `"Deploy Template Script (v0.2)`"`nSohrab Kasraeian Fard (@Kasraeian)`n"
} else {
	Write-Host "Error on connecting to vCenter Server" -BackgroundColor Yellow -ForegroundColor DarkRed
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/05/using-vmware-powercli-004-deploy-template-v0-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Using VMware PowerCLI (#003) &#8211; Deploy Template</title>
		<link>http://www.kasraeian.com/2012/05/template-deploy-script/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=template-deploy-script</link>
		<comments>http://www.kasraeian.com/2012/05/template-deploy-script/#comments</comments>
		<pubDate>Fri, 04 May 2012 23:53:41 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[VCAP-DCA]]></category>
		<category><![CDATA[Deploy]]></category>
		<category><![CDATA[Get-VICredentialStoreItem]]></category>
		<category><![CDATA[New-VM -VMHost -Template]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Template]]></category>
		<category><![CDATA[Using VMware PowerCLI]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware vSphere PowerCLI]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=1982</guid>
		<description><![CDATA[This script will help users/admins for deploying multiple VMs from one of available templates and unlike other scripts I saw so far which are file (answer file) based, this script is interactive and need and interaction of admin. In next version I&#8217;d try to add some more options like &#8220;adding to resource pool or vApp&#8221;, [...]]]></description>
			<content:encoded><![CDATA[<p>This script will help users/admins for deploying multiple VMs from one of available templates and unlike other scripts I saw so far which are file (answer file) based, this script is interactive and need and interaction of admin.<br />
In next version I&#8217;d try to add some more options like &#8220;adding to resource pool or vApp&#8221;, adding custom description and &#8230;; for this script you can simply copy/paste it to new &#8220;.ps1&#8243; file or download below file and for running this script you need to have &#8220;<a href="http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">VMware vSphere PowerCLI</a>&#8221; on your system.</p>
<p>Feel free to send your comment and idea and if you find any bug/problem in this script please let me know.</p>
<div id='wpdm_file_5' class='wpdm_file wpdm-only-button'><div class='cont'><div class='btn_outer'><div class='btn_outer_c'><a class='btn_left  has-counter' rel='5' title='Deploy Template (V0.1)' href='http://www.kasraeian.com/?wpdmact=process&did=NS5ob3RsaW5r'  >Download</a><span class='btn_right counter'>25 downloads</span></div></div><div class='clear'></div></div></div>
<pre class="brush: powershell; gutter: true; first-line: 1">#####################################################
Write-Host "Name:`tDeploy Template Script
By:`tSohrab Kasraeian Fard (@Kasraeian)
Ver:`t0.1"
#####################################################

# Enabling multiple connection
$PCC = get-PowerCLIConfiguration
if ($test.DefaultVIServerMode -eq "single") {
	Set-PowerCLIConfiguration -DefaultVIServerMode Multiple
}

# vCenter Server Connection
Write-Host ""
$Target = Read-Host ("Which vCenter Do you want")
if ($global:DefaultVIServer.Name -eq $Target) {
	Write-Host "You already connected!"
	$CRMB = "Yes"
} else {
	$VICSI = Get-VICredentialStoreItem | Sort-Object Host
	$AI = "No"
	foreach ($item in $VICSI) {
		if ($Target -eq $item.Host) {
			$AI = "Yes"
		}
	}
	if ($AI -eq "No") {
		$cred = Get-Credential
		$NCR = Connect-VIServer -Server $Target -Credential $cred
	} else {
		$NCR = Connect-VIServer -Server $Target
	}
	if ($NCR.IsConnected -eq $true) {
		$CRMB = "Yes"
	} else {
		$CRMB = "No"
	}
}

function MainBody {
	# Template Selection
	Write-Host ""
	$Templates = Get-Template | Select Name | Sort-Object Name
	$i = 1
	$Templates | %{Write-Host $i":" $_.Name; $i++}
	$SIndex = Read-Host "Enter a number ( 1 -" $Templates.Count ")"
	$STemplate = $Templates[$SIndex - 1].Name
	Write-Host "You have selected" $STemplate

	# Customization Profile Selection
	Write-Host ""
	$OSCPs = Get-OSCustomizationSpec | Select Name | Sort-Object
	$j = 1
	$OSCPs | %{Write-Host $j":" $_.Name; $j++}
	Write-Host $j": None"
	$OSIndex = Read-Host "Enter a number ( 1 -" $OSCPs.Count ")"
	$SOSCP = $OSCPs[$OSIndex - 1].Name
	if ($OSIndex -eq $j) {
		Write-Host "You didn't select any OS Customization Profile"
		$SOSCP = "None"
	} else {
		Write-Host "You have selected" $SOSCP
	}

	# Host Selection
	Write-Host ""
	$VMHosts = Get-VMHost | Select Name | Sort-Object
	$x = 1
	$VMHosts | %{Write-Host $x":" $_.Name; $x++}
	$VMHIndex = Read-Host "Enter a number ( 1 -" $VMHosts.Count ")"
	$SVMHost = $VMHosts[$VMHIndex - 1].Name
	Write-Host "You have selected" $SVMHost

	# Datastore Selection
	write-Host ""
	$Datastores = Get-VMHost $SVMHost | Get-Datastore | Select Name,FreeSpaceGB,CapacityGB | Sort-Object CapacityGB
	$y = 1
	$Datastores | %{Write-Host $y":" $_.Name"`t`tCapacity (GB):" $_.CapacityGB"`t`tFree Space (GB):" $_.FreeSpaceGB; $y++}
	$DSIndex = Read-Host "Enter a number ( 1 -" $Datastores.count ")"
	$SDatastore = $Datastores[$DSIndex - 1].Name
	Write-Host "You have selected" $SDatastore

	# Name Selection
	Write-Host ""
	$SName = Read-Host "Please enter VMs Naming Patern"

	# Getting VM count
	Write-Host ""
	$NVMTD = Read-Host "How many VMs do you want to deploy"

	# Getting confirmation and deploying
	Write-Host "`nPlease confirm if you want to deploy $NVMTD by bellow settings
	Source Template: $STemplate
	Target Host: $SVMHost
	Target Datastore: $SDatastore
	OS Customization Profile: $SOSCP
	VM naming pattern: $SName"

	$NVMDConf = Read-Host "It's confirmed (Y/N)"
	if ($NVMDConf -eq "Y") {
		if ($SOSCP -eq "None") {
			$NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore }
		} else {
			$NVMs = 1..$NVMTD | foreach { New-VM -VMHost $SVMHost -Name $SName$_ -Template $STemplate -Datastore $SDatastore -OSCustomizationSpec $SOSCP }
		}
		Write-Host "`n----- Created VMs -----"
		Get-VM | Where {$_.Name -like "$SName*"} | Select Name,NumCPU,MemoryMB | Format-Table -AutoSize
	} else {
		Write-Host "All process aborted by user!"
	}

	# Power On Option
	Write-Host ""
	$SPOO = Read-Host "Do you want to power on all created VMs (Y/N)"
	if ($SPOO -eq "Y") {
		$SVMs = Start-VM -VM $NVMs
		Write-Host "`n----- Powered On VMs -----"
		Get-VM | Where {$_.Name -like "$SName*"} | Select Name,NumCPU,MemoryMB,PowerState | Format-Table -AutoSize
	} else {
		Write-Host "You need to manually start your VMs."
	}
}

if ($CRMB -eq "Yes") {
	MainBody{}
} else {
	Write-Host "Error on connecting to vCenter Server"
}</pre>
<p>Resources I&#8217;ve used so far for creation of this script:<br />
1. <a href="http://communities.vmware.com/message/1336465#1336465" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/communities.vmware.com/message/1336465#1336465.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">Community answer</a> from <a href="http://lucd.info/" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/lucd.info/.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">LUC Dekens</a> ( <a href="http://twitter.com/LucD22" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/twitter.com/LucD22.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">@LUCD22</a> )<br />
2. <a href="http://blog.vmpros.nl/2011/01/16/vmware-deploy-multiple-vms-from-template-with-powercli/" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/blog.vmpros.nl/2011/01/16/vmware-deploy-multiple-vms-from-template-with-powercli/.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">Comment</a> from <a href="http://virtu-al.net/" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/virtu-al.net/.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">Alan Renouf</a> ( <a href="http://twitter.com/alanrenouf" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/twitter.com/alanrenouf.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">@alanrenouf</a> )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/05/template-deploy-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using VMware PowerCLI (#002) &#8211; User Accounts</title>
		<link>http://www.kasraeian.com/2012/04/using-vmware-powercli-002-user-accounts/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-vmware-powercli-002-user-accounts</link>
		<comments>http://www.kasraeian.com/2012/04/using-vmware-powercli-002-user-accounts/#comments</comments>
		<pubDate>Sun, 29 Apr 2012 09:42:07 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[VCAP-DCA]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[ESXi 5.0]]></category>
		<category><![CDATA[Get-VMHostAccount]]></category>
		<category><![CDATA[New-VMHostAccount]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Remove-VMHostAccount]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[Using VMware PowerCLI]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware vSphere PowerCLI]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=1977</guid>
		<description><![CDATA[As part of my studying, in this post I&#8217;d post one little scripts which I made so far for working with user accounts on &#8220;VMware ESXi&#8221; hosts. This script will add or remove user account from all hosts connected to one &#8220;VMware vCenter&#8221; server, in next version I&#8217;d add selecting function so user can be [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my studying, in this post I&#8217;d post one little scripts which I made so far for working with user accounts on &#8220;VMware ESXi&#8221; hosts.<br />
This script will add or remove user account from all hosts connected to one &#8220;VMware vCenter&#8221; server, in next version I&#8217;d add selecting function so user can be added/removed from specific data center, cluster or just single host.</p>
<p>I&#8217;m a beginner so this script might have (sure have) some problems and I&#8217;d be really grateful if you could help me to complete it better by posting your comment and feedback and I hope you find it useful.</p>
<p>You can copy/paste bellow code to &#8220;.ps1&#8243; file and run it using &#8220;<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview.png')" onmouseout="removepreview()" href="http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">VMware vSphere PowerCLI</a>&#8221; or simply download it.</p>
<p><span style="text-align: center;"><div id='wpdm_file_4' class='wpdm_file wpdm-only-button'><div class='cont'><div class='btn_outer'><div class='btn_outer_c'><a class='btn_left  has-counter' rel='4' title='Add/Remove User Accounts (V0.1)' href='http://www.kasraeian.com/?wpdmact=process&did=NC5ob3RsaW5r'  >Download</a><span class='btn_right counter'>11 downloads</span></div></div><div class='clear'></div></div></div></span></p>
<pre class="brush: powershell; gutter: true; first-line: 1">#####################################################
Write-Host "Name:`tAdd/Remove User Accounts Script
By:`t`tSohrab Kasraeian Fard (@Kasraeian)
Ver:`t`t0.1"
#####################################################
# 0. Enabling multiple connection
$PCC = Get-PowerCLIConfiguration
if ($test.DefaultVIServerMode -eq "single") {
	Set-PowerCLIConfiguration -DefaultVIServerMode Multiple
}

# 1. vCenter Server Connection
Write-Host ""
$Target = Read-Host ("Which vCenter Do you want to connect")
if ($global:DefaultVIServer.Name -eq $Target) {
	Write-Host "You already connected to this vCenter"
} else {
	$TCred = Get-Credential
	Connect-VIServer -Server $Target -Credential $TCred
}

# 2. Hosts connection
if ($global:DefaultVIServer.Name -eq $Target) {
	Write-Host ("`nPlease provide user credential for host level access")
	$VMHCred = Get-Credential
	$VMHosts = Get-VMHost | where {$_.PowerState -eq "PoweredOn"} | sort-Object Name
	foreach ($VMHost in $VMHosts) {
		Connect-VIServer -Server $VMHost -Credential $VMHCred
	}
	cls
	Write-Host ""
} else {
	Write-Host "Error on connecting to vCenter server ($Target)"
}

# Main Body
ListUser
Menu

# Listing Available Users On All Hosts
function ListUser {
	foreach ($VMHost in $VMHosts) {
		$VMHA = Get-VMHostAccount -Server $VMHost.Name
		Write-Host "---------- " $VMHA.Count " users found on host `"$VMHost`" ----------"
		$i = 1
		foreach ($HA in $VMHA) { Write-Host "Name"$i": " $HA.Name; $i++ }
		Write-Host "" }
}

# Main Menu
function Menu {
	$FAns = Read-Host ("[A] Add User`n[R] Remove User`n[Other keys] Exit`nPlease specify the action")
	switch ($FAns) {
	A {AddUser{}}
	R {RemoveUser{}}
	default {Quit{}}
	}
}

# Refresh Process
function Refresh {
	cls
	ListUser
	Menu
}

# Adding User To All Hosts
function AddUser {
	$NUID = Read-Host ("Please enter new username")
	$NUPS = Read-Host ("Please enter password for $NUID")
	$SAAns = Read-Host ("Do you want this user to have shell access (Y/N)")
	foreach ($VMHost in $VMHosts) {
		Write-Host "Adding $NUID user account to $VMHost"
		if ($SAAns -eq "Y") {
			New-VMHostAccount -Id $NUID -Password $NUPS -GrantShellAccess:$true -Server $VMHost.Name }
		elseif ($SAAns -eq "N") {
			New-VMHostAccount -Id $NUID -Password $NUPS -GrantShellAccess:$false -Server $VMHost.Name }
	}
	Refresh
}

# Removing User From All Hosts
function RemoveUser {
	$TUID = Read-Host ("Please enter target username")
	$TURC = Read-Host ("Do you confirm you want to remove $TUID from all hosts (Y/N)")
	if ($TURC -eq "Y") {
		foreach ($VMHost in $VMHosts) {
		Get-VMHostAccount -Server $VMHost.Name -Id $TUID | Remove-VMHostAccount -Confirm:$true }
	Refresh
	}
}

# Quiting
function Quit {
	Write-Host "Thanks for your uasge.`nId be glad to receive your feedback/comment on sohrab@kasraeian.com`n`n"
	Disconnect-VIServer -Server * -Confirm:$true
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/04/using-vmware-powercli-002-user-accounts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerCLI, TSM and Warning</title>
		<link>http://www.kasraeian.com/2012/04/powercli-tsm-and-warning/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powercli-tsm-and-warning</link>
		<comments>http://www.kasraeian.com/2012/04/powercli-tsm-and-warning/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 08:49:54 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[ESXi 5.0]]></category>
		<category><![CDATA[Get-VMHostAdvancedConfiguration]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Remote TSM]]></category>
		<category><![CDATA[Set-VMHostAdvancedConfiguration]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[TSM]]></category>
		<category><![CDATA[UserVars.SuppressShellWarning]]></category>
		<category><![CDATA[vCenter]]></category>
		<category><![CDATA[VMHostService]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware vSphere PowerCLI]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=1986</guid>
		<description><![CDATA[Well, this post is all about doing some administration tasks using &#8220;VMware PowerCLI&#8220;. 1. Remote TSM (SSH) Think about conditions you&#8217;ve added 30 new hosts to your vCenter and for some reasons  you want to enable remote access (SSH) on all these hosts; there are multiple ways like: 1. Enabling this option from &#8220;DCUI&#8221; by [...]]]></description>
			<content:encoded><![CDATA[<p>Well, this post is all about doing some administration tasks using &#8220;<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview.png')" onmouseout="removepreview()" href="http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli?view=overview" target="_blank">VMware PowerCLI</a>&#8220;.</p>
<p><span style="color: #3366ff;"><strong>1. Remote TSM (SSH)</strong></span></p>
<p>Think about conditions you&#8217;ve added 30 new hosts to your vCenter and for some reasons  you want to enable remote access (SSH) on all these hosts; there are multiple ways like:<br />
1. Enabling this option from &#8220;DCUI&#8221; by local access or using remote server management option (iLO/DRAC)<br />
2. Enabling this option one by one on all hosts using vSphere Client (ServerConfigurationSecurity ProfileServices)<br />
3. Or better and faster way would be running one little script to do it for you</p>
<p>bellow you can find the related script which will let you enable remote access (Remote TSM) on all hosts connected to one VMware vCenter server.</p>
<pre class="brush: powershell; gutter: true; first-line: 1"># Getting vCenter server information (IP/DNS)
$VCSrv = Read-Host ("Which vCenter server do you want to connect")
# Getting credential for connection
$cred = Get-Credential
# Connecting to the vCenter Server
Connect-VIServer -Server $VCSrv -Credential $cred
# Getting list of available hosts
$VMHosts = Get-VMHost | Sort-Object Name
# Viewing current state of "Remote TSM (SSH)" service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"}
# Enabling service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"} | Set-VMHostService -Policy On</pre>
<p>Also for disabling &#8220;Remote TSM&#8221; on all hosts you can change last line on above script with bellow line.</p>
<pre class="brush: powershell; gutter: true; first-line: 1"># Disabling service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"} | Set-VMHostService -Policy Off</pre>
<p>Up to now, you just enabled or disabled this service but you might want to run or stop it as well, so bellow you can find two related commands:</p>
<pre class="brush: powershell; gutter: true; first-line: 1"># Starting "Remote TSM (SSH)" service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"} | Start-VMHostService

# Stopping "Remote TSM (SSH)" service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"} | Stop-VMHostService</pre>
<p><span style="color: #3366ff;"><strong><span id="more-1986"></span>2. Local TSM</strong></span></p>
<p>Sometimes you might need to have a local access on your &#8220;VMware ESXi&#8221; host(s) for troubleshooting, maintenance or other task, in these cases you can enable local TSM on each host one by one or running one little script which will take care of this for you.</p>
<pre class="brush: powershell; gutter: true; first-line: 1"># Getting vCenter server information (IP/DNS)
$VCSrv = Read-Host ("Which vCenter server do you want to connect")
# Getting credential for connection
$cred = Get-Credential
# Connecting to the vCenter Server
Connect-VIServer -Server $VCSrv -Credential $cred
# Getting list of available hosts
$VMHosts = Get-VMHost | Sort-Object Name
# Viewing current state of "Local TSM" service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"}
# Enabling service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"} | Set-VMHostService -Policy On</pre>
<p>After finishing that task you might want to disable it <img src='http://www.kasraeian.com/wp-includes/images/blank.gif' alt=':wink:' class='wp-smiley smiley-20' /> , so here the related script for disabling this feature on all hosts, just replace this line with last line on above script.</p>
<pre class="brush: powershell; gutter: true; first-line: 1"># Disabling service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"} | Set-VMHostService -Policy Off</pre>
<p>Just like, &#8220;Remote TSM&#8221; you have enabled/disabled service but not start or stop it yet, bellow you can find related code:</p>
<pre class="brush: powershell; gutter: true; first-line: 1"># Starting "TSM" service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"} | Start-VMHostService

# Stopping "TSM" service
Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"} | Stop-VMHostService</pre>
<p><strong style="color: #3366ff;">3. TSM related warning</strong></p>
<p>All hosts which have this feature enabled on them, would show a below warning if you connect to them by vSphere Client.<br />
<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/04/P4-14-02.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/04/P4-14-02.jpg" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/04/P4-14-02.jpg.png')" onmouseout="removepreview()" onclick="removepreview()"><img class="alignnone size-medium wp-image-2000" title="P4-14-02" src="http://www.kasraeian.com/wp-content/uploads/2012/04/P4-14-02-600x270.jpg" alt="" width="600" height="270" /></a></p>
<p>Again, for fixing this problem there is multiple ways, here are two of them:<br />
1. Change one &#8220;Host Advance Configuration&#8221; value from 0 to 1 (ServerConfigurationAdvanced SettingsUserVarsUserVars.SuppressShellWarning)<br />
2. Or running script which is much faster and easier</p>
<p>Bellow you can find related script which would disable this warning on hosts with &#8220;Remote TSM (SSH)&#8221; enabled on them.</p>
<pre class="brush: powershell; gutter: true; first-line: 1"># Getting vCenter server information (IP/DNS)
$VCSrv = Read-Host ("Which vCenter server do you want to connect")
# Getting credential for connection
$cred = Get-Credential
# Connecting to the vCenter Server
Connect-VIServer -Server $VCSrv -Credential $cred
# Getting list of available hosts
$VMHosts = Get-VMHost | Sort-Object Name
# Disabling TSM related warning
Set-VMHostAdvancedConfiguration -VMHost $VMHosts -Name "UserVars.SuppressShellWarning" -Value 1</pre>
<p>For security reasons, you might be notified when this feature enabled on any host so you can do opposite and enabling this warning by bellow command.</p>
<pre class="brush: powershell; gutter: true; first-line: 1"># Enabling TSM related warning
Set-VMHostAdvancedConfiguration -VMHost $VMHosts -Name "UserVars.SuppressShellWarning" -Value 0</pre>
<p><span style="color: #3366ff;"><strong>Note:</strong></span><br />
#1. For running above services run line &#8220;#2&#8243; and for stopping them run line &#8220;#5&#8243; one each section.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/04/powercli-tsm-and-warning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vExpert 2012</title>
		<link>http://www.kasraeian.com/2012/04/vexpert-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vexpert-2012</link>
		<comments>http://www.kasraeian.com/2012/04/vexpert-2012/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 11:50:25 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[vExpert]]></category>
		<category><![CDATA[vExpert 2011]]></category>
		<category><![CDATA[vExpert 2012]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=1978</guid>
		<description><![CDATA[First of all let me say congrats to all new and reconfirmed vExpert and wish you all best luck in this year. Well the final list has come out few days ago and it announcing 434 new and reconfirmed vExpert for this year and I&#8217;m not there. In my personal opinion, I did better than [...]]]></description>
			<content:encoded><![CDATA[<p>First of all let me say congrats to all new and reconfirmed vExpert and wish you all best luck in this year.</p>
<p>Well the final list has come out few days ago and it announcing 434 new and reconfirmed vExpert for this year and I&#8217;m not there.<br />
In my personal opinion, I did better than last year which give me the opportunity to receive the &#8220;vExpert 2011&#8243; honor, but in same time I&#8217;m sure and saw all other friends did their best as well so it will raise a base line for selection.</p>
<p>I&#8217;m respecting the selection while I&#8217;m really loved to be in this list again, it reminds me to work harder if I want to receive this honor and keep it.</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/04/vexpert-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VIBs Skipped</title>
		<link>http://www.kasraeian.com/2012/03/vibs-skipped/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vibs-skipped</link>
		<comments>http://www.kasraeian.com/2012/03/vibs-skipped/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 13:46:35 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[5.0 update 1]]></category>
		<category><![CDATA[esxcli]]></category>
		<category><![CDATA[esxcli software profile update -d]]></category>
		<category><![CDATA[esxcli software sources profile list -d]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[ESXi 5.0]]></category>
		<category><![CDATA[update 1]]></category>
		<category><![CDATA[VIBs Skipped]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=1919</guid>
		<description><![CDATA[Well, I didn&#8217;t mention it like many might not mention it, while you applying any patches or updates on your &#8220;VMware ESXi&#8221; hosts, it will show the result which containing the &#8220;Successful or Failed&#8221; prompt. Most of times I did this process, I checked the result and walked a way without checking which &#8220;VIBs Skipped&#8221;. [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I didn&#8217;t mention it like many might not mention it, while you applying any patches or updates on your &#8220;VMware ESXi&#8221; hosts, it will show the result which containing the &#8220;Successful or Failed&#8221; prompt.<br />
Most of times I did this process, I checked the result and walked a way without checking which &#8220;VIBs Skipped&#8221;.<br />
Until yesterday, which I received a <a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/2012/03/updating-esxi-5-0-to-esxi-5-0-update-1/#comment-974.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/2012/03/updating-esxi-5-0-to-esxi-5-0-update-1/#comment-974" target="_blank">comment</a> on one of my <a title="Updating “ESXi 5.0″ to “ESXi 5.0 Update 1″" onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/2012/03/updating-esxi-5-0-to-esxi-5-0-update-1/.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/2012/03/updating-esxi-5-0-to-esxi-5-0-update-1/" target="_blank">posts</a> which I asked about &#8220;VIBs Skipped&#8221; the update process; I&#8217;ve answered as soon as I saw that but after double checking the KBs and tested my personal theory I decided to make a post about it.</p>
<h3>Question:</h3>
<blockquote><p>Even though the update was successful according to the output from the commands, there was a whole list of VIBs skipped. In the output it says “VIBs Skipped: …” and lists a lot of them. Any idea why this is? When using the standard profile in the patch file, I would have thought it would apply all VIBs.</p></blockquote>
<h3>My first answer:</h3>
<blockquote><p>Well, I guess VIBs would be updated only if they are older than presented one which include in patch.<br />
If all VIBs going to be overwritten over and over again, it may cause some problem (1st one is the reboot required) so it will check and skip those VIBs which are OK.<br />
AFAIK and I saw, each update contains all needed files from previous updates so if you already have host with newer source, update process may skip some VIBs.</p></blockquote>
<h3>And now, the main reason:</h3>
<p>Let me describe it with one example,  if you trying to update your hosts with first release of &#8220;VMware ESXi 5.0&#8243; without any update (built number &#8220;469512&#8243;), using &#8220;<a title="Direct link from &quot;VMware&quot; site" href="https://hostupdate.vmware.com/software/VUM/OFFLINE/release-325-20111212-924952/ESXi500-201112001.zip" target="_blank">ESXi500-201112001.zip</a>&#8221; patch (built number &#8220;<a title="KB 2007680" onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/kb.vmware.com/kb/2007680.png')" onmouseout="removepreview()" href="http://kb.vmware.com/kb/2007680" target="_blank">515841</a>&#8220;) you will only update 6 VIBs as listed below, the other VIBs without update will &#8220;Skip&#8221; the update process.  <img src='http://www.kasraeian.com/wp-includes/images/blank.gif' alt=':wink:' class='wp-smiley smiley-20' /> </p>
<table border="0" align="center">
<tbody>
<tr>
<td style="text-align: center;">Item</td>
<td style="text-align: center;">Updated VIB Name/Version</td>
<td style="text-align: center;">Old VIB Name/Version</td>
<td style="text-align: center;">Severity</td>
<td style="text-align: center;">Related KB</td>
</tr>
<tr>
<td style="text-align: center;">1</td>
<td>VMware:esx-base:5.0.0-0.3.515841</td>
<td>VMware:esx-base:5.0.0-0.0.469512</td>
<td>Important</td>
<td><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/kb.vmware.com/kb/2007671.png')" onmouseout="removepreview()" href="http://kb.vmware.com/kb/2007671" target="_blank">KB 2007671</a></td>
</tr>
<tr>
<td style="text-align: center;">2</td>
<td>VMware:tools-light:5.0.0-0.3.515841</td>
<td>VMware:tools-light:5.0.0-0.0.469512</td>
<td>Important</td>
<td><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/kb.vmware.com/kb/2007672.png')" onmouseout="removepreview()" href="http://kb.vmware.com/kb/2007672" target="_blank">KB 2007672</a></td>
</tr>
<tr>
<td style="text-align: center;">3</td>
<td>VMware:net-e1000:8.0.3.1-2vmw.500.0.3.515841</td>
<td>VMware:net-e1000:8.0.3.1-2vmw.500.0.0.469512</td>
<td>Important</td>
<td><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/kb.vmware.com/kb/2007673.png')" onmouseout="removepreview()" href="http://kb.vmware.com/kb/2007673" target="_blank">KB 2007673</a></td>
</tr>
<tr>
<td style="text-align: center;">4</td>
<td>VMware:net-e1000e:1.1.2-3vmw.500.0.3.515841</td>
<td>VMware:net-e1000e:1.1.2-3vmw.500.0.0.469512</td>
<td>Important</td>
<td><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/kb.vmware.com/kb/2007673.png')" onmouseout="removepreview()" href="http://kb.vmware.com/kb/2007673" target="_blank">KB 2007673</a></td>
</tr>
<tr>
<td style="text-align: center;">5</td>
<td>VMware:misc-drivers:5.0.0-0.3.515841</td>
<td>VMware:misc-drivers:5.0.0-0.0.469512</td>
<td>Low</td>
<td><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/kb.vmware.com/kb/2007674.png')" onmouseout="removepreview()" href="http://kb.vmware.com/kb/2007674" target="_blank">KB 2007674</a></td>
</tr>
<tr>
<td style="text-align: center;">6</td>
<td>VMware:net-be2net:4.0.88.0-1vmw.500.0.3.515841</td>
<td>VMware:net-be2net:4.0.88.0-1vmw.500.0.0.469512</td>
<td>Low</td>
<td><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/kb.vmware.com/kb/2007675.png')" onmouseout="removepreview()" href="http://kb.vmware.com/kb/2007675" target="_blank">KB 2007675</a></td>
</tr>
</tbody>
</table>
<p>Below, you can check the whole process of updating one host using &#8220;<a title="Direct link from &quot;VMware&quot; site" href="https://hostupdate.vmware.com/software/VUM/OFFLINE/release-325-20111212-924952/ESXi500-201112001.zip" target="_blank">ESXi500-201112001.zip</a>&#8220; and here are the <a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/VIBs-Comparison.xlsx.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/VIBs-Comparison.xlsx">comparison</a> of its VIBs <a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/VIBs-BU.txt.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/VIBs-BU.txt">before</a> and <a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/VIBs-AU.txt.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/VIBs-AU.txt">after</a> applying the patch.</p>

<div class="ngg-galleryoverview" id="ngg-gallery-10-1919">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://www.kasraeian.com/2012/03/vibs-skipped/?show=slide">
			[Show as slideshow]		</a>
	</div>

	
	<!-- Thumbnails -->
		
	<div id="ngg-image-132" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/p4-11-01.jpg" title="Check the host image profile and built number" class="shutterset_set_10" >
								<img title="p4-11-01" alt="p4-11-01" src="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/thumbs/thumbs_p4-11-01.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-133" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/p4-11-02.jpg" title="list the currently available VIBs on the host prior to the update (applying patch) using below command&lt;br /&gt;
esxcli software vib list" class="shutterset_set_10" >
								<img title="p4-11-02" alt="p4-11-02" src="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/thumbs/thumbs_p4-11-02.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-134" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/p4-11-03.jpg" title="Put the host under maintenance mode" class="shutterset_set_10" >
								<img title="p4-11-03" alt="p4-11-03" src="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/thumbs/thumbs_p4-11-03.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-135" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/p4-11-04.jpg" title="Check the available  image profile in update file and select one, then install update using below commands&lt;br /&gt;
esxcli software sources profile list -d [UPDATE_FILE_ADDRESS]&lt;br /&gt;
esxcli software profile update -d [UPDATE_FILE_ADDRESS] -p [SELECTED_IMAGE_PROFILE]" class="shutterset_set_10" >
								<img title="p4-11-04" alt="p4-11-04" src="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/thumbs/thumbs_p4-11-04.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-136" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/p4-11-05.jpg" title="After successfully installed the update, reboot the hosts and check for it's image profile and built number" class="shutterset_set_10" >
								<img title="p4-11-05" alt="p4-11-05" src="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/thumbs/thumbs_p4-11-05.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-137" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/p4-11-06.jpg" title="Again, check the available VIBs on the host after update, you will find new date on updated VIBs and the rest of VIBs would skip the update process ;)" class="shutterset_set_10" >
								<img title="p4-11-06" alt="p4-11-06" src="http://www.kasraeian.com/wp-content/gallery/vibs-skipped/thumbs/thumbs_p4-11-06.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class="ngg-clear"></div> 	
</div>

<script type="text/javascript" src="http://www.kasraeian.com/wp-content/plugins/nextgen-gallery-voting/js/ajaxify-stars.js"></script><link rel="stylesheet" href="http://www.kasraeian.com/wp-content/plugins/nextgen-gallery-voting/css/star_rating.css" type="text/css" media="screen" /><div class="nggv_container"><span class="inline-rating"><ul class="star-rating"><li class="current-rating" style="width:57%;">Currently 2.9/5 Stars.</li><li><a href="http://www.kasraeian.com/feed/?gid=10&r=20" title="1 star out of 5" class="one-star">1</a></li><li><a href="http://www.kasraeian.com/feed/?gid=10&r=40" title="2 stars out of 5" class="two-stars">2</a></li><li><a href="http://www.kasraeian.com/feed/?gid=10&r=60" title="3 stars out of 5" class="three-stars">3</a></li><li><a href="http://www.kasraeian.com/feed/?gid=10&r=80" title="4 stars out of 5" class="four-stars">4</a></li><li><a href="http://www.kasraeian.com/feed/?gid=10&r=100" title="5 stars out of 5" class="five-stars">5</a></li></ul></span><img class="nggv-star-loader" src="http://www.kasraeian.com/wp-content/plugins/nextgen-gallery-voting/images/loading.gif" style="display:none;" /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/03/vibs-skipped/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OS Code for VMware View</title>
		<link>http://www.kasraeian.com/2012/03/os-code-for-vmware-view/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=os-code-for-vmware-view</link>
		<comments>http://www.kasraeian.com/2012/03/os-code-for-vmware-view/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 14:44:06 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[pae-OSVersion]]></category>
		<category><![CDATA[View 5.0]]></category>
		<category><![CDATA[View 5.0.1]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware View]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[Windows 8 CP]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=1866</guid>
		<description><![CDATA[This post is created based on my personal test and what I read on &#8220;cliffdavies.com&#8221; site (This article was first published by Andre Leibovici ( @andreleibovici at &#8220;myvirtualcloud.net&#8220;) and base on it, if you want &#8220;Windows 8 CP&#8221; showing up in your &#8220;VMware View Administrator Portal&#8221; you should make some manual changes on the ADAM [...]]]></description>
			<content:encoded><![CDATA[<p>This post is created based on my personal test and what I read on &#8220;<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/cliffdavies.com/blog/virtualization/how-to-access-windows-8-cp-via-pcoip-with-vmware-view/.png')" onmouseout="removepreview()" href="http://cliffdavies.com/blog/virtualization/how-to-access-windows-8-cp-via-pcoip-with-vmware-view/" target="_blank">cliffdavies.com</a>&#8221; site (This article was first published by Andre Leibovici ( <a href="http://twitter.com/andreleibovici" target="_blank">@andreleibovici</a> <img src='http://www.kasraeian.com/wp-includes/images/blank.gif' alt=')' class='wp-smiley smiley-20' /> at &#8220;<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/myvirtualcloud.net/?p=2991.png')" onmouseout="removepreview()" href="http://myvirtualcloud.net/?p=2991" target="_blank">myvirtualcloud.net</a>&#8220;) and base on it, if you want &#8220;Windows 8 CP&#8221; showing up in your &#8220;VMware View Administrator Portal&#8221; you should make some manual changes on the ADAM which installed by &#8220;VMware View&#8221;; for process of this change you can check above links.</p>
<p>Below table showing different OS code and their pair OS Name.</p>
<table border="0">
<tbody>
<tr>
<td style="text-align: center;">Code</td>
<td style="text-align: center;">OS</td>
</tr>
<tr>
<td style="text-align: center;">1</td>
<td>Windows XP</td>
</tr>
<tr>
<td style="text-align: center;">2</td>
<td>Windows Vista</td>
</tr>
<tr>
<td style="text-align: center;">3</td>
<td>Windows 2003</td>
</tr>
<tr>
<td style="text-align: center;">4</td>
<td>Windows 2008</td>
</tr>
<tr>
<td style="text-align: center;">5</td>
<td>Windows 7</td>
</tr>
</tbody>
</table>
<p>Screen of what you would get if you changing this number (pae-OSVersion):</p>
<h3>Number 1:</h3>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-11.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-11.jpg"><img class="alignnone size-medium wp-image-1867" title="P4-08-11" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-11-600x380.jpg" alt="" width="600" height="380" /></a><br />
<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-12.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-12.jpg"><img class="alignnone size-medium wp-image-1868" title="P4-08-12" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-12-600x313.jpg" alt="" width="600" height="313" /></a></p>
<h3>Number 2:</h3>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-21.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-21.jpg"><img class="alignnone size-medium wp-image-1867" title="P4-08-21" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-21-600x380.jpg" alt="" width="600" height="380" /></a><br />
<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-22.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-22.jpg"><img class="alignnone size-medium wp-image-1868" title="P4-08-22" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-22-600x313.jpg" alt="" width="600" height="313" /></a></p>
<h3>Number 3:<span id="more-1866"></span></h3>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-31.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-31.jpg"><img class="alignnone size-medium wp-image-1867" title="P4-08-31" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-31-600x380.jpg" alt="" width="600" height="380" /></a><br />
<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-32.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-32.jpg"><img class="alignnone size-medium wp-image-1872" title="P4-08-32" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-32-600x382.jpg" alt="" width="600" height="382" /></a></p>
<h3>Number 4:</h3>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-41.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-41.jpg"><img class="alignnone size-medium wp-image-1867" title="P4-08-41" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-41-600x380.jpg" alt="" width="600" height="380" /></a><br />
<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-42.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-42.jpg"><img class="alignnone size-medium wp-image-1874" title="P4-08-42" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-42-600x381.jpg" alt="" width="600" height="381" /></a></p>
<h3>Number 5:</h3>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-51.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-51.jpg"><img class="alignnone size-medium wp-image-1867" title="P4-08-51" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-51-600x380.jpg" alt="" width="600" height="380" /></a><br />
<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-52.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-52.jpg" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-08-52.jpg.png')" onmouseout="removepreview()" onclick="removepreview()"><img class="alignnone size-medium wp-image-1876" title="P4-08-52" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-08-52-600x382.jpg" alt="" width="600" height="382" /></a></p>
<h3>Number 6:</h3>
<p>Well, I&#8217;ve checked but it seems there is no &#8220;6&#8243; for any OS yet, may be <strong>Windows 8</strong> get this number! <img src='http://www.kasraeian.com/wp-includes/images/blank.gif' alt=':wink:' class='wp-smiley smiley-20' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/03/os-code-for-vmware-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Thin PC &amp; VMware View 5.0</title>
		<link>http://www.kasraeian.com/2012/03/windows-thin-pc-vmware-view-5-0/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=windows-thin-pc-vmware-view-5-0</link>
		<comments>http://www.kasraeian.com/2012/03/windows-thin-pc-vmware-view-5-0/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 10:52:35 +0000</pubDate>
		<dc:creator>Sohrab Kasraeian Fard</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[ESXi 5.0]]></category>
		<category><![CDATA[ThinPC]]></category>
		<category><![CDATA[View 5.0]]></category>
		<category><![CDATA[View 5.0.1]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware View]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[Windows Thin PC]]></category>
		<category><![CDATA[Windows TPC]]></category>

		<guid isPermaLink="false">http://www.kasraeian.com/?p=1839</guid>
		<description><![CDATA[Few days back, during my search on the net I came across &#8220;Microsoft Windows Thin PC&#8221; which I just heard of few months back. In that time as I wasn&#8217;t evolve in VDI project, I didn&#8217;t take it so serious and moved on but now it&#8217;s something may help VDI project and users. Well, moving to the point, &#8220;Windows [...]]]></description>
			<content:encoded><![CDATA[<p>Few days back, during my search on the net I came across &#8220;Microsoft Windows Thin PC&#8221; which I just heard of few months back.<br />
In that time as I wasn&#8217;t evolve in VDI project, I didn&#8217;t take it so serious and moved on but now it&#8217;s something may help VDI project and users.<br />
Well, moving to the point, &#8220;<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.microsoft.com/en-us/windows/enterprise/products-and-technologies/virtualization/thinpc.aspx.png')" onmouseout="removepreview()" href="http://www.microsoft.com/en-us/windows/enterprise/products-and-technologies/virtualization/thinpc.aspx" target="_blank">Windows Thin PC</a>&#8221; (aka &#8220;Windows TPC&#8221;) is the smaller version of &#8220;Windows 7&#8243; with almost all useful functionality of full version and include &#8220;BitLocker, AppLocker and DirectAccess&#8221; which consume less memory and CPU resources and it can lead to better consolidation (More vDesktop/Host).  <img src='http://www.kasraeian.com/wp-includes/images/blank.gif' alt=':wink:' class='wp-smiley smiley-20' /> </p>
<p>Although it&#8217;s not mentioned in none of &#8220;VMware View 5.0&#8243; documents and it means there might be no support on it for using alongside VDI, I tested it&#8217;s usage with &#8220;VMware View 5.0&#8243; and &#8220;VMware View 5.0.1&#8243; and it&#8217;s work fine with both of them.</p>
<p>Installation of this OS is same as Windows 7 with little difference on its background on some steps.  <img src='http://www.kasraeian.com/wp-includes/images/blank.gif' alt=':wink:' class='wp-smiley smiley-20' /> </p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-001.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-001.jpg"><img class="alignnone size-medium wp-image-1842" title="P4-07-001" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-001-600x524.jpg" alt="" width="600" height="524" /></a></p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-002.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-002.jpg"><img class="alignnone size-medium wp-image-1842" title="P4-07-002" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-002-600x524.jpg" alt="" width="600" height="524" /></a></p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-003.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-003.jpg"><img class="alignnone size-medium wp-image-1855" title="P4-07-003" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-003-600x464.jpg" alt="" width="600" height="464" /><span id="more-1839"></span></a></p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-004.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-004.jpg"><img class="alignnone size-medium wp-image-1842" title="P4-07-004" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-004-600x524.jpg" alt="" width="600" height="524" /></a></p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-005.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-005.jpg"><img class="alignnone size-medium wp-image-1842" title="P4-07-005" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-005-600x524.jpg" alt="" width="600" height="524" /></a></p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-006.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-006.jpg"><img class="alignnone size-medium wp-image-1842" title="P4-07-006" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-006-600x524.jpg" alt="" width="600" height="524" /></a></p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-007.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-007.jpg"><img class="alignnone size-medium wp-image-1842" title="P4-07-007" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-007-600x524.jpg" alt="" width="600" height="524" /></a></p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-008.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-008.jpg"><img class="alignnone size-medium wp-image-1842" title="P4-07-008" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-008-600x524.jpg" alt="" width="600" height="524" /></a></p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-009.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-009.jpg"><img class="alignnone size-medium wp-image-1842" title="P4-07-009" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-009-600x524.jpg" alt="" width="600" height="524" /></a></p>
<p>Checking system base configuration:</p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-010.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-010.jpg"><img class="alignnone size-medium wp-image-1856" title="P4-07-010" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-010-600x352.jpg" alt="" width="600" height="352" /></a></p>
<p>And now, connecting to it using &#8220;VMware View Client on Windows&#8221;</p>
<p><a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.kasraeian.com/wp-content/uploads/2012/03/P4-07-011.jpg.png')" onmouseout="removepreview()" href="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-011.jpg"><img class="alignnone size-medium wp-image-1857" title="P4-07-011" src="http://www.kasraeian.com/wp-content/uploads/2012/03/P4-07-011-600x375.jpg" alt="" width="600" height="375" /></a></p>
<p>More information about &#8220;Windows TPC&#8221; can be found below:<br />
<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.anandtech.com/show/4281/windows-thin-pc-windows-slimmed-down.png')" onmouseout="removepreview()" href="http://www.anandtech.com/show/4281/windows-thin-pc-windows-slimmed-down" target="_blank">AnandTech</a><br />
<a onclick="removepreview()" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.microsoft.com/licensing/software-assurance/windows-thin-pc.aspx.png')" onmouseout="removepreview()" href="http://www.microsoft.com/licensing/software-assurance/windows-thin-pc.aspx" onmouseover="drawpreview('http://www.kasraeian.com/wp-content/plugins/tooltip/images/www.microsoft.com/licensing/software-assurance/windows-thin-pc.aspx.png')" onmouseout="removepreview()" onclick="removepreview()" target="_blank">Microsoft Licensing </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kasraeian.com/2012/03/windows-thin-pc-vmware-view-5-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

