Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell nesting help

$
0
0

I have the following code which works like a dream to find the relevant mac address and changes the network adapter name:

$macaddress = "%macaddress%"
$newname = "%networkname%"
$NicInterfaceName = get-wmiobject Win32_NetworkAdapter | where {$_.macaddress -eq "$macaddress"}
$NicInterfaceName.netconnectionid = "$newname"
$NicInterfaceName.put()

I want to make this code exist on one line, I know I could remove the variables, which obviously i'll do.

Help :)


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>