vmCalgary's Posts

Thanks LucD. The syntax works perfectly as you've written it, as none of the vms containing the string have been previously tagged. Your solution was far too obvious and I was making it harder than i... See more...
Thanks LucD. The syntax works perfectly as you've written it, as none of the vms containing the string have been previously tagged. Your solution was far too obvious and I was making it harder than it needed to be.
I want to get a listing of VMs where the name contains a particular string. For example purposes, the string is: red.ball.ad Once I get this listing, I want assign a tag (OVA) to them.   Thanks in... See more...
I want to get a listing of VMs where the name contains a particular string. For example purposes, the string is: red.ball.ad Once I get this listing, I want assign a tag (OVA) to them.   Thanks in advance for your help.
  I had to use: Get-VM | where{$_.Notes -match 'Created by: Unix Admin Name' } | Select Name, but the pointer in the right direction was what I needed. Thanks Luc.
I appreciate some assistance extracting a list of VMs that contain a particular string in the notes. The string I am looking for is: "Created by: Unix Admin Name" Help is appreciated.
vRealize 8.1. I used this video to build a super metric to get powered off duration for VMs. My intent is to use it to rid our environment of abandoned VMs (powered off 90+ days as per policy). It ... See more...
vRealize 8.1. I used this video to build a super metric to get powered off duration for VMs. My intent is to use it to rid our environment of abandoned VMs (powered off 90+ days as per policy). It works great and my metric is:   It gives me this type of information:   I want to have additional columns added to it, or a report built on it. For each powered off VM I want to know: Provisioned disk space utilized disk space datastore Operation System   I am not sure how to achieve this. Help appreciated.
I have a csv file listing template names. I want to verify they are templates before I run a process to convert to VM, storage vmotion, and convert back to a template (scripted). $TEMPLATES = (Get-C... See more...
I have a csv file listing template names. I want to verify they are templates before I run a process to convert to VM, storage vmotion, and convert back to a template (scripted). $TEMPLATES = (Get-Content "C:\Users\jm\Desktop\template2convert.csv") Foreach($TEMPLATE in $TEMPLATES) { # Validate Template (make sure it still exists) try{ Write-Host ("Validate template: '" + $TEMPLATE + "'") Get-Template $TEMPLATE  Write-Host -foregroundcolor "green" "Template: $TEMPLATE is valid" } catch{ Write-Host -foregroundcolor "red" "Template: $TEMPLATE is invalid" $valid = $false } I get the following. Ideally, I'd like to get: 1. The green font item on the screen. 2. Errors of template names to a txt file for me to deal with separately. I plan on integrating the list test to the following (feel free to offer tidier coding suggestions as always) so that we may retire a datastore: # Load PowerCLI cmdlets Add-PSSnapin TEMPLATEware.VimAutomation.Core -ErrorAction "SilentlyContinue" $TEMPLATES = (Get-Content "C:\Users\jm\Desktop\template2convert.csv") Foreach($TEMPLATE in $TEMPLATES) { Write-Host ("Start Template conversion for TEMPLATE '" + $TEMPLATE + "'") # Start conversion Write-Host (Get-Template $TEMPLATE) -ForegroundColor Blue Write-Host ("Set " + $TEMPLATE + " to VM") Set-Template -Template $TEMPLATE -ToVM Write-Host (Get-VM $TEMPLATE | select Name,@{E={$_.ExtensionData.Config.Files.VmPathName};L="VM Path"}) -ForegroundColor Blue $Cluster = Get-VM $TEMPLATE | Get-Cluster Write-Host $Cluster Write-Host (Get-VM $TEMPLATE| Move-VM -Datastore (Get-Cluster $Cluster| Get-Datastore st074no_templates_ds01)) Write-Host (Get-VM $TEMPLATE | select Name,@{E={$_.ExtensionData.Config.Files.VmPathName};L="VM Path"}) -ForegroundColor Green Get-VM $TEMPLATE | Set-VM -ToTemplate -Confirm:$False write-Host (Get-Template $TEMPLATE) -ForegroundColor Green Write-Host ("Template conversion for template '" + $TEMPLATE + "' finished. LOOK FOR ERRORS IN RED Font") -ForegroundColor Magenta }  
@LucD @depping  It turns out that our environment is currently not setup to have host profiles due to the inconsistencies between clusters. Instead, one of our team members has written standardized f... See more...
@LucD @depping  It turns out that our environment is currently not setup to have host profiles due to the inconsistencies between clusters. Instead, one of our team members has written standardized functions. This was a valuable exercise as I often wondered why we didn't have host profiles, and now I know.   Thanks as always.
Thank you Duncan and LucD. I'm not sure why our teams don't use host profiles. I'll ask the question to our team. Failing that I'll just script for the various variables.
(Get-EsxCli -VMHost 'esx001').system.settings.advanced.list($true) The above command is great, but I'd like to go one step further when adding a new virtual host to a cluster. How do I copy the adva... See more...
(Get-EsxCli -VMHost 'esx001').system.settings.advanced.list($true) The above command is great, but I'd like to go one step further when adding a new virtual host to a cluster. How do I copy the advanced system settings from one host to another? The process of setting them to our standard is tedious. Powercli has to be able to do something for me to ensure nothing is missed.  
Thank you LucD. This will help quite a bit in getting the teams who created the templates to clean them up. There are so many duplicates. With all you've taught me, I'll be able to produce quite a lo... See more...
Thank you LucD. This will help quite a bit in getting the teams who created the templates to clean them up. There are so many duplicates. With all you've taught me, I'll be able to produce quite a lovely report for them. Reclaim resources ... that's my life some days.
Get-Template -name template_OEL6.5 | Select Name, @{N="Host";E={(Get-VMhost -id $_.HostID).Name}} @{N="HD#";E={@($_.ExtensionData.Config.Hardware.Device | where{$_.GetType().Name -eq "VirtualDisk"... See more...
Get-Template -name template_OEL6.5 | Select Name, @{N="Host";E={(Get-VMhost -id $_.HostID).Name}} @{N="HD#";E={@($_.ExtensionData.Config.Hardware.Device | where{$_.GetType().Name -eq "VirtualDisk"}).Count}}, @{N="HD Size (GB)";E={[string]::Join(',',( $_.ExtensionData.Config.Hardware.Device | where{$_.GetType().Name -eq "VirtualDisk"} | %{$_.CapacityInKB} ))}} @{N='Datastore';E={(Get-View -Id $_.DatastoreIdList -Property Name).Name -join ','}}, @{N="vCPU";E={$_.ExtensionData.Config.Hardware.NumCPU}}, @{N="RAM (GB)";E={$_.ExtensionData.Config.Hardware.MemoryGB}}, @{N="Created";E={(Get-VIEvent -Entity $_ -maxsamples ([int]::MaxValue) | where {$_.GetType().Name -eq "TaskEvent" -and $_.Info.DescriptionId -eq "VirtualMachine.markAsTemplate"} | Sort-Object -Property CreatedTime | Select -First 1).CreatedTime}........   Super simple solution, I'm sure. I would like the HD size in GB, not KB. I get stuck when I need to do [math]. Be gentle, what I don't know, I do my best to learn.
PowerCLI C:\> Compare-Object -ReferenceObject $oldFiles -DifferenceObject $newFiles | Out-GridView -PassThru | Clip With out-gridview open, I selected CTRL-A (select all), then CTRL-C (copy), ok, an... See more...
PowerCLI C:\> Compare-Object -ReferenceObject $oldFiles -DifferenceObject $newFiles | Out-GridView -PassThru | Clip With out-gridview open, I selected CTRL-A (select all), then CTRL-C (copy), ok, and pasted into Excel. All good now. Thanks @LucD 
@LucDthis is great, however, the syntax as you had it scrolls the results on screen and I can't analyze the output.I also had to insert a Get-Cluster request before the get-datastore due to how our e... See more...
@LucDthis is great, however, the syntax as you had it scrolls the results on screen and I can't analyze the output.I also had to insert a Get-Cluster request before the get-datastore due to how our env is set up. I exported $oldFiles and $newFiles to csv and the csv files contained one column titled Length. $dsOldName = 'olddatastore' $dsNewName = 'newdatastore' $dsOld = Get-Cluster 'clusterName' | Get-Datastore -Name $dsOldName $dsNew = Get-Cluster 'clusterName' |Get-Datastore -Name $dsNewName New-PSDrive -Location $dsOld -Name OLD -PSProvider VimDatastore -Root '\' | Out-Null New-PSDrive -Location $dsNew -Name NEW -PSProvider VimDatastore -Root '\' | Out-Null $oldFiles = Get-ChildItem -Path OLD: -Recurse | Select -ExpandProperty DatastoreFullPath $newFiles = Get-ChildItem -Path NEW: -Recurse | Select -ExpandProperty DatastoreFullPath Remove-PSDrive -Name OLD -Confirm:$false Remove-PSDrive -Name NEW -Confirm:$false Compare-Object -ReferenceObject $oldFiles -DifferenceObject $newFiles The output looked similar to: [oldDatastore] ISOs/vmware/co/rhel-atomic-cloud-7.3.1-1.x86_64.vsphere.ova [oldDatastore ISOs/vmware/co/test.txt [oldDatastore] ISOs/vmware/6.5/Cisco/VMware-ESXi-6.5.0-9298722-Custom-Cisco-6.5.2.2-Bundle.zip [oldDatastore] ISOs/vmware/6.5/Cisco/VMW-ESX-6.5.0-nenic-1.0.29.0-offline_bundle-12982103.zip [oldDatastore] ISOs/vmware/6.5/Cisco/Vmware-ESXi-6.5.0-7967591-Custom-Cisco-6.5.1.3-Update1.zip [oldDatastore] ISOs/vmware/6.5/Cisco/VMW-ESX-6.5.0-nenic-1.0.33.0-offline_bundle-16182785.zip [oldDatastore] ISOs/vmware/6.5/Cisco/VMware_ESXi_6.5.0_13932383_Custom_Cisco_6.5.3.1_Bundle.zip [oldDatastore] template_rhel_7_6_20181220_vc010no_cgno/template_rhel_7_6_20181220_vc010no_cgno.vmsd [oldDatastore] template_rhel_7_6_20181220_vc010no_cgno/template_rhel_7_6_20181220_vc010no_cgno.vmxf [oldDatastore] template_rhel_7_6_20181220_vc010no_cgno/template_rhel_7_6_20181220_vc010no_cgno-214612ff.hlog [oldDatastore ISOs/netcracker/Netcracker-nc1.ova [oldDatastore ISOs/Davra/coreos_production_vmware_ova_10.ova Great information, just a question. In the way the data is presented, is ISOs most likely my folder name (I believe it is)? Also, when I see this go zipping by on screen does that mean that these particular files are on oldDatastore and not on newDatastore, similar to a unix sdiff suppress duplicate files? It has to do something with invoking out-grid-view but as always, Luc, I need a little coaching.
I have two datastores, datastore-old and datastore-new, mounted across my environment. I believe I've copied the files from datastore-old to datastore-new, however as a check I'd like to obtain two ... See more...
I have two datastores, datastore-old and datastore-new, mounted across my environment. I believe I've copied the files from datastore-old to datastore-new, however as a check I'd like to obtain two exports. One for datastore-old and the other for datastore-new with column headers: Datastore Folder  | Child FileName | Child File Size | Child File Modified Date| Child File Path I will then do a match in Excel to verify the contents of datastore-new matches datastore-old. How do I get this? My thanks in advance for assistance.
LucD​, I referenced your article on HA VM failover tracking to determine the EventTypeID and descriptions. Please see the attached file of event types on our systems.
Thank you for responding so quickly, LucD​. I know I can always count on you. Your suggestion references 'UnmountVmfsVolume' and the datastore in question was NFS 3. I swapped the string... See more...
Thank you for responding so quickly, LucD​. I know I can always count on you. Your suggestion references 'UnmountVmfsVolume' and the datastore in question was NFS 3. I swapped the string to read " $t = Get-VIEvent -Start $eventTime.AddMinutes(-5) -Finish $eventTime -MaxSamples ([int]::MaxValue) |         where{$_ -is [VMware.Vim.TaskEvent] -and $_.Info.Name -eq 'UnmountNfs3Volume -and $_.Host.Name -eq $esx}" That was a bad guess. I didn't get any results. 1. I'm guessing the VMware.Vim.TaskEvent and $_.Info.Name is different under NFS 3. Is it? 2. Why are you doing $start = (Get-Date).AddHours(-2)? What is the significance of .AddHours(-2)? This is the code I ran after your suggested code failed to produce results: $start = (Get-Date).AddHours(-2) $dsName = 'st29001_prd_ds05' Get-VIEvent -Start (Get-Date).AddHours(-1) -MaxSamples ([int]::MaxValue) | where{$_ -is [VMware.Vim.EventEx] -and                   $_.EventTypeId -eq 'esx.audit.vmfs.volume.umounted' -and                   $_.Arguments[0].Value -match "^\[$dsName,"} | Select CreatedTime,     @{N='UserName';E={         $eventTime = $_.CreatedTime         $esx = $_.Host.Name         $t = Get-VIEvent -Start $eventTime.AddMinutes(-5) -Finish $eventTime -MaxSamples ([int]::MaxValue) |         where{$_ -is [VMware.Vim.TaskEvent] -and $_.Info.Name -eq 'UnmountNfs3Volume -and $_.Host.Name -eq $esx}         $t.UserName     }},     @{N='Datastore';E={$_.Arguments[0].Value.Split(',')[0].TrimStart('[')}},     @{N='VMHost';E={$_.Host.Name}},     @{N='Cluster';E={$_.ComputeResource.Name}} Earlier today I unmounted a datastore that was not required to see what Get-VIEvent recorded. 9/4/2020 12:44:00 PM      Removed unconfigured datastore st004no_templates_ds1-q1 9/4/2020 12:44:00 PM      Removed datastore st004no_templates_ds1-q1 from vh1146nr.sjrb.ad in WP-NR The datastore above is also NFS 3. It's quite possible it was a month ago when someone unmounted this datastore.
I am looking for assistance in determining who unmounted a datastore and when they did so. The unmounted datastore is generating a backup failure and I'd like to approach them to find out if the ... See more...
I am looking for assistance in determining who unmounted a datastore and when they did so. The unmounted datastore is generating a backup failure and I'd like to approach them to find out if the storage device is going away as well. Get-VIEvent or Get-VIEventPlus are likely the tools I'm to work with, but I'm not clear on how to get the exact data I'm looking for. For argument sake, let's call the datastore st290001no_prd_ds05. It would be nice to identify what cluster or esxi hosts the datastore was deleted from.
Am I able to do this via powercli? I have a txt list of deleted VMs that I'd like to report the following metrics for year-end resources reclaimed purposes: VMname Provision RAM Average us... See more...
Am I able to do this via powercli? I have a txt list of deleted VMs that I'd like to report the following metrics for year-end resources reclaimed purposes: VMname Provision RAM Average used RAM Provisioned vCPU Average used RAM Provisioned disk space (GB) Used disk space (GB). I am okay dropping average used RAM and vCPU. I would think this would be an option to run via powercli but have no idea how to integrate the information from vRealize to powercli other than what I read (and tried) from https://ryanjan.uk/2018/05/16/running-vrops-reports-using-powercli/ . This seems easy enough but I require assistance on this quarterly task. Get-content servers.txt seems like it needs to be used. Can OMStat be used to gather stats on deleted vms? Message was edited by: JoyM
I have a txt vm list that I'd like to get a report on that includes the following: VMname Provision RAM Average used RAM Provisioned vCPU Average used RAM Provisioned disk space (GB) Used... See more...
I have a txt vm list that I'd like to get a report on that includes the following: VMname Provision RAM Average used RAM Provisioned vCPU Average used RAM Provisioned disk space (GB) Used disk space (GB) I am okay dropping average used RAM and vCPU. I would think this would be an option to run via powercli but have no idea how to integrate the information from vRealize to powercli other than what I read (and tried) from https://ryanjan.uk/2018/05/16/running-vrops-reports-using-powercli/ . This seems easy enough but I require assistance on this quarterly task. Get-content servers.txt seems like it needs to be used.
My apologies. If the notes has 7 lines, I want 7 columns. If the notes has 3 lines, I want 3 columns. If it has 10 lines, then 10 columns. This will end up with a csv with the vm name and the ... See more...
My apologies. If the notes has 7 lines, I want 7 columns. If the notes has 3 lines, I want 3 columns. If it has 10 lines, then 10 columns. This will end up with a csv with the vm name and the number of columns equal to the max number of lines in the annotations; some VMs will have blank columns due to the fact they had less notes than other VMs. This is a problem with inconsistency and why I prefer tags. I hope this makes more sense. I want all the notes output with column separators when there is a line break in the notes. In the table I added, Column 1 (Header 1) = vmname