VMware Cloud Community
Squigglymonkey
Enthusiast
Enthusiast

trouble with invoke-script and -guestuser

I'm working on a script to apply some security settings. It is working on a vcenter(domain.local) that is in the same domain as the user account I use to run it and the systems it manages are also in the same domain(domain.local). I don't have to specify user/pass.
On another vcenter which is also in same domain  (domain.local) the systems that it manages are not in domain.local, but are in DMZdomain.local. I added my DMZ account to the invoke-vmscript, but it is still using the credentials for the session, my domain.local account.  What am  I doing wrong?

 

 

ForEach ($server in $servernames)
{
Invoke-VMScript -vm $server -scripttext $ScriptCF -GuestUser dmzdomain\dmz-user -guestpassword password13 -scripttype powershell
}

 

 

 

Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership

Does adding the Verbose switch provide any more information?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Squigglymonkey
Enthusiast
Enthusiast

No, just that is VERBOSE: performing the operation invoke-vmscript...... 

Reply
0 Kudos
LucD
Leadership
Leadership

Yup, the Verbose output for Invoke-VMScript is rather sparse.

You might want to give the same a try with my Invoke-VMScriptPlus function with the Verbose switch.
It should provide more information.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Tags (2)
Reply
0 Kudos
LucD
Leadership
Leadership

You did mention DMZ, is port 902 open to the ESXi node where the VM is running?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Squigglymonkey
Enthusiast
Enthusiast

Not sure on port 902. It looks like it is connecting, but it is getting access denied, because it is using an account that the system doesn't know.

I'm feeling like an idiot, I don't see what I am suppose to do with that code, I can't even find where Powercli is 'installed' it's not in C:\Windows\System32\WindowsPowerShell\v1.0\Modules, or in 'my documents' either. 

Reply
0 Kudos
LucD
Leadership
Leadership

Do a 

 

Get-Module -Name VMware* -ListAvailable

 

That should tell you where the PowerCLI modules are installed


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Squigglymonkey
Enthusiast
Enthusiast

I finally noticed the file download at the bottom of your page. I have that file now. 

I see that the modules are in c:\program files\windowspowershell\modules 

Do I put that file in one of the folders?

 

 

Reply
0 Kudos
LucD
Leadership
Leadership

The file you downloaded contains a function, named Invoke-VMScriptPlus.
The easiest way to use it is to copy that to a .ps1 file, and then at the end of that .ps1 file add a line, outside the function, where you call Invoke-VMScriptPlus.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos