read a great article about a new API for updating the tools repository. Configuring a VMware Tools Repository in vSphere 6.7U1 - VMware vSphere Blog
it uses the new UpdateProductLockerLocation_Task method. there is currently no module to do this.
does anyone have any idea how we could do this in a powerCLI script?
thanks
Scott
That post was only published 4 hours ago :smileygrin:
But luckily you can access the API methods from PowerCLI.
Try something like this (note that the folder should exist).
$dsName = 'MyDS'
$dsFolder = 'ToolsRepo'
$esx = Get-VMHost -Name $esxName
$ds = Get-Datastore -Name $dsName
$oldLocation = $esx.ExtensionData.QueryProductLockerLocation()
$location = "/$($ds.ExtensionData.Info.Url.TrimStart('ds:/'))$dsFolder"
$esx.ExtensionData.UpdateProductLockerLocation($location)
Write-Host "Tools repository moved from"
Write-Host $oldLocation
Write-Host "to"
Write-Host $location
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That post was only published 4 hours ago :smileygrin:
But luckily you can access the API methods from PowerCLI.
Try something like this (note that the folder should exist).
$dsName = 'MyDS'
$dsFolder = 'ToolsRepo'
$esx = Get-VMHost -Name $esxName
$ds = Get-Datastore -Name $dsName
$oldLocation = $esx.ExtensionData.QueryProductLockerLocation()
$location = "/$($ds.ExtensionData.Info.Url.TrimStart('ds:/'))$dsFolder"
$esx.ExtensionData.UpdateProductLockerLocation($location)
Write-Host "Tools repository moved from"
Write-Host $oldLocation
Write-Host "to"
Write-Host $location
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I know it only 4 hours only. but you know the question is going to come up, because what do you do when you have lots and lots of host to change, Powercli it!!!
thanks for the answer LucD.
That's the spirit, automate it (with PowerCLI preferably) when you do it more than once
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
question:
should we be updating
UpdateProductLockerLocation or UpdateProductLockerLocation_task?
Both API methods do the same.
The ones with _Task at the end run in async mode, similar to the RunAsync switch on some PowerCLI cmdlets.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The post applies to vSphere 6.7U1.
If we are in a mixed environment, VC on 6.7U1, but ESXi still on 6.5 (upgrade planned), may I use this method?
regards
Riaan
Since the method is called on the ESXi node, I'm afraid your ESXi needs to be on 6.7U1.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
While I realize this post is a bit older...but I just came across it. My environment is slightly different, but I can't seem to find anything.
ESXi 6.7u2ep10
When running your script I get the following error:
Method invocation failed because [VMware.Vim.HostSystem] does not contain a method named 'QueryProductLockerLocation'.
Thoughts? I can make the change manually in MOB, but would rather script it...
Thanks!
Doesn't this return the two methods?
$esx.ExtensionData | Get-Member -MemberType Method -Name *ProductLocker*
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry, I was running an older version of PowerCLI (6.5). I upgraded to 11.5 and then it worked.
Thanks for the quick response though!