vmCalgary's Posts

$PSDefaultParameterValues is empty. I see them running concurrently in web client.
LucD Hello again. My objective is to use the Move-VM from one datastore to another one at a time. My script is doing the equivalent to -RunAsync. C:\> $VMsToRelocate = (Get-Content "C:... See more...
LucD Hello again. My objective is to use the Move-VM from one datastore to another one at a time. My script is doing the equivalent to -RunAsync. C:\> $VMsToRelocate = (Get-Content "C:\Users\username\Desktop\O6297-storage_vm\O6297_SVM.csv") $Datastore = Get-Datastore -Name "st815zz_vcd_ds8" foreach ($VM in $VMsToRelocate) { Write-Host "Relocating VM:" $VM "to" $Datastore Get-VM -Name $VM | Move-VM -datastore $Datastore > $null } Write-Host "Completed!" My file is a list of VM names: VM1 VM2 VM3 It works but all at once. I want one at a time. What am I missing?
LucD I'm noticing a random aside that likely makes no difference to my results. If the folder has a forward slash in it's name I get the following message. I'm not going to worry about it ... See more...
LucD I'm noticing a random aside that likely makes no difference to my results. If the folder has a forward slash in it's name I get the following message. I'm not going to worry about it as my vm count is correct. If I had the cycles, I'd rename the folders with an acceptable character, but I'd want to do it with regular expressions vs one by one.EG: current name:Linux/Unix --> rename to Linux-Unix.  (if '/' is in the folder name replace with '-').
Also, my VMs have unique VM names. They potentially have similar beginning characters of the VM names (container names) as shown in this example below. Is that what you mean by display names? ... See more...
Also, my VMs have unique VM names. They potentially have similar beginning characters of the VM names (container names) as shown in this example below. Is that what you mean by display names?
LucD That makes sense and I'm willing to give it a go. However, I have several datacenters in my vcenter and I don't want to give it a go with the wrong ask, ie: a wildcard for the datacenter... See more...
LucD That makes sense and I'm willing to give it a go. However, I have several datacenters in my vcenter and I don't want to give it a go with the wrong ask, ie: a wildcard for the datacenter. Get-Datacenter -Name MyDC | Get-Folder -Name * -NoRecursion | --> I'd be entering Get-Datacenter -Name * | Get-Folder -Name * - NoRecursion. Seems like too many wildcards to me.
LucD - randomly this pops up (see image). This is similar to what the math on uptime showed.
LucD , perhaps I spoke too soon. I modified your script slightly to capture sizing information. I also had to comment out the uptime field as it was occasionally generating an error (my ... See more...
LucD , perhaps I spoke too soon. I modified your script slightly to capture sizing information. I also had to comment out the uptime field as it was occasionally generating an error (my apologies, I didn't capture it). I am concerned the script is stuck in a loop as it's been running for hours. Here's my script: #Report on vcloud vms - need users to decide what to do where there are duplicate names $report = @() Get-Folder -Name *| ForEach-Object -Process {     Get-InventoryPlus -RootObject $_ | where{$_.Type -eq 'VirtualMachine'} |     ForEach-Object -Process {         $vm = Get-VM $_.Name         $_ | Add-Member -Name PowerSTate -Value $vm.PowerState -MemberType NoteProperty         $_ | Add-Member -Name OSName -Value $vm.guest.hostname -MemberType NoteProperty         $_ | Add-Member -Name VMHost -Value $vm.VMHost.Name -MemberType NoteProperty         #$_ | Add-Member -Name UptimeDays -Value ([math]::Round(([TimeSpan]::FromSeconds($vm.ExtensionData.Summary.QuickSTats.UptimeSeconds)).TotalDays,0)) -MemberType NoteProperty (paste word wrapped)         $_ | Add-Member -Name IPAddress -Value ($vm.Guest.IPAddress -join '|') -MemberType NoteProperty                 $_ | Add-Member -Name Datastore -Value ((Get-View -Id $vm.DatastoreIdList -Property Name).Name -join '|') -MemberType NoteProperty         $_ | Add-Member -Name VMid -Value $vm.id -MemberType NoteProperty         $_ | Add-Member -Name MemoryMB -Value $vm.MemoryMB -MemberType NoteProperty         $_ | Add-Member -Name NumCPU -Value $vm.NumCPU -MemberType NoteProperty         $_ | Add-Member -Name UsedSpaceGB -Value $vm.UsedSpaceGB -MemberType NoteProperty                $_ | Add-Member -Name vCenter -Value (([uri]$vm.ExtensionData.Client.ServiceUrl).Host) -MemberType NoteProperty         #$_| Add-Member -Name Notes -Value ($vm.Notes) -MemberType NoteProperty            $_     } } $report
Thank you, LucD , for the explanation and information regarding seconds to days. As always with your guidance, it worked like a charm.
LucD​, that's almost exactly what I want. I've inserted the output below. 1. I'm looking to limit it to a particular folder with wildcard (vCloud*) to shorten my results. I'm not sure how ... See more...
LucD​, that's almost exactly what I want. I've inserted the output below. 1. I'm looking to limit it to a particular folder with wildcard (vCloud*) to shorten my results. I'm not sure how to insert that into the process. 2. I would also like a bit of help understanding blue path vs yellow path. I've been reading your blog on Get-InventoryPlus and am not comprehending it. 3. Uptime:  $_ | Add-Member -Name Uptime -Value $vm.ExtensionData.Summary.QuickSTats.UptimeSeconds ----> how do I get this rounded to days vs seconds? You've been a great teacher, Luc. I look forward to your reply. VMware_scripts> get-folder vClou* Name                               Type ----                                     ---- vCloud (CG-ZZ)                 VM vCloud (CG-NL)                 VM
jeffreymcclain​ LucD​ Jeffery, did LucD help you with merging the folder information with the vm information? I'm looking for the same output so I can get users to authorize vm deletions. My ... See more...
jeffreymcclain​ LucD​ Jeffery, did LucD help you with merging the folder information with the vm information? I'm looking for the same output so I can get users to authorize vm deletions. My column headers are: Folder Folder Path VM Name PowerState VMhost Uptime IP address(es) datastore vcentre (optional) I can do one or the other (folder vs vm information) and match up in Excel but that seems to be a waste of time. I'm just not sure of the code to use in powercli. Here's my gotcha as well...I'd like to do it for folders that contain a specific phrase such as "Wireless".
LucD, I like the code you shared for Cluster | VM | Snapshot way back ion Jan 28, 2016 10:10 PM in this post. I'm looking for a modification so that it's Datastore | VM | Snapshot. The resulting... See more...
LucD, I like the code you shared for Cluster | VM | Snapshot way back ion Jan 28, 2016 10:10 PM in this post. I'm looking for a modification so that it's Datastore | VM | Snapshot. The resulting table would display: Datastore Name     VM Name   Snapshot Name   Size   Days Old I'm tripped up on the code.
LucD, How do you capture the vcenter that a particular VM may be on when the environment has mulitiple vCenters? I'd like to add to this script to list the vcenter for each vm. Thanks in advanc... See more...
LucD, How do you capture the vcenter that a particular VM may be on when the environment has mulitiple vCenters? I'd like to add to this script to list the vcenter for each vm. Thanks in advance, Joy
Luc, I get what you're doing. Conceptually the same as a LEFT OUTER JOIN in MySQL. My results were not what I expected. You can see the blanks for yourself. Device    : NIC       : IPSw   ... See more...
Luc, I get what you're doing. Conceptually the same as a LEFT OUTER JOIN in MySQL. My results were not what I expected. You can see the blanks for yourself. Device    : NIC       : IPSw      : VLAN      : IP        : 10.187.230.226 VM        : VMname.no.cg.int.where_I_work.net Portgroup : CSD--10.187.230.0/24--CSC-MGMT vSwitch   : vNIC      : Network adapter 1 VMHost    : vh315no.vim.dcs.mlb.inet Device    : NIC       : IPSw      : VLAN      : IP        : 10.187.230.156|fe80::250:56ff:fe89:648d VM        : VMname2.no.cg.nms.mlb.inet Portgroup : CSD--10.187.230.0/24--CSC-MGMT vSwitch   : vNIC      : Network adapter 1 VMHost    : vh315no.vim.dcs.mlb.inet The earlier code from my Nov 7, 2017 10:51 am post gave me: ESX       : vh301bb.vim.dcs.mlb.inet vSwitch   : vSwitch1 NIC       : vmnic3,vmnic1 Portgroup : RSC--64.59.161.64/29--Public VLAN      : 650 Device    : IP        : ESX       : vh301bb.vim.dcs.mlb.inet vSwitch   : vSwitchUSB0 NIC       : vusb0 Portgroup : IMM_Network0 VLAN      : 0 Device    : vmk1 IP        : 169.254.95.120 Essentially all  I need: VMname, Portgroups used, VLANS used, esxi host used. IP address of the VM is a would be nice to verify that the IP truly matches the portgroup on the esxi host is a match (sanity check). VM: VMname2.no.cg.nms.mlb.inet IP: 10.187.230.156|fe80::250:56ff:fe89:648d VMHost: vh315no.vim.dcs.mlb.inet Portgroup:  CSD--10.187.230.0/24--CSC-MGMT VLAN: 155      Below is from the original code.
Do you have VMs with more than 1 vNIC? Yes we have VMs with more than one vNIC.
LucD​, I love the output from the following but I'm missing a bit of information for my needs. &{foreach($esx in Get-VMHost){     $vNicTab = @{}     $esx.ExtensionData.Config.Network.Vni... See more...
LucD​, I love the output from the following but I'm missing a bit of information for my needs. &{foreach($esx in Get-VMHost){     $vNicTab = @{}     $esx.ExtensionData.Config.Network.Vnic | %{         $vNicTab.Add($_.Portgroup,$_)     }     foreach($vsw in (Get-VirtualSwitch -VMHost $esx)){         foreach($pg in (Get-VirtualPortGroup -VirtualSwitch $vsw)){             Select -InputObject $pg -Property @{N="ESX";E={$esx.name}},                 @{N="vSwitch";E={$vsw.Name}},                 @{N="NIC";E={if($vsw.Nic){[string]::Join(',',$vsw.Nic)}}},                 @{N="Portgroup";E={$pg.Name}},                 @{N="VLAN";E={$pg.VLanId}},                 @{N="Device";E={if($vNicTab.ContainsKey($pg.Name)){$vNicTab[$pg.Name].Device}}},                 @{N="IP";E={if($vNicTab.ContainsKey($pg.Name)){$vNicTab[$pg.Name].Spec.Ip.IpAddress}}}         }     } }} | Export-Csv report.csv -NoTypeInformation -UseCulture How do I get the following columns? VM Name, VM_IP, Virtual Host + the output from above:  vSwitch, NIC,  PortGroup,  VLAN, Device, IP I am planning on retiring a cluster and need to move VMs. My goal is to accurately identify which VMs and VLANs/PortGroups I need to relocate. I do have a specific cluster name if that helps.
The above is a datastore folder containing four datastores. I'd like to find out the VM names, power status, usageGB, and cluster of VM for all VMs using those four datastores. I'm struggli... See more...
The above is a datastore folder containing four datastores. I'd like to find out the VM names, power status, usageGB, and cluster of VM for all VMs using those four datastores. I'm struggling with using get-datastore, get-folder -type datastore, get-vm to get this information. Get-Folder -name stc03-lab | get-datastore | get-vm gives me kind of what I want: PowerCLI C:\> get-folder -name stc03-lab | get-datastore | get-vm -name mgt3. Name                 PowerState Num CPUs MemoryGB ----                 ---------- -------- -------- mgt3. PoweredOn  2        2.000 What I want is: VM Name                Datastore                                PowerState                  mgt3                         st037_nl                                   PoweredOn                It would be really nice to add in provisioned and used resources (memory, cpu, and storage). I am new to powercli and would appreciate any help the community can offer.