VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Invoke-VMScript : A positional parameter cannot be found that accepts argument 'Host; E={AURPP02}}'.

Hi,

I am unable get the output from below script

connect-viserver 10.10.10.6

$computers = Get-Content "C:\2_DNS_Change\Shared_Apps.txt"

Foreach($computer in $computers)

{

Invoke-VMScript -vm $computer -ScriptText "Get-Netadapter | Select Name, @{N="Host"; E={$env:computername}}" -ScriptType PowerShell -GuestUser admin -GuestPassword "p@ssw123"

}

Error

Invoke-VMScript : A positional parameter cannot be found that accepts argument 'Host; E={AURPP02}}'.

At C:\DR\2.ps1:5 char:1

+ Invoke-VMScript -vm $computer -ScriptText "Get-Netadapter | Select Na ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Invoke-VMScript], ParameterBindingException

    + FullyQualifiedErrorId : PositionalParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That is due to the quotes you used.
Use single quotes around the Name string

Invoke-VMScript -vm $computer -ScriptText "Get-Netadapter | Select Name, @{N='Host'; E={$env:computername}}" -ScriptType PowerShell -GuestUser admin -GuestPassword "p@ssw123"

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

That is due to the quotes you used.
Use single quotes around the Name string

Invoke-VMScript -vm $computer -ScriptText "Get-Netadapter | Select Name, @{N='Host'; E={$env:computername}}" -ScriptType PowerShell -GuestUser admin -GuestPassword "p@ssw123"

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you very much LucD Smiley Happy

Reply
0 Kudos