How to get the domain (different domains! ) of any vm that is in Virtual Center?
Does the attached script work for you ?
You do need to have VMware Tools installed.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No, only partly.
FOr example:
VM is in Domain A
VM is in Domain B
VM is in Domain C
VM is in Workgroup A
VM is in Workgroup B
and so on.
So I thought with get-vm and a filter I can get all the powered on windows vms .
Now if I want read , execute or copy something inside the vm, then I need the domain of the vm, because I have to use credentials in a form of domainxy/userxy logic. At this step I get an array of get-vm and with it couldn't the active dirctory per adsi get the domain or workgroup of the vm?
So I thought it is like the function GetComputerNames and GetDomainNames ?
http://cyrusbuilt.net/wordpress/?p=104
But what happens if i only have rights to Domain A and B and C . Wouldn't the script then stop running, because no valid credentials for Domain C exists.
I'm not sure I understand that last question.
If you encounter a guest that is joined to a domain for which you have no account, then you can't use Invoke-VMScript since you have to give guest credentials.
But you should be able to capture that situation in the script before you actually call Invoke-VMScript and thus avoid a failing cmdlet.
Or did I get the question completely wrong ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
here is another example why script which calls wmi inside vm's will not work for several domains and workgroups because of the credentials
http://ict-freak.nl/2009/12/15/powercli-check-partition-alignment-windows-vms-only/
1.) I though I can do fowolling : from get-vm cmdlet get only the windows computers
2.) The list or array is then used for getting the domain of the computer
List Domain Information Using WMI ( I only need the part Wscript.Echo "Domain Name: " & objItem.DomainName)
http://gallery.technet.microsoft.com/ScriptCenter/en-us/fd6ef110-011f-4799-b923-59c35d0d52df
3.) Check if the user account is allowed to logon . This means to query administrators group if the user exist in this group. If it exist the script executes the wmi call
Did you think of using a local account to use the Invoke-VMScript cmdlet ?
Then you should be able to find the domain/workgroup from there.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference