VicMware's Posts

Hi Is it part of vShield requirement to configure link aggregation on physical switch and LACP on vDS? Thanks
Hi It doesnt work Here is the error Get-VMHostNetworkAdapter : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or... See more...
Hi It doesnt work Here is the error Get-VMHostNetworkAdapter : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input. Get-VMHostNetworkAdapter : 2/05/2014 3:28:02 PM    Get-VMHostNetworkAdapter        VMHostNetworkAdapter with name ' $_.PortGroupName -eq "1234-abc-VMKernel" ' was not found using the specified filter(s).
Hi Whats the command to disable management traffic on the VMK portgroup? PowerCLI D:\test> get-vmhost abc | get-VMHostNetworkAdapter where { $_.PortGroupName -eq "1234-abc-VMKernel" } | Set-VMH... See more...
Hi Whats the command to disable management traffic on the VMK portgroup? PowerCLI D:\test> get-vmhost abc | get-VMHostNetworkAdapter where { $_.PortGroupName -eq "1234-abc-VMKernel" } | Set-VMHostNetworkAdapter -managementtrafficenabled $false
Sorry I didnt make it clear First thing I want to do: how do I check if the hard disk is a RDM? $vhdds = $vm | get-harddisk check each $vhdds if its a RDM Second thing I want to do: $vh... See more...
Sorry I didnt make it clear First thing I want to do: how do I check if the hard disk is a RDM? $vhdds = $vm | get-harddisk check each $vhdds if its a RDM Second thing I want to do: $vhdds = $vm | get-harddisk check each $vhdds has a snapshot or not
Hi How do I find out if a harddisk has snapshots and whether its a virtual or physical RDM? $vhdds = $vm | get-harddisk "find out each $vhdds has snapshots and whether its a virtual or physi... See more...
Hi How do I find out if a harddisk has snapshots and whether its a virtual or physical RDM? $vhdds = $vm | get-harddisk "find out each $vhdds has snapshots and whether its a virtual or physical RDM"
I need to get the version of the host, for example, 5.0.0. Any idea why this line doesnt work? $version = get-vmhost $vmhost | select $_.Version
Hi Is there a way of change statistics level using Powercli? and is it possible to set heartbeat datastores using Powercli?
Hi LucD, Here is the error message. I think this script was created by you last year.
Hi The following script move the virtual machines alarms from vCenter level to folder level. The script works with Powercli4.1 but not 5.1. It gives error message for the line $alarmMgr.CreateAl... See more...
Hi The following script move the virtual machines alarms from vCenter level to folder level. The script works with Powercli4.1 but not 5.1. It gives error message for the line $alarmMgr.CreateAlarm($destination.MoRef,$newAlarm) Any idea why it doesnt work?? Write-Host "Adding in VMware PowerCLI PowerShell Snapin......" Add-PSSnapin vmware.VimAutomation.core -ErrorAction SilentlyContinue $viserver = "localhost" Write-Host "Connecting to vCenter: " $viserver Connect-VIServer $viserver Write-Host "Collecting VM and Root Folder information...." Set-Variable -Name alarmLength -Value 80 -Option "constant" $from = Get-Folder -NoRecursion | Get-View $to1 = Get-Folder -Name "Customer VMs" | Get-View  #move alarms from vCenter level to Customer VMs folder level $to2 = Get-Folder -Name "Management VMs" | Get-View #move alarms from vCenter level to Management VMs folder level function Move-Alarm{ param($Alarm, $From, $To, [switch]$DeleteOriginal = $false, [switch]$VMAlarmsOnly = $false) $alarmObj = Get-View $Alarm $alarmMgr = Get-View AlarmManager $IsAVirtualMachine = $false $alarmObj.Info.Expression.Expression | % {   #$_.Type   if ($_.Type -eq "VirtualMachine") {    $IsAVirtualMachine = $true   } } if($VMAlarmsOnly){   if($IsAVirtualMachine) {    if($deleteOriginal){     $alarmObj.RemoveAlarm()    }    else{     $updateAlarm = New-Object VMware.Vim.AlarmSpec     $updateAlarm = $alarmObj.Info     $oldName = $alarmObj.Info.Name     $oldState = $alarmObj.Info.Enabled     $oldDescription = $alarmObj.Info.Description     $suffix = " (moved to " + ([string]($to | %{$_.Name + ","})).TrimEnd(",") + ")"     if(($oldName.Length + $suffix.Length) -gt $alarmLength){      $newName = $oldName.Substring(0, $alarmLength - $suffix.Length) + $suffix     }     else{      $newName = $oldName + $suffix     }     $updateAlarm.Name =  $newName     $updateAlarm.Enabled = $false     $updateAlarm.Description += ("`r`n    Original name: " + $oldName)     $updateAlarm.Expression.Expression | %{      if($_.GetType().Name -eq "EventAlarmExpression"){       $_.Status = $null       $needsChange = $true      }     }     $alarmObj.ReconfigureAlarm($updateAlarm)     $alarmObj.Info.Name = $oldName     $alarmObj.Info.Enabled = $oldState     $alarmObj.Info.Description = $oldDescription    }    $newAlarm = New-Object VMware.Vim.AlarmSpec    $newAlarm = $alarmObj.Info    $oldName = $alarmObj.Info.Name    $oldDescription = $alarmObj.Info.Description    foreach($destination in $To){     if($To.Count -gt 1){      $suffix = " (" + $destination.Name + ")"      if(($oldName.Length + $suffix.Length) -gt $alarmLength){       $newName = $oldName.Substring(0, $alarmLength - $suffix.Length) + $suffix      }      else{       $newName = $oldName + $suffix      }      $newAlarm.Name = $newName      $newAlarm.Description += ("`r`n    Original name: " + $oldName)     }     $newAlarm.Expression.Expression | %{      if($_.GetType().Name -eq "EventAlarmExpression"){       $_.Status = $null       $needsChange = $true      }     }     $alarmMgr.CreateAlarm($destination.MoRef,$newAlarm)     $newAlarm.Name = $oldName     $newAlarm.Description = $oldDescription    }   } } else {   if($deleteOriginal){    $alarmObj.RemoveAlarm()   }   else{    $updateAlarm = New-Object VMware.Vim.AlarmSpec    $updateAlarm = $alarmObj.Info    $oldName = $alarmObj.Info.Name    $oldState = $alarmObj.Info.Enabled    $oldDescription = $alarmObj.Info.Description    $suffix = " (moved to " + ([string]($to | %{$_.Name + ","})).TrimEnd(",") + ")"    if(($oldName.Length + $suffix.Length) -gt $alarmLength){     $newName = $oldName.Substring(0, $alarmLength - $suffix.Length) + $suffix    }    else{     $newName = $oldName + $suffix    }    $updateAlarm.Name =  $newName    $updateAlarm.Enabled = $false    $updateAlarm.Description += ("`r`n    Original name: " + $oldName)    $updateAlarm.Expression.Expression | %{     if($_.GetType().Name -eq "EventAlarmExpression"){      $_.Status = $null      $needsChange = $true     }    }    $alarmObj.ReconfigureAlarm($updateAlarm)    $alarmObj.Info.Name = $oldName    $alarmObj.Info.Enabled = $oldState    $alarmObj.Info.Description = $oldDescription   }   $newAlarm = New-Object VMware.Vim.AlarmSpec   $newAlarm = $alarmObj.Info   $oldName = $alarmObj.Info.Name   $oldDescription = $alarmObj.Info.Description   foreach($destination in $To){    if($To.Count -gt 1){     $suffix = " (" + $destination.Name + ")"     if(($oldName.Length + $suffix.Length) -gt $alarmLength){      $newName = $oldName.Substring(0, $alarmLength - $suffix.Length) + $suffix     }     else{      $newName = $oldName + $suffix     }     $newAlarm.Name = $newName     $newAlarm.Description += ("`r`n    Original name: " + $oldName)    }    $newAlarm.Expression.Expression | %{     if($_.GetType().Name -eq "EventAlarmExpression"){      $_.Status = $null      $needsChange = $true     }    }    $alarmMgr.CreateAlarm($destination.MoRef,$newAlarm)    $newAlarm.Name = $oldName    $newAlarm.Description = $oldDescription   } } } Write-Host "Parsing Alarms and moving VM Alarms (if you see errors it is likely that you have run this script twice and may been to clean up the alarms)......" Write-Host Write-Host "Note: There should be a listed for each alarm copied from root to each of the two folders, as an example if there are 4 Alarms (Type: Virtual Machine) in the root you should see 8 alarms listed." Write-Host $alarmMgr = Get-View AlarmManager $alarms = $alarmMgr.GetAlarm($from.MoRef) $alarms | % { Move-Alarm -Alarm $_ -From (Get-View $_) -To $to1,$to2 -DeleteOriginal:$false -VMAlarmsOnly:$true } Disconnect-VIServer -confirm:$false Write-Host "Hit any key to close window....." #Pause Screen $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Hi Is there a way to automate vmware-tools install using PowerCLI?
Hi LucD The spreadsheet is working but the wwn column is showing System.Object[], any idea why?
I have moved the export-csv but still getting the same output, not sure what's wrong.
Hi I wrote this script, it works perfectly but I cant output this script to a excel document. Anyone knows how to do that? $list = get-content -Path D:\vCenterList.txt #List of your vcenter... See more...
Hi I wrote this script, it works perfectly but I cant output this script to a excel document. Anyone knows how to do that? $list = get-content -Path D:\vCenterList.txt #List of your vcenter to retrieve storage wwn targets from $username =' '  #vCenter login name $Password =' '  #vCenter password $report = @() $row = "" | Select vc,path,cluster,wwn # foreach ($vc in $list) { if (($vc -eq 'vc01') -or ($vc -eq 'vc02')) {     Connect-VIserver $vc -user $username -password $password     write-host "Non-standalone hosts:" -foregroundcolor green     $clusters = get-cluster     foreach ($cluster in $clusters) {                 $path = @()         $parent = Get-View $cluster.ExtensionData.ResourcePool             While ($parent.parent){                  $parent = Get-View $parent.parent                 $path += $parent.Name             }             $path = "$path".split(" ")[1]             write-host "$vc"             write-host "$path"             $esxihost = get-cluster $cluster | Get-VMHost | select -first 1             $out = get-vmhost $esxihost | get-vmhosthba | get-scsilun | get-scsilunpath | Select -ExpandProperty SanID -unique -ErrorAction "SilentlyContinue"             write-host "$cluster"             write-host "$out"             write-host " "                         $row.vc = $vc             $row.path = $path             $row.cluster = $cluster             $row.wwn = $out             $report += $row     } #################### write-host "Standalone hosts:" -foregroundcolor green #TM hosts not in cluster $hostlist = Get-VMHost |where{$_.ExtensionData.Parent.Type -ne "ClusterComputeResource"} $path = @() foreach ($host1 in $hostlist) {     $out = get-vmhost $host1 | get-vmhosthba | get-scsilun | get-scsilunpath | Select -ExpandProperty SanID -unique -ErrorAction "SilentlyContinue"     $path = @($host1.Name)      $parent = Get-View $host1.ExtensionData.Parent       While ($parent.parent){         $parent = Get-View $parent.parent            if("Datacenters","host" -notcontains $parent.Name){             $path += $parent.Name            }      $path1 = "$path".split(" ")[1]         }     write-host "$vc"     write-host "$path1"     write-host "$host1"     write-host "$out"       write-host " "     $row.vc = $vc     $row.path = $path1     $row.cluster = $host1     $row.wwn = $out     $report += $row } Disconnect-VIServer * -Confirm:$False } else { Connect-VIserver $vc -user $username -password $password $clusters=get-cluster foreach ($cluster in $clusters) { $datacenter = get-datacenter write-host "$datacenter" $esxihost = get-cluster $cluster | Get-VMHost | select -first 1 $out = get-vmhost $esxihost | get-vmhosthba | get-scsilun | get-scsilunpath | Select -ExpandProperty SanID -unique -ErrorAction "SilentlyContinue" write-host "$cluster" write-host "$out" write-host " " $row.vc = $vc $row.path = $datacenter $row.cluster = $cluster $row.wwn = $out $report += $row Disconnect-VIServer * -Confirm:$False $report | Export-Csv ESXiStorageWWN.csv -NoTypeInformation -UseCulture }}} The powercli output: This is the excel output I am looking for
Hi I wrote a loop to retrieve vcenter name $a, cluster name $b and $c folder name in the environment. How do I display it in excel spreadsheet? Here is an example: $i =0 while ($i -neq 10)... See more...
Hi I wrote a loop to retrieve vcenter name $a, cluster name $b and $c folder name in the environment. How do I display it in excel spreadsheet? Here is an example: $i =0 while ($i -neq 10) { $a = $i+1 #display in first raw column 1 $b = $i+2 #display in first raw column 2 $c = $i+3 #display in first raw column 3 $i++ #Add $a, $b and $c to the row $i } The output I am expecting is 1 2 3 2 3 4 3 4 5 . . .
Hi How do I use powercli to set number of cores per socket to 2 from 1? Thanks
Hi 1. Whats the command to move a VM to a newly created blue folder? 2. See screenshot. Any idea why I am getting those errors?
Hi set-vm $vm -numCPU 2 set the number of CPU sockets. Is it possible using PowerCLI to set number of cores??
1. I need to remove all network cards of a VM, the problem is I dont know how many network cards this VM has. Does anyone know how to write a script for it? 2. New-NetworkAdapter -VM $vm -... See more...
1. I need to remove all network cards of a VM, the problem is I dont know how many network cards this VM has. Does anyone know how to write a script for it? 2. New-NetworkAdapter -VM $vm -NetworkName "VM Network" -WakeOnLan -StartConnected      Is WakeOnLan enabled by default if I add the network card manually from VI Client?
Hi I have a script to create a new hard disk for the VM How to modify my script to skip the the harddisk creation if the hardisk1 cell does not have a value(empty)! $harddisk1 = $Data.harddi... See more...
Hi I have a script to create a new hard disk for the VM How to modify my script to skip the the harddisk creation if the hardisk1 cell does not have a value(empty)! $harddisk1 = $Data.harddisk1 $DatastoreName1 = $Data.DatastoreName1 $Name | New-HardDisk -CapacityGB $harddisk1 -Datastore $DatastoreName1 -Persistence persistent
Hi Does anyone has a script that gives the host name with most CPU and memory resources available in the cluster? Regards Vickie