Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Changing subnet mask only.

219 views
Skip to first unread message

guv

unread,
Mar 29, 2010, 11:10:25 AM3/29/10
to
I am using the below script to change the subnet mask of some computers, and
am using the enablestatic method from the Win32_NetworkAdapterConfiguration
class, but I only want to change the subnet mask and leave the IP address
the same as it is on the server. Does anyone know how I would setup the
parameters on the enablestatic method for changing subnet mask only on the
computer, or is there another method of doing this.

$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration `
| where{$_.IPEnabled -eq "TRUE"}
Foreach($NIC in $NICs) {
$NIC.EnableStatic("......


rkd

unread,
Mar 29, 2010, 2:36:06 PM3/29/10
to
Hi guv,

the docu states out the following syntax:
uint32 EnableStatic(
[in] string IPAddress[],
[in] string SubnetMask[]
);

Both paramters are arrays. so you should first get the ipaddress array and
store it in a variable and then define a subnet mask array and both pass to
the EnableStatic method. I think doing this by using WMI this could be the
right way.
It could be necessary you have to reboot the processed computer.
Reinhard

"guv" wrote:

> .
>

guv

unread,
Mar 30, 2010, 8:41:18 AM3/30/10
to
but i only want to change the subnet only and leave the ip address as it is
on the source machine. How would I write the syntax for that.
"rkd" <r...@discussions.microsoft.com> wrote in message
news:65D2F16F-1631-4899...@microsoft.com...

Chris Dent

unread,
Mar 31, 2010, 3:57:11 AM3/31/10
to

Use the original IP address array as Reinhard suggested.

For example:

$NIC = Get-WMIObject Win32_NetworkAdapterConfiguration -Filter
"IPEnabled='$True'"
$NIC.EnableStatic($NIC.IPAddress, @("255.255.242.0"))

Where 255.255.242.0 is the subnet mask. You may also consider pulling
the subnet mask array and only modifying the element you need (should
you have more than one IP address on the interface).

Chris

0 new messages