Automation

 View Only
  • 1.  trouble with invoke-script and -guestuser

    Posted May 03, 2023 06:53 PM

    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
    }

     

     

     



  • 2.  RE: trouble with invoke-script and -guestuser

    Posted May 03, 2023 07:14 PM

    Does adding the Verbose switch provide any more information?



  • 3.  RE: trouble with invoke-script and -guestuser

    Posted May 03, 2023 07:28 PM

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



  • 4.  RE: trouble with invoke-script and -guestuser

    Posted May 03, 2023 07:35 PM

    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.



  • 5.  RE: trouble with invoke-script and -guestuser

    Posted May 03, 2023 07:36 PM

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



  • 6.  RE: trouble with invoke-script and -guestuser

    Posted May 03, 2023 08:04 PM

    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. 



  • 7.  RE: trouble with invoke-script and -guestuser

    Posted May 03, 2023 08:29 PM

    Do a 

     

    Get-Module -Name VMware* -ListAvailable

     

    That should tell you where the PowerCLI modules are installed



  • 8.  RE: trouble with invoke-script and -guestuser

    Posted May 03, 2023 08:53 PM

    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?

     

     



  • 9.  RE: trouble with invoke-script and -guestuser

    Posted May 03, 2023 08:58 PM

    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.