Hay Guys,
I would need a script which can pull out the RAM DISK partition size info for multiple ESXi 6.0. Please let me know if anyone having any idea to accomplish this.
Hay Guys,
I would need a script which can pull out the RAM DISK partition size info for multiple ESXi 6.0. Please let me know if anyone having any idea to accomplish this.
Hi
I have a SAN storage BOX connected with a Blade chassis SAN switch. I configured Powercli and getting details of VMs and all LUN connected on each VMware host. I want to get a list which LUN is hosting which VM. I have huge number of LUNs configured and I donot have any option rather than browsing the LUN to see what VMs are there on that LUN. So is there a command that will give me details what are VM hosted on a particular LUN.
Thanks
Amit
I have 13 ESXi hosts across multiple domains and security boundaries and therefore can only access each ESXi host individually.
Initially all 13 ESXi hosts should have been built to a uniform baseline. Subsequent to the baseline build completion, specific domain and site specific configuration changes are made although these are high level and minimal (IP address FQDN etc.)
Troubleshooting a couple of recent issues has highlighted discrepancies on a number of host's baseline build configurations which has resulted in the requirement to compare each and every ESXi host's configuration.
I looking to run a VMware PowerCLI command on each host and have the output exported to a .CSV file so that I can then complete a QA check on the each hosts baseline build configuration against the baseline build document. I want to output to a CSV file the entire ESXi host configuration which needs to includes the details displayed in both the Summary Tab and the Configuration Tab of the selected ESXI host within the vSphere Client (i.e.:- Hardware-Processors, Memory, Storage etc. , Software- License, Time, DNS, Routing etc., General, Resources, Storage, Network, Fault Tolerance etc.)
I believe the correct cmdlet is Get-VMHostAdvanceConfiguration?
I can run this command successfully with the output to the screen however when I then try to export the same content to a .csv file it fails.
Any help or advice would be greatly appreciated. I have spend some considerable time searching the web but have not found any answers specific to my requirement.
Hi I have a script that modifies the email address used by existing alarm definitions. It doesn't modify the alarmAction and alarmActionTrigger, just the email address
The script does this:
-Get the alarm definition
-Copies the existing alarmTriggerAction to a variable
-Deletes the current alarmAction
-Creates a new alarmAction
-Creates a new alarmActionTrigger using the properties of the deleted alarmAction
Works as it should, except that it is never able to set the properties for YELLOW-->RED on any alarm definition. Am I missing something?
Verified that the values I'm passing to the New-AlarmActionTrigger are the correct objectType. Even cast them manually to [InventoryItemStatus]
------------------------------------------------------------------------------------------------------------------------------
#$alarms = Get-AlarmDefinition | ? {($_ | Get-AlarmAction).ActionType -eq "SendEmail"}
$alarms | foreach {
$trigAction = ($_ | get-alarmAction).trigger
#$trigAction.repeat
#$_ | get-alarmAction | remove-alarmAction -Confirm:$FALSE
"Alarm Action: $($_ | get-alarmAction)"
"Alarm Action Trigger: $(($_ | get-alarmAction | get-alarmActionTrigger))"
$_ | New-AlarmAction -Email -To "myemail@mycompany.com" |
foreach {
sleep 2
$alarmAction = $_
$trigAction | foreach {
$keepgoing = $_.repeat
#$start = ([VMware.VimAutomation.ViCore.Types.V1.Inventory.InventoryItemStatus]($_.StartStatus))
#$end = ([VMware.VimAutomation.ViCore.Types.V1.Inventory.InventoryItemStatus]($_.EndStatus))
"StartStatus : $($_.startStatus)"
"StartStatus ObjectType: $(($_.startStatus).gettype().name)"
""
"EndStatus : $($_.EndStatus)"
"EndStatus ObjectType : $(($_.EndStatus).gettype().name)"
""
IF ($keepgoing)
{
New-AlarmActionTrigger -alarmAction $alarmAction -StartStatus $_.StartStatus -endStatus $_.EndStatus -Repeat -ErrorAction Continue
}
New-AlarmActionTrigger -alarmAction $alarmAction -StartStatus $_.StartStatus -endStatus $_.EndStatus -ErrorAction Continue
}
}
}
Thanks a lot!
Larry
any idea how to set the snmp engineid on a host?
$esxcli.system.snmp.set ?
PowerCLI 6.0 Release 3
VCSA 5.5.0.30100 Build 3154314
Command:
Get-Stat-Entity "cluster name" -start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples10000-statcpu.usage.average-IntervalMins120
Error:
I can run the same command with the entity being a VM host and that works fine. I can also run this command against another Windows vcenter and cluster and it works fine. Wondering what might be wrong with this vcenter/cluster. I have two clusters in this vcenter and they both get this error. Any ideas? Thanks.
Hi everyone,
i want to connect a usb drive via powecli or any command tool to a vm on my vcenter. it work thru the gui of the vmrc easy but i didnt found any solution thru command. I need that to automate a test with a product of my company.
Does Onyx give me maybe the answer?
Thanks in advance
Hi there,
I'm using Invoke-VMScript to have my guest OS install windows updates. That works fine.
After the Invoke-VMScript command is left, I'm calling Restart-VMGuest. Though, this returns "Shutdown VM guest." failed for VM "60TrustedTruste" for the following reason: A general system error occurred: Cannot execute scripts"
I have no idea how to track this issue down. Is there a log on the guest-side, I could check for more details?
Here are snippets of what I'm doing, in case it helps...
Perform windows updates in guest OS:
$script = { #Define update criteria. $Criteria = "IsInstalled=0 and Type='Software'"; #Search for relevant updates. $Searcher = New-Object -ComObject Microsoft.Update.Searcher; $SearchResult = $Searcher.Search($Criteria).Updates; #Download updates. $Session = New-Object -ComObject Microsoft.Update.Session; $Downloader = $Session.CreateUpdateDownloader(); $Downloader.Updates = $SearchResult; $Downloader.Download(); #Install updates. $Installer = New-Object -ComObject Microsoft.Update.Installer; $Installer.Updates = $SearchResult; #Result -> 2 = Succeeded, 3 = Succeeded with Errors, 4 = Failed, 5 = Aborted $Result = $Installer.Install(); return $Result; } Wait-Tools -VM $VM -TimeoutSeconds 600 Try { $result = Invoke-VMScript -VM $VM -ScriptText $script -GuestUser $GuestUser -GuestPassword $GuestPassword -ScriptType Powershell } Catch { Write-Log -EntryType Error -Message "Error invoking guest OS updates." -Exception $_.Exception }
Restart the guest OS
Wait-Tools -VM $VM -TimeoutSeconds 600 Restart-VMGuest -VM $VM -Confirm:$false do { Start-Sleep -Milliseconds 100 } until ((Get-VMGuest -VM $VM).State -eq "Running") Wait-Tools -VM $VM -TimeoutSeconds 600
I am looking for some assistance on how to enable guest customization for CIVM's at the VApp level. Currently I am using the $CIVM.ExtensionData.Section to enumerate guest customization settings and then using the .UpdateServerData() method to apply the settings. But this is run on each CIVM individually by cycling through the CIVapp. I have seen that there is a CustomizeAtNextPowerOn method in the extensiondata of the CIVApp but I am battling to figure out how to invoke this. I am looking for any assistance with this........
I am building a script to grab DNS A record > ping them all > if they do not ping write to a file > get-vm cmdlet > if they do not exists write to another file.
Below is the part that is not working. It is writing all the VM's to the file. Can someone help me get this to work. I have tried try catch loops as well and can not get it to work.
Connect-VIServer $vcenter-User$username-Password$password
$Exists=Import-CsvC:\tmp\test1.csv
$array= @()
foreach ($VMNamein$Exists){
$not=get-vm-name$VMName-ErrorActionSilentlyContinue
$writeme=$VMName
If ($not){
# Write"VM is there $VMName"
}
Else {
# Write"VM not there $VMName $writeme"
$array+=$writeme
}
}
$array | Export-Csvc:\tmp\test2.csv-NoTypeInformation-UseCulture
Disconnect-VIServer $vcenter-Confirm$false-Force
Does anyone have a script that will gather up all SRM information for me, I'm looking to query SRM and get at least the following:
Folder: Recovery Plan: Protection Group: VM: LUN: VM Priority: protected IP: Recovery IP:
Thanks in advance!
Hi all,
im trying to enable fault tolerance on some vms using powercli,
im using vsphere 6 and meet the req license.
I foung some stuff on the web but nothing seems to be working for me.
Hello,
I need to create weekly report for local accounts on ESXi 5.5 servers. All ESXi have a unique password which is stored in a secure database and there is not scripted way to access the password; ESXi lockdown mode is enabled also. What is the best way to generate ESXi local account list? All ESXi are managed by vCenter.
Thank you,
Asim
Hello,
I faced with the following problem some days ago: unable to get VM view by executing "get-view" cmdlet with filter containig "Name" property. This issue occurs only with VMs that managed by vCloud Director.
Everyone knows that vCD gives the name to VMs in vCenter like this: "VMName (<vCD_ID>)" - where <vCD_ID> is an identifier that can be expressed as this regex:"(\w|\d){8}[-]+((\w|\d){4}[-]+){3}(\w|\d){12}".
I tried to execute something like this: "Get-View -ViewType VirtualMachine -Filter @{"Name" = "<VMName> (<vCD_ID>)"}"
And like this: "Get-View -ViewType VirtualMachine -Filter @{"Name" = "^$($<VMName> (<vCD_ID>))$"}"
Cmdlet returns an empty response.
To my surprise if i try to execute: "Get-View -ViewType VirtualMachine -Filter @{"Name" = "<VMName>"}" - it responed VM view.
The problem is that <VMName> without identifier is not a unique name of vCD VM. So powercli can respond an array of VMS View objects.
Anyone else seeing similar issue?
Hi,
Could you suggest me some script to migrate Folders of a particular DC from one VC to another VC.
Thanks!
I am at a loss.
I have a PowerCLI script which fires on a "VM created event" in vCenter
The script runs a batch file which looks like
PowerShell.exe -file "C:\Scripts\alarms\VMcreated\scriptName.ps1" >> c:\temp\log.txt
scriptName.ps1 basically does
. "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
Connect-ViServer
I end up getting Connect-VI: Command does not exist.
I seems that the script is not loading the modules when running as the system account without a shell but does as the system user when in a shell.
I have run this manually as the nt authority\system user is a ps shell started by psexec and it works great.
If I put a Get-VICommand in there it works but has no commands available.
Any ideas why it wont work?
Using Windows 2012R2 for VCenter and Power CLI 6.3 U1
Script attached.
Dion
This has come about as I have to implement this on a new 6.0 vCenter server (as we had it setup on 5.5):
http://blogs.vmware.com/PowerCLI/2009/09/how-to-run-powercli-scripts-from-vcenter-alarms.html
hello
is there any possible to add single line to my script for VMtools build number? I am looking for Vmtools build number
LucD or any expert Please help
$allLines = @() # Line added
Get-VM |
ForEach-Object {
$VM = $_
$VMview = $VM | Get-View
$VMResourceConfiguration = $VM | Get-VMResourceConfiguration
$VMHardDisks = $VM | Get-HardDisk
$HardDisksSizesGB = @()
$Temp = $VMHardDisks | ForEach-Object { $HardDisksSizesGB += [Math]::Round($_.CapacityKB/1MB) }
$VmdkSizeGB = ""
$Temp = $HardDisksSizesGB | ForEach-Object { $VmdkSizeGB += "$_+" }
$VmdkSizeGB = $VmdkSizeGB.TrimEnd("+")
$TotalHardDisksSizeGB = 0
$Temp = $HardDisksSizesGB | ForEach-Object { $TotalHardDisksSizeGB += $_ }
$VMDKnames = @()
$Temp = $VMHardDisks | ForEach-Object { $VMDKnames += $_.Filename.Split("/")[1] }
$Snapshots = $VM | Get-Snapshot
$Report = "" | Select-Object VMname,GuestState,ToolsStatus,UsedSpaceGB,ProvisionedSpaceGB,Version,DNSname,ESXname,ClusterName,MemoryGB,vCPUcount,vNICcount,vNICType,
IPaddresses,VMXname,VMDKname,VmdkSizeGB,TotalVmdkSizeGB,DatastoreName,ToolsVersion,ToolsUpdate,NumCpuShares,
CpuLimitMHZ,CpuReservationMHZ,NumMemShares,ReservationsMB,LimitMB,SnapshotCount,GuestOS,VLANid,Portgroup,
RDMPath,GuestDisks,GuestDiskspaceGB,GuestDiskspaceUsedGB,GuestDiskspaceUsed,Folder
$Report.VMName = $VM.name
$Report.GuestState = $VM.guest.State
$Report.ToolsStatus = $VM.guest.extensiondata.toolsstatus
$Report.UsedSpaceGB = $VM.UsedSpaceGB
$Report.ProvisionedSpaceGB = $vm.ProvisionedSpaceGB
$Report.Version = $vm.ExtensionData.config.version
$Report.DNSNAME = $vm.Guest.ExtensionData.Hostname
$Report.ESXname = $VM.Host
$Report.ClusterName = ($VM | Get-Cluster).Name
$Report.MemoryGB = $VM.MemoryMB/1KB
$Report.vCPUcount = $VM.NumCpu
$Report.vNICcount = $VM.Guest.Nics.Count
$report.vNicType = [string]::Join(',',($vm.NetworkAdapters | %{$_.Type}))
$Report.IPaddresses = [string]::Join(',',$VM.Guest.IPAddress)
$Report.VMXname = $vm.Extensiondata.Config.Files.VmPathName.Split("/")[1]
$Report.VMDKname = [string]::Join(',',$VMDKnames)
$Report.VmdkSizeGB = $VmdkSizeGB
$Report.TotalVmdkSizeGB = $TotalHardDisksSizeGB
$Report.DatastoreName = [string]::Join(',',($vm.Extensiondata.Config.DatastoreUrl | %{$_.Name}))
$Report.ToolsVersion = $vm.guest.ExtensionData.ToolsVersion
$Report.ToolsUpdate = $vm.Extensiondata.Guest.ToolsStatus
$Report.NumCpuShares = $VMResourceConfiguration.NumCPUShares
$Report.CpuLimitMHZ = &{if($VMResourceConfiguration.CpuLimitMhz -eq -1){"No Limit"}else{$VMResourceConfiguration.CpuLimitMhz}}
$Report.CpuReservationMHZ = $VMResourceConfiguration.CpuReservationMhz
$Report.NumMemShares = $VMResourceConfiguration.NumMemShares
$Report.ReservationsMB = $VMResourceConfiguration.MemReservationMB
$Report.LimitMB = &{if($VMResourceConfiguration.MemLimitMB -eq -1){"No Limit"}else{$VMResourceConfiguration.MemLimitMB}}
$Report.SnapshotCount = (@($VM | Get-Snapshot)).Count
$Report.GuestOS = $VM.Guest.OSFullName
$Report.VLANid = [string]::Join(',',(Get-VirtualPortgroup -VM $vm | %{$_.VlanId}))
$Report.Portgroup = [string]::Join(',',(Get-VirtualPortgroup -VM $vm | %{$_.Name}))
$RDMPaths = $vm | Get-HardDisk | where {$_.DiskType -like "Raw*"}
$Report.RDMPath = &{if($RDMPaths){[string]::Join(',',($RDMPaths | %{$_.ScsiCanonicalName}))}else{"No RDM"} }
$Report.GuestDisks = [string]::Join(',',($VM.Guest.Disks | %{$_.Path}))
$Report.GuestDiskspaceGB = [string]::Join(',',($VM.Guest.Disks | %{"{0:f0}" -f ($_.Capacity/1GB)}))
$Report.GuestDiskspaceUsedGB = [string]::Join(',',($VM.Guest.Disks | %{"{0:f0}" -f (($_.Capacity - $_.FreeSpace)/1GB)}))
$Report.GuestDiskspaceUsed = [string]::Join(',',($VM.Guest.Disks | %{"{0:p0}" -f (($_.Capacity - $_.FreeSpace)/$_.Capacity)}))
$report.Folder = $VM | Select BlueFolderPath
$allLines += $Report # Line changed
}
$allLines | Export-Csv "GDCVMreport.csv" -NoTypeInformation -UseCulture
Hello,
VI Toolkit is avilable only for below OS ?
nstalling the VI Toolkit (f
or Windows) on Windows
You can install the VI Toolkit (for Windows) package
on the following 32-bit an
d 64-bit Windows platforms:
Windows Vista
Windows XP SP 2
Windows 2003 Server SP 2
===
Or does it included now in powercli 6x ?
thanks
Trying to get a list of all my VMs and whether they boot BIOS or EFI using PowerCLI 5.5 release 1. Doesn't seem to be in ExtensionData.Config.BootOptions like I'd expect and I'm having an awful time trying to track down where it might be. Must be somewhere, right? I'd be thrilled if anyone can point me to where this attribute is kept.
Thanks for any suggestions