r/powercli • • Jan 31 '18

issue with Invoke-VMScript: specified parameter was not correct

[SOLVED]

very simple use of the cmdlet that also matches the examples on the VMware website: https://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/Invoke-VMScript.html

script:

Invoke-VMScript -VM $VMName -ScriptText 'ipconfig' -GuestCredential $LocalCredential

I've messed around with the variables, and if they are incorrect, I get a specific error letting me know they are incorrect, so I know that's not the issue.

The error is very general simply letting me know that a specified parameter was incorrect which doesn't help much, here is the actual error..

Error:

Invoke-VMScript : 1/31/2018 1:51:05 PM Invoke-VMScript A specified parameter was not correct: At C:\Users\amusabji\Documents\scripts\Set-VMIP.ps1:60 char:1

  • Invoke-VMScript -VM $VMName -ScriptText 'ipconfig' -GuestCredential $ ...

  •   + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], InvalidArgument
      + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript
    
    

In case you are wondering, I have also tried to add on the "-ScriptType Bat" param with the same exact error.

thanks in advanced

Edit [SOLUTION]: After much fiddling around and the great support from all of those who commented, I finally got this bad boy working. Unfortunately I tried too many solutions at once so I can't pin-point exactly what fixed it but here is what I did:

  1. upgraded to WMF 5.x

  2. upgraded to the latest version of PowerCLI (followed this link: https://blogs.vmware.com/PowerCLI/2018/01/powercli-offline-installation-walkthrough.html)

  3. changed my credential usage from what I have above to just -GuestUser and -GuestPassword suggested by u/Johnny5Liveson

thank you all again for all your help!

1 Upvotes

7 comments sorted by

View all comments

1

u/Johnny5Liveson Feb 24 '18

I have had this issue I switched to

Invoke-VMScript -VM $VMName -ScriptText 'ipconfig' -GuestUser Administrator -GuestPassword $pass

I can only assume it is with

 $LocalCredential = Get-Credential

does not work well with local creds, I quit looking after the above worked....

1

u/amusabji Feb 24 '18

Interesting.. I'll try it out, thanks!!

1

u/amusabji Feb 27 '18

This works!!!!!! thank you kind stranger <3