The managed obj reference (MoRef) of the automation objects is expressed by the ID property. However, the Get-View cmdlet only knows this value by the MoRef parameter. This forces you do this:
get-vmhost | % { get-view $_.ID }
Instead of this:
get-vmhost | get-view
Can the cmdlet be altered to support the second example?
Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)
I have not been able to get either of these to successfully return the proper object. I instead receive permission denied when trying to retrieve the view.
I have not been able to get either of these to successfully return the proper object. I instead receive permission denied when trying to retrieve the view.
What error are you seeing? Does get-vmhost return any hosts?
Well the second command won't work because it's not designed to presently, although I'm hoping VMware can change it. If you get permission denied on the first command, that may be because you have not chosen and logged into a server using the get-viserver command, or the user ID you used did not have the proper permissions to do the task you are attempting.
Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)
I get the error below. I am authenticating to vc, and get-vmhost returns my hosts, but the get-view returns the below error.
Get-View : Permission to perform this operation was denied.
I have verified that I am using the correct version.
VI Toolkit Version
-
VMware VI Toolkit for Windows 1.0 (Beta) build 81531
I get the error below. I am authenticating to vc, and get-vmhost returns my hosts, but the get-view returns the below error.
Get-View : Permission to perform this operation was denied.
I have verified that I am using the correct version.
VI Toolkit Version
-----
VMware VI Toolkit for Windows 1.0 (Beta) build 81531
Do you know what role your user is using? If it's a custom role, could you summarize what permissions it has or attach a screenshot from the role editor?
I am running command with a custom administrator role. The only option removed from the administrator role is suspend vm.
-KjB
I have now also tried running the same command in my lab environment that has no custom roles with the same result, 'Permission to perform operation was denied'
I also tried retrieving a host with get-viserver bypassing vc, and received the same result using root.
It appears that for some reason, after a period of use, my shell produces the permission denied when trying to use get-view with a host or vm object's ID. If I close my shell, and re-open the terminal, the same command which was failing, successfully produces the correct output. I'm not sure if there is a timeout associated here somewhere, but it's strange that is only causing issues when trying to use get-view. My virtual center times out after 20 minutes, which causes me to re-authenticate to my vc, but even that does not fix it. I have had to close out the shell, and open a fresh one.
-KjB
Maybe I'm misunderstanding your issue but yes--you do have to re-auth using get-viserver after X minutes of inactivity.
Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Sorry, I wasn't more clear earlier. I do have to re-authenticate after my vc object times out. However, it does not help get-view. I can get an object successfully from get-vmhost or get-vm, after inactivity by re-authenticating to vc, but piping that object to get-view fails and produces the permission denied exception. That is why I mentioned that maybe there is something additional for get-view, which is causing a failure for me.
Ok, I have been able to re-produce the behavior several times now. I am using a saved credential, supplied to VC to save some typing. Below is the process I am following to reproduce the issue.
Create a credential object
Connect to vc using saved credential
Use get-vm or get-vmhost -- SUCCESSFUL--
pipe object to get-view -- SUCCESSFUL--
-
Wait until vc object times out
Re-authenticate to vc using credential (saved or newly created object)
Use get-vm or get-vmhost -- SUCCESSFUL--
pipe object to get-view -- FAILURE -- "permission to perform this operation denied"
-
Close window
Open new terminal window
Create credential and connect to vc
Use get-vm or get-vmhost -- SUCCESSFUL--
pipe object to get-view -- SUCCESSFUL--
We have confirmed that this is a bug. In an earlier version of the toolkit there were 2 ways to authenticate, get-viserver and connect-vim. Connect-vim was used for the get-view and find-entityview cmdlets. We merged these for the Beta.
Unfortunately, if you connect using get-viserver and your session times out, get-viserver won't refresh the timed-out connection that is used for the get-view and find-entityview cmdlets.
The workaround is to close the session and start a new one. We will have a fix for this in our GA release.
Ahh, excellent, glad you guys figured that out and will be fixing it. Now any comment on my defect report/feature suggestion (depending on how you look at it) with how get-view works?
Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)