Gaprofitt17's Posts

  I have read in some docs when you enable vSAN encryption only new data is encrypted.  I thought it performs a rolling reformat and then moves the data back, so all data would be encrypted..
Ok, i'm close.. Connect-CIServer -Server https://servername $vmv = Get-CIVM -name testvmname Foreach ($vm in $vmv) { $Metadata = $vm.ExtensionData.GetMetadata() $MetaValue1= $Metadata.Met... See more...
Ok, i'm close.. Connect-CIServer -Server https://servername $vmv = Get-CIVM -name testvmname Foreach ($vm in $vmv) { $Metadata = $vm.ExtensionData.GetMetadata() $MetaValue1= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"owner_name")].TypedValue.Value $MetaValue2= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"referential_id")].TypedValue.Value $MetaValue3= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"template_os_version")].TypedValue.Value $MetaValue4= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"class_of_data")].TypedValue.Value $MetaValue5= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"service_offering")].TypedValue.Value $MetaValue6= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"app_code")].TypedValue.Value $MetaValue7= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"server_role")].TypedValue.Value $MetaValue8= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"template_os_name")].TypedValue.Value $MetaValue9= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"business_unit")].TypedValue.Value $MetaValue10= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"env")].TypedValue.Value $MetaValue11= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"cost_code")].TypedValue.Value $MetaValue12= $Metadata.MetadataEntry[[array]::indexof($Metadata.MetadataEntry.Key,"cmdb_ci_service_technical")].TypedValue.Value Write-Host $vm + $MetaValue1 + $MetaValue2 +$MetaValue3 + $MetaValue4 + $MetaValue5 + $MetaValue6 + $MetaValue6 + $MetaValue7     How do I get the data in a CSV with the VM names, $MetaValue1, 2, 3 etc with the corresponding values and keys?  Also for NULL it blows up..
I'm trying to do the following: Get a report of all associated Metadata with each VM in vCloud Director..  Ideally i'd have vorg name, vdc, vapp, and vm name and associated metadata for just the V... See more...
I'm trying to do the following: Get a report of all associated Metadata with each VM in vCloud Director..  Ideally i'd have vorg name, vdc, vapp, and vm name and associated metadata for just the VM. $vmv = Get-CIVM | Sort-Object -Property Name Foreach ($vm In $vmv) { $Metadata = $vm.ExtensionData.GetMetadata() | Export-CSV -path c:\scripts\test1.csv }   You cannot call a method on a null-valued expression.   Figure out how to update an existing attribute/value with the correct value for a given VM.. Thanks in advance..    
  It runs successfully, but we are also using vCloud Director with meta data/tags.  It looks like these are not passed into vCenter.  Is there a mechanism to pass them or at least query the data fro... See more...
  It runs successfully, but we are also using vCloud Director with meta data/tags.  It looks like these are not passed into vCenter.  Is there a mechanism to pass them or at least query the data from vCD?  The cmdlets for vCloud Director look pretty limiting.
  Hi, I'm trying to report on the following per vCenter: VM name, all custom attribute fields including fields with no values. I've found some good examples in the community on interjecting new ... See more...
  Hi, I'm trying to report on the following per vCenter: VM name, all custom attribute fields including fields with no values. I've found some good examples in the community on interjecting new values but not on just reporting.  Is there something more robust than below? Pulling from vCenter DB, etc.. Get-VM | Select Name -ExpandProperty CustomFields     Thanks..
