Hi,
How to retrieve the current host standard deviation value and the status(loadbalanced for example) from the cluster using powercli?
Hi,
How to retrieve the current host standard deviation value and the status(loadbalanced for example) from the cluster using powercli?
Hi all,
I am calling a Guest OS customization spec in my PowerCLi script that I am using to automate the deploy of VM's. The script executes and 10 minutes later there is a machine on the domain with all our internal customization. This takes around 10 minutes to complete, which is great, but I noticed that the Guest OS customization takes around 4 minutes to start applying after the VM has been deployed from template. Has anyone else encountered this and is there a way to accelerate\te the initiation of the OS customization?
Running vSphere 5.5 Ent Plus.
ESXi 5.5.0 3116895
PowerCLi 5.5 Release 2
Thanks,
Ramsey.
Hello,
I've been up and down the internet and cannot seem to find an answer to this.
I'm trying to script output to include a Guest VM's IP address and its Subnet Mask. I cannot seem to find any command that will present it without having to provide an account to the VM (Get-VMGuestNetworkInterface). Isn't VMtools aware of the IPaddress and netmask? Maybe this is so simple I'm overlooking something.
I'm looking for something like this: Get-Cluster "<cluster>" | Get-VM | Select Name, {$_.Guest.IPAddress}, {$_.ExtensionData.Summary.Guest.Subnet}
Obviously "Guest.Subnet" isn't a valid parameter, but is there something that would work in its place?
Thanks in advance!
Hi,
Can somebody provide me PowerCLI script on how to add 'CpuTotalMhz' together of all ESX Hosts in a cluster?
Hi all,
I'm getting this error when I try to connect with the Horizon Api :
Connect-HVServer : The request channel timed out while waiting for a reply
after 00:01:39.9989768. Increase the timeout value passed to the call to
Request or increase the SendTimeout value on the Binding. The time allotted to
this operation may have been a portion of a longer timeout.
At D:\ListadoVDD.ps1:53 char:1
+ Connect-HVServer -server myserver.fqdn.corp -User $vcAdmin
-Password $v ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : NotSpecified: (:) [Connect-HVServer], Exception
+ FullyQualifiedErrorId : System.Exception,VMware.VimAutomation.HorizonVie
w.Commands.Cmdlets.ConnectHVServer
Any ideas?
Thank you very much.
I created a Two text Files manually
one Text File has the following information
Usage
"10"
"20"
"30"
"40"
Can somebody provide me Power CLI script to get the input from that file, add all the four number and provide the total?
Second Text File has the following information
Total
"50"
"60"
"70"
"80"
Again need a script to get the input from that file, add all the four number and provide the total value?
Then Finally the output of the following
<<Total value of the First Text File>> / <<Total value of the Second Text File>> * 100
Eg: (100 / 260 ) * 100
Ans = 38.46%
HI,
Can some body provide me PowerCLI Script to find out Average CPU and Memory Utilization percentage for an ESX Cluster (Containing multiple ESX Hosts)?
Note : Require Average CPU and memory Utilization for multiple ESX Hosts together in a Cluster.
This annoying problem seems to have started after I reinstalled PowerCLI from the powershell gallery (via install-module) vs the installer they used to use. Every time I type in connect-viserver server name, it seems to try to connect, then stops. Powershell prompt is also frozen, I can't even move the window let alone close it. Need to use task manager to kill powershell.exe. I don't have anything being loaded from my _profile.ps1 file. I've made sure no other installs of PowerCLI show up in Uninstall Programs. And try deleting the modules from C:\Program Files\WindowsPowerShell\Modules and then reinstalling 6.5.1 via install-module -name VMware.PowerCLI. I'm connecting to a 6.5 vCenter instance as well. I'm out of ideas.
Has anyone had this problem or can help?
Thanks.
Hello Experts,
Is there a powercli cmdlet that one can use to interrogate BIOS settings, not BIOS version. I would like to audit our ESXI hosts BIOS settings in an easy way instead of logging into every host and interrogating the BIOS setting using the conrep tool/script. Neither get-view nor get-vmhosthardware seem to do the job. Below is an example list of BIOS settings that i would like to audit. Our HW is based on the HPE BL460c. The other option would be to use get-esxcli cmdlet or invoke-vmscript but i'm afraid this will be too complex and just wondering if there is an easier way to do it. Your help is appreciated. Thanks
HP_Power_Profile |
Memory_Power_Savings_Mode |
Thermal_Configuration |
SR-IOV |
HP_Power_Regulartor |
Dynamic_Power_Capping_Functionality |
Energy_Performance_Bias |
Intel_QPI_Link_Power_Management |
Intel_Minimum_Processor_Idle_Power_State |
Intel_Minimum_Processor_Idle_Power_Package_State |
Intel_DIMM_Voltage_Preference |
Cannot seem to make this work. Any suggestions?
In the examples of new-harddisk for 6.5 r1 this is what is provided:
-------------- Example 6 --------------
New-HardDisk -VM $vm -VDisk $vDisk
Attaches the $vDisk VDisk object to the $vm virtual machine.
-----------------------------------------
This is the result when Ii attempt to use this command against a 6.5 lab setup from William Lam. I even tried specifying a controller and it doesn't matter.
PowerCLI C:\> $controller
Type BusSharingMode UnitNumber
---- -------------- ----------
ParaVirtual NoSharing 3
PowerCLI C:\> $vm
Name PowerState Num CPUs MemoryGB
---- ---------- -------- --------
TestVM PoweredOff 1 2.000
PowerCLI C:\> $vdisk
Name Disk Type CapacityGB Filename
---- --------- ---------- --------
TestVolume Flat 1.000 ...056898496/a90a82eeb49c40218fc27ad3ece92109.vmdk
PowerCLI C:\> New-HardDisk -Controller $controller -vdisk $vdisk -vm $vm
WARNING: Parameter 'VM' is obsolete. Passing multiple values to this parameter is obsolete.
New-HardDisk : 11/25/2016 3:48:36 PM New-HardDisk Device requires a controller.
At line:1 char:1
+ New-HardDisk -Controller $controller -vdisk $vdisk -vm $vm
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-HardDisk], MissingController
+ FullyQualifiedErrorId : Client20_VirtualDeviceServiceImpl_AttachHardDisk_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDev
ice.NewHardDisk
$config_init ='
$rloc = "C:\Program Files\Path\Path2\"
Set-Location $rloc
.\app.exe
proprietary app.exe command #1
proprietary app.exe command #2
proprietary app.exe command #3
proprietary app.exe command #4
'
Invoke-VMScript -ScriptText $config_init -VM MyvM -GuestUser Administrator -GuestPassword Password
Also tried setting the location and running the app all in one like:
& "C:\Program Files\Path\Path2\app.exe"
Both return errors.
Any assistance would be great
Thank you
Hello Team,
I am preparing a PowerCLI Script when I can given manual Input and combine the output of two commands. The requirement is:
For selected VMs
- Powered ON / OFF .
- UUID of these VM's .
- Esx Host Names of which these VM's belong to .
- UUID Of ESX Host .
I have prepared as-->
# Prompt for VC
$vCenter = Read-Host "Enter vCenter Name or IP"
Connect-VIServer $vCenter
$CSVFilepath = "C:\Test.csv"
$VM = Read-Host "Enter VM Name"
Get-VM $VM |select name, PowerState, @{n="VMUUID";e={(Get-View $_.Id).config.uuid}} | out-file -FilePath $CSVFilepath -append
Get-VM $VM |Get-VMHost | Select Name,@{n="HostUUID";e={$_.ExtensionData.hardware.systeminfo.uuid}} | out-file -FilePath $CSVFilepath -append
Q1 - Script should ask to enter the VM name again and again.
Q2 - Combine the output in single CSV file with different data in separate columns.
Pls help, as I m not able to create foreach and combine the output.
Rgds
-Harjit
Hi,
maybe someone has suggestions to optimize my code for summarizing information relating a special VIPrivilege regarding VMSA-2017-0012 / CVE-2017-4919.
#
#Title: VMSA-2017-0012-export.ps1
#
#Description: This scripts exports VIPermission items related to its role and entity. It #shows all VIPermissions including the "VirtualMachine.Interact.GuestControl“-VIPrivilege #which needs to be managed in accordance to the VMSA-2017-0012 / CVE-2012-4919 issue.
#
#Date: 07/27/2017
#
#Creator: Mathias Raab
#
#Instructions: This script needs to be run AFTER establishing a connection to the vCenter #server. The file path for the export document needs to be specified while running the #script.
#
#Caution: This script has been tested. But I give no guarantee it is working for your #environment. Have a test first and if needed edit it for your own best.
#
#Removing variables first
Remove-Variable a,ergebnis
$ergebnis = @()
foreach ($role in (Get-VIRole))
{
foreach ($priv in ($role | Get-VIPrivilege | where {$_.ExtensionData.PrivId -eq "VirtualMachine.Interact.GuestControl"}))
{
foreach ($viuser in (Get-VIPermission | where {$_.Role -eq $role.Name}))
{
$a = New-Object -TypeName PSObject
$a | Add-Member -MemberType NoteProperty -Name Role -Value $role.Name.tostring()
$a | Add-Member -MemberType NoteProperty -Name Privilege -Value $priv.Name.tostring()
$a | Add-Member -MemberType NoteProperty -Name Principal -Value $viuser.Principal.tostring()
$a | Add-Member -MemberType NoteProperty -Name Entity -Value $viuser.Entity
$ergebnis += $a
}
}
}
$ergebnis | Export-CSV -Path (Read-Host -Prompt „Enter full file path for the export:“) -NoTypeInformation -Delimiter ";"
Hello everyone!
After recent discussion on vSphere Capacity planning, I thought I would share one of the tools I use for this purpose. This is a side project I've been working on for few months.
I present to you, my very own "VMware Capacity & Performance Report PowerCLI script (v2.1 Community edition)"
(Click here then click on "Download")
This is a complex PowerCLI script I wrote, that generates an e-mail report that gives you insight into the current state of your VMware vSphere environment's capacity. It generates tables, pie charts and line charts with information about CPU, Memory & Storage capacity, VM Provisioning Potential, Cluster Resilience and more. Check the script's #INFORMATION block for more information about prerequisites, script input and output.
Have a look at the report it generates and let me know what you think of it!
Please share your thoughts and comments!
Marc Davoli
http://ca.linkedin.com/in/marcvincentdavoli/
Edited on May 25 : Changed OneDrive link to updated script v2.1 with bugfix (for cluster names with a space in it)
I need to find a VM Guest's last boot time. The machine running the PowerCli script and the VMGuest are on the same vCenter, but in isolated network segments. So I can't use Powershell to run Get-WmiObject or Get-CimInstance. And I would really prefer to avoid Invoke-VMscript. I haven't had much luck with it.
How can I get a VMGuest's last boot time by using PowerCli cmdlets?
Hello all,
I've got a question/problem.
At my workplace, we use VSphere/Vcenter Server to manage a few thousand VMs.
I've been working on a PowerShell script to collect resource utilization of VMs using `Get-Stat`
But I'm noticing that Get-Stat is causing a painful amount of delay for the script in general.
It takes about 20 seconds to run one instance of Get-Stat, and in my script, about 60 seconds create a table with what I've scripted.
Is there any alternative command to use to retrieve stats of a VM; or any way that I could speed up the process/better format my commands?
Please see the excerpt from my PS Module and measurements using `Measure-Command` below-
Thank you in advance!
Try{ Write-Host "Retreiving $NodeName information in VSphere..." Connect-VIServer -Server $VCenter -Credential $AmerSCreds -Force -wa 0 -ErrorAction Stop | Out-Null $GetStatCPU = Get-Stat -Entity $NodeName -Stat CPU.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop $GetStatMem = Get-Stat -Entity $NodeName -Stat Mem.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop $GetStatNet = Get-Stat -Entity $NodeName -Stat Net.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop Get-VM $NodeName | Select-Object Name,PowerState,NumCPU,MemoryGB,Folder,VMHost -ErrorAction Stop | Format-Table $VMInfoTable = $GetStatCPU | ForEach { $TempCPUTable = $_ $match = $GetStatMem | Where {$_.TimeStamp -eq $TempCPUTable.TimeStamp} | Select -Unique $match1 = $GetStatNet | Where {$_.TimeStamp -eq $TempCPUTable.TimeStamp} | Select -Unique "" | Select @{n="TimeStamp";e={$TempCPUTable.TimeStamp}}, @{n="CPU Use %";e={$TempCPUTable.Value}}, @{n="Memory %";e={$match.Value}}, @{n="Net Use kbps";e={$match1.Value}} } $VMInfoTable|Format-Table|Out-String|% {Write-Host $_} Disconnect-VIServer -Server $VCenter -Confirm:$False -ErrorAction Stop| Out-Null }
C:\Directory> measure-command {^I^I$GetStatCPU = Get-Stat -Entity $NodeName -Stat CPU.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop>> ^I^I$GetStatMem = Get-Stat -Entity $NodeName -Stat Mem.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop>> ^I^I$GetStatNet = Get-Stat -Entity $NodeName -Stat Net.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop>> ^I^IGet-VM $NodeName | Select-Object Name,PowerState,NumCPU,MemoryGB,Folder,VMHost -ErrorAction Stop | Format-Table>> ^I^I$VMInfoTable = $GetStatCPU | ForEach {>> ^I^I^I$TempCPUTable = $_>> ^I^I^I$match = $GetStatMem | Where {$_.TimeStamp -eq $TempCPUTable.TimeStamp} | Select -Unique>> ^I^I^I$match1 = $GetStatNet | Where {$_.TimeStamp -eq $TempCPUTable.TimeStamp} | Select -Unique>> ^I^I^I"" | Select @{n="TimeStamp";e={$TempCPUTable.TimeStamp}}, @{n="CPU Use %";e={$TempCPUTable.Value}}, @{n="Memory %";e={$match.Value}}, @{n="Net Use kbps";e={$match1.Value}}>> ^I^I^I}>> ^I^I$VMInfoTable|Format-Table|Out-String|% {Write-Host $_}} TimeStamp CPU Use % Memory % Net Use kbps --------- --------- -------- ------------ 2017-07-28 01:10:00 21.59 28.05 468 2017-07-28 01:05:00 12.79 20.72 207 2017-07-28 01:00:00 13.85 21.19 278 2017-07-28 00:55:00 18.1 22.05 385 2017-07-28 00:50:00 18.57 25.85 400 2017-07-28 00:45:00 14.7 38.25 233 2017-07-28 00:40:00 12.24 80.39 204 2017-07-28 00:35:00 83.74 33.05 55 Days : 0 Hours : 0 Minutes : 1 Seconds : 7 Milliseconds : 394 Ticks : 673940985 TotalDays : 0.000780024288194444 TotalHours : 0.0187205829166667 TotalMinutes : 1.123234975 TotalSeconds : 67.3940985 TotalMilliseconds : 67394.0985 C:\Directory> measure-command {^I^I$GetStatCPU = Get-Stat -Entity $NodeName -Stat CPU.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop>> ^I^I$GetStatMem = Get-Stat -Entity $NodeName -Stat Mem.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop>> ^I^I$GetStatNet = Get-Stat -Entity $NodeName -Stat Net.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop>> ^I^IGet-VM $NodeName | Select-Object Name,PowerState,NumCPU,MemoryGB,Folder,VMHost -ErrorAction Stop | Format-Table>> ^I^I$VMInfoTable = $GetStatCPU | ForEach {>> ^I^I^I$TempCPUTable = $_>> ^I^I^I$match = $GetStatMem | Where {$_.TimeStamp -eq $TempCPUTable.TimeStamp} | Select -Unique>> ^I^I^I$match1 = $GetStatNet | Where {$_.TimeStamp -eq $TempCPUTable.TimeStamp} | Select -Unique>> ^I^I^I"" | Select @{n="TimeStamp";e={$TempCPUTable.TimeStamp}}, @{n="CPU Use %";e={$TempCPUTable.Value}}, @{n="Memory %";e={$match.Value}}, @{n="Net Use kbps";e={$match1.Value}}>> ^I^I^I}>> ^I^I$VMInfoTable|Format-Table|Out-String|% {Write-Host $_}} TimeStamp CPU Use % Memory % Net Use kbps --------- --------- -------- ------------ 2017-07-28 01:10:00 21.59 28.05 468 2017-07-28 01:05:00 12.79 20.72 207 2017-07-28 01:00:00 13.85 21.19 278 2017-07-28 00:55:00 18.1 22.05 385 2017-07-28 00:50:00 18.57 25.85 400 2017-07-28 00:45:00 14.7 38.25 233 2017-07-28 00:40:00 12.24 80.39 204 2017-07-28 00:35:00 83.74 33.05 55 Days : 0 Hours : 0 Minutes : 1 Seconds : 5 Milliseconds : 509 Ticks : 655098115 TotalDays : 0.00075821541087963 TotalHours : 0.0181971698611111 TotalMinutes : 1.09183019166667 TotalSeconds : 65.5098115 TotalMilliseconds : 65509.8115 C:\Directory> measure-command {Get-Stat -Entity $NodeName -Stat CPU.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop} Days : 0 Hours : 0 Minutes : 0 Seconds : 19 Milliseconds : 514 Ticks : 195141443 TotalDays : 0.00022585815162037 TotalHours : 0.00542059563888889 TotalMinutes : 0.325235738333333 TotalSeconds : 19.5141443 TotalMilliseconds : 19514.1443 C:\Directory> measure-command {Get-Stat -Entity $NodeName -Stat CPU.Usage.Average -IntervalMins 10 -MaxSamples 8 -ErrorAction Stop} Days : 0 Hours : 0 Minutes : 0 Seconds : 18 Milliseconds : 527 Ticks : 185270404 TotalDays : 0.000214433337962963 TotalHours : 0.00514640011111111 TotalMinutes : 0.308784006666667 TotalSeconds : 18.5270404 TotalMilliseconds : 18527.0404 C:\Directory>
Hello all,
In the past months we managed to upgrade our infrastructure from 5.1 to 6.0 (that was a real pain to accomplish on such big environment). Now, we have this little annoyance with one of the scripts we were using. In order to pull out HBA Lun Path status, we used an script which counted the amount of Active, Death and standby paths. While the script it self works, hence the commands are fine, it is showing all paths as stand by. So, I thought it was an issue with the script, yet when I run it as a single line I still get same results. Any ideas why after upgrading command is showing different results?
Here is the single line and its output (obviously changing host name for security reasons) for some of the paths:
PowerCLI E:\Scripts> get-vmhost host01 | Get-VMHostHba -Type "FibreChannel" | Get-ScsiLun | Get-ScsiLunPath | select name, scsilun, state
Name ScsiLun State
---- ------- -----
vmhba5:C0:T3:L3,fc.20000024ff2f0305:21000024ff2f0305-f... naa.6005076801808631e000000000000363 Standby
vmhba5:C0:T2:L3,fc.20000024ff2f0305:21000024ff2f0305-f... naa.6005076801808631e000000000000363 Standby
vmhba64:C0:T3:L3,fc.20000024ff2f02d8:21000024ff2f02d8-... naa.6005076801808631e000000000000363 Standby
vmhba64:C0:T2:L3,fc.20000024ff2f02d8:21000024ff2f02d8-... naa.6005076801808631e000000000000363 Standby
vmhba64:C0:T0:L3,fc.20000024ff2f02d8:21000024ff2f02d8-... naa.60050768018106341800000000000358 Standby
vmhba5:C0:T1:L3,fc.20000024ff2f0305:21000024ff2f0305-f... naa.60050768018106341800000000000358 Standby
vmhba5:C0:T0:L3,fc.20000024ff2f0305:21000024ff2f0305-f... naa.60050768018106341800000000000358 Standby
vmhba64:C0:T1:L3,fc.20000024ff2f02d8:21000024ff2f02d8-... naa.60050768018106341800000000000358 Standby
Here is the script output for same server:
VMHost | HBA | Active Dead Standby |
------ | --- | ------ ---- ------- |
host01 vmhba64 0 | 0 | 72 |
host01 vmhba4 0 | 0 | 56 |
host01 vmhba65 0 | 0 | 56 |
host01 vmhba5 0 | 0 | 72 |
So this one is interesting...
I have a self-service portal which I built for users to pull metrics from vRops, It runs on W2K12, C# / ASP.net and executes a PowerShell script which goes off and talks to the vRops API and vCenter for Event history...
The portal has been working just fine using PowerCLI 6.3 R1, I recently upgraded to PowerCLI 6.5.1 and had customers complain that the Events where no longer showing up in the report... When I execute the script via PowerShell manually or with a Scheduled task it works just fine and events are imported... but when the ASP page runs the script it fails!
So after lots of playing around I discovered that Import-Module appears not to work correctly when executed by my webpage... where as Add-PSSnapin still works just fine. The portal runs as a Domain User which is also an administrator of the server...
I suspect it's permission related as I found this post that sounded like a similar issue...
Has anyone else experienced this before?
Connect-VIServer : The 'Connect-VIServer' command was found in the module 'VMware.VimAutomation.Core', but the module could not be loaded. For more information, run 'Import-Module VMware.VimAutomation.Core'.
At E:\vRops\vRopsScript.ps1:506 char:1
+ Connect-VIServer -server $VC -User $vRopsUser -Password $vRopsPasswor ...
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-VIServer:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Could not load file or assembly 'file:///E:\vROPS\Modules\VMware.VimAutomation.Common\6.5.1.5335010\Common.Logging.dll' or one of its dependencies. The system cannot find the file specified.
Import-Module : Could not load file or assembly
'file:///E:\vROPS\Modules\VMware.VimAutomation.Common\6.5.1.5335010\Common.Logging.dll' or one of its dependencies. The system cannot find the file specified.
At E:\vRops\vRopsScript.ps1:501 char:1
+ Import-Module VMware.VimAutomation.Core -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
Could not load file or assembly 'file:///E:\vROPS\Modules\VMware.VimAutomation.Common\6.5.1.5335010\Common.Logging.dll' or one of its dependencies. The system cannot find the file specified.
How do you call another Script and execute that?
I have with me two .ps1 files. script1.ps1 and script2.ps1
From script1.ps1, I want to call script2.ps1 and execute the script.
Hello,
I need to update all of the VM Notes (about 300 VMs), and I have the info in a CSV file, two columns are in the file, one for VM name, the other for the Note, no column heads in present.