locked
Object reference not set to an instance of an object Server 2016 RRS feed

  • Question

  • Hi guys,

    I'm running into an issue related to the VMware.PowerCLI module, I know it's VMware product, but I think my issue is Windows Server related.

    When I try to run the invoke-VMscript using PowerShell on windows server 2016 i get the following reply:

    Invoke-VMScript : 3/5/2018 11:11:43 AM	Invoke-VMScript		Object reference not set to an instance of an 
    object.	
    At line:37 char:17
    + ... iptresult = Invoke-VMScript -VM TestVM -ScriptText $command -GuestU ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], ViError
        + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DownloadFileFromGuest_DownloadError,VMware.Vim 
       Automation.ViCore.Cmdlets.Commands.InvokeVmScript

    While it works perfectly when I run the same command using PowerShell on Windows 10. 

    According to VMware, this module is compitable with Windows Server 2016 and Windows 10 as well:

    https://vdc-download.vmware.com/vmwb-repository/dcr-public/6a356389-4ad9-4f87-84f3-184881d48fe8/deeaba66-9019-4f0e-89b4-9f85173027b2/powercli1000-compat-matrix.html

    Here is the script:

    $vcserver = "vcenterserver.example.com" 
    $vmuser = "myvcenteruser" 
    $vmpassword = 'vcenterpassword'
    $vmprotocol = "HTTPS" 
    
    #connect to VirtualCenter with credentials
    get-viserver -server $vcserver -user $vmuser -password $vmpassword -Protocol $vmprotocol
     
    $command = "ifconfig"
    $guestuser = "rootuser"
    $guestpassword = 'rootpassword'
    $scriptresult = Invoke-VMScript -VM TestVM -ScriptText $command -GuestUser $guestuser -GuestPassword $guestpassword -ScriptType Bash 
    $scriptresult.ScriptOutput
    

    Is there anything blocking me from running it on Windows Server or is should be related to VMware?

    Thanks in Advanced

    Housam 


    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer". This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!

    Monday, March 5, 2018 10:33 AM

All replies

  • UPDATE:

    It turns out that the command is running on the target machine, but I'm not able to get the response back.

    And as I mentioned before, this issue is only when I'm running the script from Windows Server 2016, is there anything might be blocking the response?


    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer". This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!

    Monday, March 5, 2018 3:18 PM
  • This Question needs to be asked in a VMWare forum.


    \_(ツ)_/

    Monday, March 5, 2018 3:22 PM
  • I'm discussing this issue with them, but it seems that it's Windows Server related, there is something blocking the output from the VM back.


    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer". This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!

    Monday, March 5, 2018 3:53 PM
  • This is not a server repair forum.  You need to get a sever tech to help you troubleshoot this issue.


    \_(ツ)_/

    Monday, March 5, 2018 3:55 PM
  • Just for the record, this issue was related to PowerCLI version 10.0.0 and by downgrading to PowerCLI 6.5.4 problem was sloved!

    Regards,

    Housam


    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer". This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!

    • Proposed as answer by j0rt3g4 Monday, June 4, 2018 6:05 PM
    Monday, June 4, 2018 5:53 PM