Hi,
i am pretty new to power shell.
i am working with it to configure vmware machine.
the following code works:
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
PS C:\Users\nir.s> $object = Get-networkadapter -vm "windows_2008_#1"PS C:\Users\nir.s> $object
Name Type NetworkName MacAddress WakeOnLan
Enabled
---- ---- ----------- ---------- ---------
Network adapter 1 e1000 WAN and MGMT 00:50:56:09:00:22 True
Network adapter 2 e1000 Nirs Net 00:50:56:09:00:22 True
PS C:\Users\nir.s> Set-NetworkAdapter -networkadapter $object[1] -macaddress '00:50:56:09:00:42' -confirm:$false
Name Type NetworkName MacAddress WakeOnLan
Enabled
---- ---- ----------- ---------- ---------
Network adapter 2 e1000 Nirs Net 00:50:56:09:00:42 True
//////////////////////////////////////////////////////////////
but if i do the following it fail ( just use string variable $cc to hold the parameter)
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
PS C:\Users\nir.s> $cc = "-macaddress '00:50:56:09:00:43'"PS C:\Users\nir.s> PS C:\Users\nir.s> Set-NetworkAdapter -networkadapter $object[1] $cc -confirm:$false
Set-NetworkAdapter : A positional parameter cannot be found that accepts argument '-macaddress '00:50:56:09:00:43''.
At line:1 char:19
+ Set-NetworkAdapter <<<< -networkadapter $object[1] $cc -confirm:$false
+ CategoryInfo : InvalidArgument: (:) [Set-NetworkAdapter], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.SetNetworkAdapter
PS C:\Users\nir.s>
///////////////////////////////////////
Many thanks.
Nir