Firstly - this is really a message to LucD (who I know from previous assistance tends to prowl this forum ) , just figured I'd share it, as it's all usefull info and any insight LucD has will no doubt be usefull for all.
Firstly - this is really a message to LucD (who I know from previous assistance tends to prowl this forum ) , just figured I'd share it, as it's all usefull info and any insight LucD has will no doubt be usefull for all.
Hi all,
Has anyone successfully automated the creation of the vMotion TCP/IP Stack on each host and then the creation of the vMotion VMK utilizing the newly created stack.
Regards
Cliff
I'm created a script and I'm having trouble getting the Powerstate it spits out nothing, if I take away Get-View I can get the powerstate.
Excuse my ignorance but I'm just starting to dive into powershell
get-cluster -Name <clustername> | Get-VM | Get-View | Select-Object @{Name="Hostname";e={$_.Name}}, @{Name="VMware Tools"; e={$_.Guest.ToolsStatus}}, @{Name="Powerstate";e={$_.PowerState}}
So I've managed to get 75% of what I'm looking to extract from vCenter and export it to a CSV file. I'm trying to get some more information which will help me maintain the vCenter environment I am working on. I guess the first problem I'll address is what is the best way to pull down the IPv4 address only? Right now I'm getting both IPv4 and IPv6. When I log into the vCenter server via PowerCli and then run this command:
Get-VM | Select Name, @{N="IP addr";E={[string]::Join(',',$_.Guest.IPAddress)}}, NumCpu, MemoryGB, Notes, PowerState | Export-Csv -path "c:\temp" -NoTypeInformation
I'm getting a CSV file with a number of data points, and it all looks good other than the IPv4 issue. I tried just adding Host or NetworkAdapters to the data points to get, but it didn't work. Am I going about this the wrong way, or is there a better way to get these data points?
Thanks!
I am having an odd experience with Get-VDPort. I am doing the following:
Get-VDSwitch | Get-VDPort -Uplink | where proxyhost -match "$($ESXHost.name)"
This is in a loop of many esx hosts.
This should produce all the uplinks in each vdswitch however I am missing uplinks. When i do this command on a specific vdswitch everything comes back as expected.
Anyone else experiencing this issue? or is this a known bug?
Hello,
I've been looking around for a script but I cant seem to find what i'm looking for. I would like something that would survey all VM's across all clusters and datastores (everything) And would generate a CSV report that show the IOPS usage per VM's.
I just want to be able to evaluate which VM's in particular are taxing our storage arrays.
Any help or pointers in the right direction would be appreciated.
Thanks!
Hello,
I am using Get-Stat cpu.usage.average and mem.usage.average to check VM usage. I am pulling info at 2 hr intervals.
It is my understanding that each of these measurements should be a maximum of 100 for each VM-host (summing % of each client). or in my case 500 as I have 5 identical VM-hosts.
But, as I sum each column I get 600-700 - hos is this possible?
Thanks-
Script:
$DaysBack = 14 #Number of days back to collect performance counters.
$PeakTimeStart = 8 #hour of the day in 24 hour format
$PeakTimeEnd = 20 #hour of the day in 24 hour format
$rdy_interval = 7200 #interval of rdy time values aggregation/averaging in seconds. This value should be changed according to your vcenter statistics settings.
#FUNCTIONS
function Connect-Vcenter {
param(
$vcenter
)
#Load snap-in
if (-not (Get-PSSnapin -Name VMware.VimAutomation.Core)) {
Add-PSSnapin VMware.VimAutomation.Core
}
#Connect to vCenter
if ($global:DefaultVIServers.Count -lt 1) {
Connect-VIServer $vcenter
}
}
function Get-VMCPUAverage {
param (
$VM
)
$Start = (get-date).AddDays(-$DaysBack)
$Finish = get-date
$stats = get-vm $VM | get-stat -MaxSamples "1000" -Start $Start -Finish $Finish -Stat "cpu.usage.average" | `
? { ($_.TimeStamp).Hour -gt $PeakTimeStart -and ($_.TimeStamp).Hour -lt $PeakTimeEnd }
$aggr_stats = $stats | Measure-Object -Property Value -Average
$avg = $aggr_stats.Average
return $avg
}
function Get-VMCpuRDY {
param (
$VM
)
$Start = (get-date).AddDays(-$DaysBack)
$Finish = get-date
$stats = get-vm $VM | Get-Stat -MaxSamples "1000" -Start $Start -Finish $Finish -Stat Cpu.Ready.Summation | `
? { ($_.TimeStamp).Hour -gt $PeakTimeStart -and ($_.TimeStamp).Hour -lt $PeakTimeEnd -and $_.Instance -eq ""}
$aggr_stats = $stats | Measure-Object -Property Value -Average
$rdy = [Math]::Round(((($aggr_stats.Average)/1000)/$rdy_interval) * 100,1)
return $rdy
}
#SCRIPT MAIN
#clear
#Load the VMWare module and connect to vCenter
Connect-Vcenter -vcenter $vcenter
$AvgCPUValues = @() #Create array to hold the CPU usage and CPU ready values
Get-Cluster $ClusterName | Get-VM | ? {$_.PowerState -eq "PoweredOn"} | % { #loop through all powered on VMs in the cluster
$AvgCPUValue = "" | Select "VM","CpuAvg","CpuRdy" #create a custom object with these properties.
$AvgCPUValue.VM = $_.Name
$AvgCPUValue.CpuAvg = "{0:N2}" -f $(Get-VMCPUAverage -VM $_) #Get VM CPU usage and round to two decimals
$AvgCPUValue.CpuRdy = Get-VMCpuRDY -VM $_
$AvgCPUValues += $AvgCPUValue
}
$AvgCPUValues | Export-Csv $CSV -NoTypeInformation -Force
I'm connected to a vCenter server and this is what I see when checking the metrics I have available:
$aaa = Get-Stat -Entity SomeVM
#when running this I get an error saying metric counter 'disk.usage.average' doesn't exist
$aaa | group -property metricid
#I only see these metrics:
cpu.usage.average
cpu.usagemhz.average
mem.usage.average
net.usage.average
sys.uptime.latest
Hi guys
Please help to modify script below to export all user & group role, permission & propagation.
get-cluster | get-vmhost | where=object {$_.connectionstate -eq "Connected"} | get-vipermission | export-csv -path c:\output\vipermission.csv
thanks.
I've the issue with importing vm from vsphere into existing vapp in vcloud director (8.0)
the following message error when i use import-civapp ...
Import-CIVApp, the vSphere server with UUID ...... is not found on this cloud Instance.
And yet I am sure that the vCenter I use is good
Any Idea ?
Code:
Connect-VIserver .... Connect-CIServer ... $vm=Get-VM test Get-CIVapp $vappName | Import-CIVApp $vm
Do we have any script for checking Esxi System swap ?
How can a mandatory parameter be obsolete?
I am currently running the following search-cloud to get Org VDC Network.
$network = Search-Cloud -QueryType OrgVdcNetwork -Name 'my_network_name'
I then want to get the href of this object. But, this is not visible in the object returned:
PS C:\powershell\VCDProduction\GenericScripts> $a
Name : my_network_name
DefaultGateway : 192.168.1.254
Netmask : 255.255.255.0
Dns1 :
Dns2 :
DnsSuffix :
LinkType : 0
ConnectedTo : my_network_name
Vdc : urn:vcloud:vdc:ae96fdb6-b2df-4884-911f-c19e24953b4f
IsBusy : False
IsShared : True
VdcName : my_vdc_name
IsIpScopeInherited : True
Href :
Id : urn:vcloud:network:f55f6db0-e099-45d5-88eb-8192e00e9618
Type :
AnyAttr : {taskStatus, taskOperation, task, taskDetails}
Link :
Metadata :
PropertyList : {[Name, my_network_name], [DefaultGateway, 192.168.1.254],
[Netmask, 255.255.255.0], [Dns1, ]...}
Uid : /CIServer=custdccreator:system@x.x.x.x:443/CISearchResult=18de8709-af31-4c2a-90b7-4596c43457c2
/
Client : /CIServer=custdccreator:system@x.x.x.x:443/
So I am just having an issue finding where the previous tasks are stored
Get-task only does tasks in the recent pane, and get-vievent only seems to cover the Events portion of the Tasks/Events tab in vCenter.
I just can't find where that big list of Past tasks is located...
Any help would be aprpeciated...
Thanks!
Hi,
I apologise if this has been asked previously. I did a search and couldn't find anything.
I have a script that loops though a number of IP addresses and connects to each host one at a time to retrieve information (not all hosts belong to a vCenter)
I'm trying to get license details.
In the script I can do:
$lm = Get-View -Id 'LicenseManager-ha-license-manager'
I can then do
PowerCLI C:\PSScripts> $lm
Source :
SourceAvailable : False
Diagnostics :
FeatureInfo : {}
LicensedEdition :
Licenses : {VMware vSphere 5 Essentials}
LicenseAssignmentManager :
Evaluation : VMware.Vim.LicenseManagerEvaluationInfo
LinkedView :
MoRef : LicenseManager-ha-license-manager
Client : VMware.Vim.VimClientImpl
and
PowerCLI C:\PSScripts> $lm.Licenses
LicenseKey : JJ214-44LDN-6894D-0UE06-CTA45
EditionKey : esxExpress.vram
Name : VMware vSphere 5 Essentials
Total : 66
Used : 2
CostUnit : cpuPackage
Properties : {ProductName, ProductVersion, feature, feature...}
Labels :
DynamicType :
DynamicProperty :
But I can't do
$lm.Licenses.Name
I get no data back.
I can do:
PowerCLI C:\PSScripts> $lm.Licenses | select Name
Name
----
VMware vSphere 5 Essentials
but how do I then put "VMware vSphere 5 Essentials" into a variable?
I hope that makes sense?
Thanks
Joe
Has anyone been able to get powercli to run the esxcli command for unamp
esxcli storage vmfs unmap -l Datastore name -n unit
any example would be appreciated
I have a PowerCLI script which vMotions a set of VM's from one cluster to another, done asynchronously. Now I need to run a post check to confirm the vMotion tasks were successful. Using Get-Task, I can see the status of vMotion tasks change to "completed" and cross reference the Id back to the VM name. The main downside to Get-Task is the objects expire after 10 minutes. In my use case this really shouldn't be an issue as I'm vMotioning at most 15-20 VM's and the Get-Task history should contain all the information I need.
But I would prefer to not rely on that condition if possible. I was looking at Get-VIEvent as an alternative, but it appears the state object property is always locked in "queued" state even long after the job has completed. Is there way to get "completed" status from Get-VIEvent or another other cmdlets?
Does anyone have a PowerCLI script for pulling NIC driver levels form host(s)?
As you can see in the results PowerShell adds @{ signs. Is there way to remove that from the results and display the result just like the below.?
get-view -viewtype virtualmachin | Where-Object { $_.Name -like "*BKP"} | Select name |
ForEach-Object {
set-vm -VM $_.Name -Name "$_.name $($dateformat )" -Confirm:$false
}
Result = @{Name=abcd-BKP}.Name 22-03-2016
Expected result = abcd-BKP 22-03-2016
please advice
Thanks
Anoop