I have a txt file that looks like this
PC1 192.168.0.2
PC2 192.168.0.3
PC3 192.168.0.4
I would like to change computers ip addresses based on that list, so it will fill up the computer name and the ip address and process them all without manually changing the values, and I'm having issues getting this to work "still learning powershell"
$wmi = Get-WmiObject -ComputerName ??? win32_networkadapterconfiguration -filter "ipenabled = 'true'"
$wmi.SetGateways("192.168.0.1", 1)
$wmi.EnableStatic("?????", "255.255.255.0")
any help on that?
Best Answer
If your txt file is just a space-separated list of
[computername] [ip-address]
, you can use theImport-Csv
cmdlet: