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
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
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
Thank you very much LucD