I'm trying to pull the following and not having much success: Org Name, VDC name, associated vAPPS and underlying VM's.  I also need created date. I've tried various scripts and not having much suc... See more...
I'm trying to pull the following and not having much success: Org Name, VDC name, associated vAPPS and underlying VM's.  I also need created date. I've tried various scripts and not having much success..   For example:   $ListOrg = Get-Org | Sort-Object -Property Name # Write the list and prompt for input write-host "$ListOrg" write-host "" $Org = read-host "Please Enter the Name of the Org" $vms = Get-Org -Name $Org | get-civm $objects = @()   # Jakes Smarts foreach($vm in $vms) {  $hardware = $vm.ExtensionData.GetVirtualHardwareSection()  $diskMB = (($hardware.Item | where {$_.resourcetype.value -eq "17"}) | %{$_.hostresource[0].anyattr[0]."#text"} | Measure-Object -Sum).sum  $row = New-Object PSObject -Property @{"vapp" = $vm.vapp; "name"=$vm.Name;"cpuCount"=$vm.CpuCount;"memoryGB"=$vm.MemoryGB;"storageGB"=($diskMB/1024)}  $objects += $row }   # Use select object to get the column order right. Sort by vApp. Force table formatting and auto-width. $objects | select-Object name,vapp,cpuCount,memoryGB,storageGB | Sort-Object -Property vapp | Format-Table -AutoSize   # Also Export results to CVS for further processing $objects | Export-Csv "$Org.csv" -NoTypeInformation -UseCulture II don't really want them listed individually, but as groups..  Any easy tool or way of going this?
I need to modify some OrgVDC's to set memory and cpu guaranteed amounts.  It's requesting a positive number, but I want 0, the parameter shows 0 as an option, how do I get around this?   Get-OrgVdc... See more...
I need to modify some OrgVDC's to set memory and cpu guaranteed amounts.  It's requesting a positive number, but I want 0, the parameter shows 0 as an option, how do I get around this?   Get-OrgVdc -Name 'Workshop' | Set-OrgVdc -CpuGuaranteedPercent 0 Set-OrgVdc: Cannot validate argument on parameter 'CpuGuaranteedPercent'. A positive value is expected. Parameter values: Specifies the percentage of CPU resources that are reserved for the organization vDC. This parameter accepts values in the range of 0 to 100. This parameter is only applicable to the Pay As You Go and Allocation Pool resource allocation models.   Thanks..   Greg
Hey, Had a question, using VScode and when I upgraded to MacOS Ventura, when I connect to a vCenter it prompts for login, I enter creds and it just hangs.  Does the same thing on every vCenter. When... See more...
Hey, Had a question, using VScode and when I upgraded to MacOS Ventura, when I connect to a vCenter it prompts for login, I enter creds and it just hangs.  Does the same thing on every vCenter. When I try to enable verbose I don't get anything useful as to what the issue might be.  I'm running current Powershell version, also updated Powercli module. Any thoughts..?   Greg
That worked.  Thanks a bunch..
I'm trying to clone a list of VM's to an alternate datastore, I have a list of VM's in a .CSV file.   ## Connect-VIServer vcenter.server $VMHost = "hostname.test" $srcvms = Import-Csv -Path ./... See more...
I'm trying to clone a list of VM's to an alternate datastore, I have a list of VM's in a .CSV file.   ## Connect-VIServer vcenter.server $VMHost = "hostname.test" $srcvms = Import-Csv -Path ./Documents/vmnames.csv -UseCulture | select -ExpandProperty VM Foreach ($srcvm in $srcvms) { new-vm -name "clone_$srcvm" -VM $srcvm -VMHost $VMHost -Datastore "test" -DiskStorageFormat Thin -RunAsync }   My variable returns hostname.test, I am connected to my vCenter, but it's barking about the $VMhost variable..   new-vm -name "clone_$srcvm" -VM $srcvm -VMHost '$VMHost' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 5/9/2022 12:52:48 PM New-VM Please specify at least one of the following parameters: "ResourcePool" or "VMHost".   All the hosts have the test datastore mounted, can I forego the VMhost requirement or what am I doing wrong?   Thanks,   Greg
  Perhaps VM-host rules would make more sense then.  
  It would be an affinity rule based on OS type just for DRS, not SDRS.. I'll see if I can find the example, I didn't see it when searching prior to posting..
  Is there a way to schedule DRS to monitor say hourly via script and manage DRS rules to keep machines with Windows OS on particular hosts? We don't want to babysit this list as new VM's are built.... See more...
  Is there a way to schedule DRS to monitor say hourly via script and manage DRS rules to keep machines with Windows OS on particular hosts? We don't want to babysit this list as new VM's are built.  VCenter 7.x, ESXi 7.x   Thanks,   Greg
