hi friends
i am creating a powershell script which performs many customization which one of them is setting ip address on my only network adapter which its default name is Ethernet in windows server 2012.
(note: i do know there are new cmdlet to do this easily in PS 4.0, but i need to perform that via wim methods so that i be able to run that script on my win 2008 server as well), so i need something to work in both PS 2.0 & 4.0
its about 3 hours i am struggling with codes but encounter different errors.
because in get-wmiobject win32_networkAadapterconfiguration command, we don't have "NetConnectionID" which refers to displayname of the network adaptor, we cannot refer to that network adaptor directly in win32_networkAadapterconfiguration command.
so after verifying , i found that index property exist in both win32_networkAadapter & win32_networkAadapterconfiguration commands via which i can reach what ia want
i have to first create a $NIC variable using win32_networkAadapter & then use it in 2nd command on the basis of index, but i end up with the following error.
where i am wrong in the code? any help please
thanks in advanced