LucD's Posts

You didn't specify the Property for the imported data Change to $missingPrivileges = $PList.LIST | Where-Object { $_ -notin $currentPrivileges }
Without knowing what is in $PList it is hard to tell
Does the solution provided in Issue#4 help?
Again, you are aware that his code only moves 1 VM, you will have to place it in a function or a loop. In any case, that info is all there. You can easily write that to a log (line after the Move... See more...
Again, you are aware that his code only moves 1 VM, you will have to place it in a function or a loop. In any case, that info is all there. You can easily write that to a log (line after the Move-VM line) Write-Host "Moving $targetvm to $deltahost" Move-VM -VM (Get-VM -Name $targetvm) -Destination (Get-VMHost -Name $deltahost) -VMotionPriority:High | Out-Null "$((Get-Date).ToString()) VM: $targetvm From: $((Get-VM -Name $targetvm).VMHost.Name) To: $deltahost" | Out-File -FilePath ".\log.txt" -Append  
I would strongly advise you not to do that, it might cause duplicate MAC addresses on your network. Under MAC Address Assignment from vCenter Server under Preventing MAC Address Conflicts, it clea... See more...
I would strongly advise you not to do that, it might cause duplicate MAC addresses on your network. Under MAC Address Assignment from vCenter Server under Preventing MAC Address Conflicts, it clearly states "The MAC address of a powered off virtual machine is not checked against the addresses of running or suspended virtual machines." So if that VM is powered off, another VM might obtain that same MAC address out of the reserved range. When the 1st VM is now powered on and since it is not marked as Automatic anymore, the MAC address will not be changed. Hence a MAC address conflict on the network.
Not really, that would require quite some major changes, i.e. a new script
Since this code (I assume you copied it from here) only moves 1 VM, how would you make this move 3 VMs in parallel?
That script assumes that the Alarm trigger is an event, the screenshot you post is from an Alarm that is triggered by a metric. Having a script that shows all possible trigger types and the details... See more...
That script assumes that the Alarm trigger is an event, the screenshot you post is from an Alarm that is triggered by a metric. Having a script that shows all possible trigger types and the details will be rather complex.
You can query these Advanced Settings with Get-AdvancedSetting. The following will set isolation.tools.autoInstall.disable to False, when it is set to True. Note that this will not add the setting ... See more...
You can query these Advanced Settings with Get-AdvancedSetting. The following will set isolation.tools.autoInstall.disable to False, when it is set to True. Note that this will not add the setting when it isn't there (which shouldn't cause an issue for the AutoUpgrade setting). Get-VM -Name MyVM | Get-AdvancedSetting -Name isolation.tools.autoInstall.disable | where{$_.Value -eq 'True'} | Set-AdvancedSetting -Value False -Confirm:$false
1) Yes, should work. But note that vSphere 6.7 and all versions before are not supported anymore since Oct 2022 2) You will have to set the VMX entry to $false Get-VM -Name MyVM | Get-AdvancedS... See more...
1) Yes, should work. But note that vSphere 6.7 and all versions before are not supported anymore since Oct 2022 2) You will have to set the VMX entry to $false Get-VM -Name MyVM | Get-AdvancedSetting -Name isolation.tools.autoInstall.disable | Set-AdvancedSetting -Value false
Looks like you didn't import the PowerCLI module that holds the definition for that type. Import-Module -Name VMware.VimAutomation.Core
To be honest I don't think moving VMs around, based on how much memory they use, is not a good way to balance a cluster. That is why DRS uses more indicators to do just that. If you still want to ... See more...
To be honest I don't think moving VMs around, based on how much memory they use, is not a good way to balance a cluster. That is why DRS uses more indicators to do just that. If you still want to use this logic, there are a couple of things you should add to the code. - remember if a VM was already moved - check if the average memory consumption on each ESXi node in the cluster is located within a reasonable range. Calculating and optimising/minimisng the Standard Deviation of the memory consumption looks like an option.
You can use a VIProperty I once wrote to retrieve the full blue folderpath. To avoid having to call the VIProperty twice I used the script scope to store the $path variable.   New-VIProperty -Na... See more...
You can use a VIProperty I once wrote to retrieve the full blue folderpath. To avoid having to call the VIProperty twice I used the script scope to store the $path variable.   New-VIProperty -Name 'BlueFolderPath' -ObjectType 'VirtualMachine' -Value { param($vm) function Get-ParentName{ param($object) if($object.Folder){ $blue = Get-ParentName $object.Folder $name = $object.Folder.Name } elseif($object.Parent -and $object.Parent.GetType().Name -like "Folder*"){ $blue = Get-ParentName $object.Parent $name = $object.Parent.Name } elseif($object.ParentFolder){ $blue = Get-ParentName $object.ParentFolder $name = $object.ParentFolder.Name } if("vm","Datacenters" -notcontains $name){ $blue + "/" + $name } else{ $blue } } (Get-ParentName $vm).Remove(0,1) } -Force | Out-Null #Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Scope AllUsers $stat = 'sys.osuptime.latest' $now = Get-Date $vms = Get-VM Get-Stat -Entity $vms -Stat $stat -Realtime -MaxSamples 1 | Select @{N='VM';E={$_.Entity.Name}}, @{N='GuestOS';E={$_.Entity.ExtensionData.Guest.GuestFullName}}, @{N='Notes';E={$_.Entity.ExtensionData.Summary.Config.Annotation}}, @{N='VMware Tools State';E={$_.Entity.ExtensionData.Guest.ToolsStatus}}, @{N='VMware Tools Version';E={$_.Entity.ExtensionData.Guest.ToolsVersion}}, @{N='CreateDate';E={$_.Entity.CreateDate}}, @{N='LastOSBoot';E={$now.AddSeconds(- $_.Value)}}, @{N='UptimeDays';E={[math]::Floor($_.Value/(24*60*60))}}, @{N="DNS";E={$_.Entity.ExtensionData.Guest.IpStack.DnsConfig.IpAddress}}, @{N='Tag';E={(Get-TagAssignment -Entity $_.Entity -Category 'Backup').Tag.name}}, @{N='IT Team';E={ $script:path = $_.Entity.BlueFolderPath $script:path.Split('/')[-2] }}, @{N='Application';E={$script:path.Split('/')[-1]}} | Export-Csv -Path .\VM_Uptime_Report.csv -NoTypeInformation -UseCulture  
The problem is with this line $fhostram.GetEnumerator() | Sort-Object Name Since that output is not captured in a variable, the result is also returned by the function. Which explains what you s... See more...
The problem is with this line $fhostram.GetEnumerator() | Sort-Object Name Since that output is not captured in a variable, the result is also returned by the function. Which explains what you seeing in the variables that capture what the function returns. I suspect that this line should be $fhostram = $fhostram.GetEnumerator() | Sort-Object Name  
In that case use -ErrorAction Ignore
Try adding the -SkipCertificateCheck to the call to Invoke-VMScriptPlus
Then use -ErrorAction Stop
Good, that is a recent version. You can safely remove the Add-PsSnapin line
Nothing official I'm afraid, but William wrote a script that uses the MOB to create such permissions. Have a look at Automating vSphere Global Permissions with PowerCLI (williamlam.com)
The Principal parameter only accepts a single value. You will have to use a loop to add multiple $users = 'domain\user1','domain\user2','domain\user3' $users | Foreach-Object -Process { New-VI... See more...
The Principal parameter only accepts a single value. You will have to use a loop to add multiple $users = 'domain\user1','domain\user2','domain\user3' $users | Foreach-Object -Process { New-VIPermission -Entity (Get-Folder -Name Datacenters) -Principal $_ -Role Admin }