It would read it but not display anything, same thing happens on a bunch of my CSV files.  I created some new ones and it's working fine, must have some hidden formatting in there or something.. ... See more...
It would read it but not display anything, same thing happens on a bunch of my CSV files.  I created some new ones and it's working fine, must have some hidden formatting in there or something.. Thanks.
$VMlist = Import-Csv -Path /temp/5192020.csv -UseCulture | select -ExpandProperty Name Get-VM -Name $VMlist | where {$_.PowerState -eq "PoweredOn"} I have Name in my first column, first cell... See more...
$VMlist = Import-Csv -Path /temp/5192020.csv -UseCulture | select -ExpandProperty Name Get-VM -Name $VMlist | where {$_.PowerState -eq "PoweredOn"} I have Name in my first column, first cell and the list of VM's below this in the .csv file  I get this error..  Am I trying to use something that's been deprecated? Get-VM -Name $VMlist | where {$_.PowerState -eq "PoweredOn"}      |               ~~~~~~~      | Cannot validate argument on parameter 'Name'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null      | values and then try the command again. Thanks..
That was it, I was connected to the same vCenter twice using seperate credentials..  Thanks so much, as always..
I've been using this script for about a month, been working fine, then all of a sudden it stops working. $Cluster = "Cluster-1" $Datastores = "CBE_TO_QTS_VMMigration_OS_01" $VMFolder = "... See more...
I've been using this script for about a month, been working fine, then all of a sudden it stops working. $Cluster = "Cluster-1" $Datastores = "CBE_TO_QTS_VMMigration_OS_01" $VMFolder = "TEST" $ESXHost = Get-Cluster $Cluster | Get-VMHost | select -First 1 foreach($Datastore in Get-Datastore $Datastores) { # Set up Search for .VMX Files in Datastore $ds = Get-Datastore -Name $Datastore | %{Get-View $_.Id} $SearchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec $SearchSpec.matchpattern = "*.vmx" $dsBrowser = Get-View $ds.browser $DatastorePath = "[" + $ds.Summary.Name + "]" # Find all .VMX file paths in Datastore, filtering out ones with .snapshot (Useful for NetApp NFS) $SearchResult = $dsBrowser.SearchDatastoreSubFolders($DatastorePath, $SearchSpec) | where {$_.FolderPath -notmatch ".snapshot"} | %{$_.FolderPath + ($_.File | select Path).Path} #Register all .vmx Files as VMs on the datastore foreach($VMXFile in $SearchResult) { New-VM -VMFilePath $VMXFile -VMHost $ESXHost -Location $VMFolder -RunAsync } } I get this everytime.  The datastore is mounted to all the host in the cluster. Exception calling "SearchDatastoreSubFolders" with "2" argument(s): "Invalid datastore path '[CBE_TO_QTS_VMMigration_OS_01 CBE_TO_QTS_VMMigration_OS_01 CBE_TO_QTS_VMMigration_OS_01      | CBE_TO_QTS_VMMigration_OS_01]'." Any guesses or suggestions?
Hi, I recently switched to a mac.  Attempting to use Powershell Core and VScode versus what I used in the past, Powershell ISE.  I'm finding a lot of my scripts are having issues.  I also am ... See more...
Hi, I recently switched to a mac.  Attempting to use Powershell Core and VScode versus what I used in the past, Powershell ISE.  I'm finding a lot of my scripts are having issues.  I also am not crazy about VScode, even with the powershell extension.  Any suggestions?  I know I can run my code on a Windows VM but was just wondering am I missing something?
Thanks LucD.. Much appreciated!
How would I add Power status on this, and specify I only want powered on VM's in the report? Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Sele... See more...
How would I add Power status on this, and specify I only want powered on VM's in the report? Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}},  @{N="Running OS";E={$_.Guest.GuestFullName}} | Export-CSV