• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Problem using EnableStatic to remotely set IP address

wwar1ace

New Member
Messages
4
#1
Hi all,
I'm attempting to update the network adapter config remotely for hundreds of machines from using DHCP to using new and statically assigned IP's. I've come up with the following script from reading others' posts, using Get-Member, and a little blind luck...

It works fine up until the point it sends the EnableStatic command, causing my script to hang. In fact, this line does its work ok on the remote machine. It successfully sets the IP and Subnet settings, and the remote machine works just fine after that. But *I think* in doing so, the network connection gets reset after the new settings are applied, causing my connection to the machine to be broken, and causing my script to just hang waiting for the result/response to come back and not move on to process the next host.

Is there a way to tell my script NOT to wait for the response and just proceed with the remainder of the script? Or is there another way I should be attempting to do this operation?


Thanks in advance.
-wwar1ace

===SCRIPT===
## Testing with a group of 10 machines:
## "host_info.csv" contains records with hostname, MAC, and myIP.
## All other values (cred, myGW, myDNS, mySUBNET) are set by an init script.

$hosts=Import-Csv "host_info.csv"

Foreach($machine in $hosts){
$LANs=(gwmi -Class Win32_NetworkAdapterConfiguration -Comp $machine.hostname -cred $cred)|where{$_.MACAddress -eq $machine.MAC}

Foreach($NIC in $LANs) {
"Set Gateways:"
$NIC.SetGateways($myGW)
"Turn OFF DNS Reg"
$NIC.SetDynamicDNSRegistration($false)
"Set DNS Server Order"
$NIC.SetDNSServerSearchOrder($myDNS)
"Enable Static IP:"
$NIC.EnableStatic($machine.myIP,$mySUBNET)
"Static Enabled"
}

}
===END SCRIPT===
 

My Computer

A

Al Dunbar

#2
"wwar1ace" <guest@xxxxxx-email.com> wrote in message
news:c0309762cb342f2d38f16fcf89be3c63@xxxxxx-gateway.com...

>
> Hi all,
> I'm attempting to update the network adapter config remotely for
> hundreds of machines from using DHCP to using new and statically
> assigned IP's.
Some would call that a step backwards. How are you planning on managing the
fixed IP's as machines are added and retired?

> I've come up with the following script from reading
> others' posts, using Get-Member, and a little blind luck...
>
> It works fine up until the point it sends the EnableStatic command,
> causing my script to hang. In fact, this line does its work ok on the
> remote machine. It successfully sets the IP and Subnet settings, and the
> remote machine works just fine after that. But *I think* in doing so,
> the network connection gets reset after the new settings are applied,
> causing my connection to the machine to be broken, and causing my script
> to just hang waiting for the result/response to come back and not move
> on to process the next host.
Seems the most likely cause of your script's problem...

> Is there a way to tell my script NOT to wait for the response and just
> proceed with the remainder of the script? Or is there another way I
> should be attempting to do this operation?


>
> Thanks in advance.
> -wwar1ace
>
> ===SCRIPT===
> ## Testing with a group of 10 machines:
> ## "host_info.csv" contains records with hostname, MAC, and myIP.
> ## All other values (cred, myGW, myDNS, mySUBNET) are set by an init
> script.
>
> $hosts=Import-Csv "host_info.csv"
>
> Foreach($machine in $hosts){
> $LANs=(gwmi -Class Win32_NetworkAdapterConfiguration -Comp
> $machine.hostname -cred $cred)|where{$_.MACAddress -eq $machine.MAC}
>
> Foreach($NIC in $LANs) {
> "Set Gateways:"
> $NIC.SetGateways($myGW)
> "Turn OFF DNS Reg"
> $NIC.SetDynamicDNSRegistration($false)
> "Set DNS Server Order"
> $NIC.SetDNSServerSearchOrder($myDNS)
> "Enable Static IP:"
> $NIC.EnableStatic($machine.myIP,$mySUBNET)
> "Static Enabled"
> }
>
> }
> ===END SCRIPT===
>
>
> --
> wwar1ace
 

My Computer

wwar1ace

New Member
Messages
4
#3
Quite true, in general... But there are reasons for it here. We run in a pretty complex environment (with a DHCP server AND registered IP's) that does not belong to us, meaning that the network infrastructure is not ours and we cannot manage it if something goes wrong with a server or other piece of network hardware. We've found it beneficial to have the IP info hardcoded on the machine for just these times.

Management during turnover is not an issue, as the machines have to be setup anyhow. But right now we're going through a change of subnets for entire buildings that are related to a major network upgrade there.

-wwar1ace

"wwar1ace" <guest@xxxxxx-email.com> wrote in message
news:c0309762cb342f2d38f16fcf89be3c63@xxxxxx-gateway.com...
>
> Hi all,
> I'm attempting to update the network adapter config remotely for
> hundreds of machines from using DHCP to using new and statically
> assigned IP's.
Some would call that a step backwards. How are you planning on managing the
fixed IP's as machines are added and retired?
 

My Computer

wwar1ace

New Member
Messages
4
#4
Yeah, I agree... but I would like to find out whether 1) I'm not doing something as I should be doing it, like some other option or switch I should be using or 2) the EnableStatic functionality is not fully developed in v1.0 and trying to use it on a remote machine causes my PS script to *break*.




"wwar1ace" <guest@xxxxxx-email.com> wrote in message
news:c0309762cb342f2d38f16fcf89be3c63@xxxxxx-gateway.com...


> ...But *I think* in doing so,
> the network connection gets reset after the new settings are applied,
> causing my connection to the machine to be broken, and causing my script
> to just hang waiting for the result/response to come back and not move
> on to process the next host.
Seems the most likely cause of your script's problem...
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)