![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Create a subnet in AD Hi, i don't manage to find an exemple of creating Subnet script. It's more special than creat just simple user, it's on the configuration partition so i'm not sure... If someone could help me I try to make a script which search subnettoo... Thanks ! -- P.A. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Create a subnet in AD Try this, for some odd reason I had to specifically set the DN, but I did and it worked... ############### function Add-ADSubnet{ Param($NetMask,$Site) $root = [ADSI]"LDAP://rootDSE" $conf = $root.configurationNamingContext $subnetcont = [ADSI]"LDAP://CN=Subnets,CN=Sites,$conf" $subnetcont.psbase.children $subnetobj = $subnetcont.create('subnet',"cn=$netmask") $subnetobj.put("siteObject","cn=$site,CN=Sites,$conf") $subnetobj.put("distinguishedName","CN=$netmask,CN=Subnets,CN=Sites,$conf") $subnetobj.setinfo() } Add-ADSubnet "10.10.10.0/23" -site "MySite" "BZP" <p.audonnet@xxxxxx> wrote in message news:1189764786.080205.264730@xxxxxx Quote: > Hi, i don't manage to find an exemple of creating Subnet script. > It's more special than creat just simple user, it's on the > configuration partition so i'm not sure... > If someone could help me I try to make a script which search subnet> too... > > Thanks ! > > -- > P.A. > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Create a subnet in AD I also tried to create it, I got stuck with the following (Your code outputs the same on my lab DC - W3K SP1) Exception calling "setinfo" with "0" argument(s): "A constraint violation occurred. (Exception from HRESULT: 0x8007202F )" At line:10 char:19 + $subnetobj.setinfo( <<<< ) Shay http://scriptolog.blogspot.com Quote: > Try this, for some odd reason I had to specifically set the DN, but I > did and it worked... > > ############### > function Add-ADSubnet{ > Param($NetMask,$Site) > $root = [ADSI]"LDAP://rootDSE" > $conf = $root.configurationNamingContext > $subnetcont = [ADSI]"LDAP://CN=Subnets,CN=Sites,$conf" > $subnetcont.psbase.children > $subnetobj = $subnetcont.create('subnet',"cn=$netmask") > $subnetobj.put("siteObject","cn=$site,CN=Sites,$conf") > > $subnetobj.put("distinguishedName","CN=$netmask,CN=Subnets,CN=Sites,$c > onf") > $subnetobj.setinfo() > } > Add-ADSubnet "10.10.10.0/23" -site "MySite" > > "BZP" <p.audonnet@xxxxxx> wrote in message > news:1189764786.080205.264730@xxxxxx > Quote: >> Hi, i don't manage to find an exemple of creating Subnet script. >> It's more special than creat just simple user, it's on the >> configuration partition so i'm not sure... >> If someone could help me I try to make a script which search>> subnet >> too... >> Thanks ! >> >> -- >> P.A. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Create a subnet in AD Odd.. I tried in both my Labs and in production Also.. you have to belogged as an Enterprise Admin. What happens if you Hardcode the LDAP paths $root = [ADSI]"LDAP://<SERVER>/rootDSE" "Shay Levi" <no@xxxxxx> wrote in message news:8766a94473128c9c50edad7e9a4@xxxxxx Quote: >I also tried to create it, I got stuck with the following (Your code >outputs the same > on my lab DC - W3K SP1) > > Exception calling "setinfo" with "0" argument(s): "A constraint violation > occurred. (Exception from HRESULT: 0x8007202F > )" > At line:10 char:19 > + $subnetobj.setinfo( <<<< ) > > > Shay > http://scriptolog.blogspot.com > > > Quote: >> Try this, for some odd reason I had to specifically set the DN, but I >> did and it worked... >> >> ############### >> function Add-ADSubnet{ >> Param($NetMask,$Site) >> $root = [ADSI]"LDAP://rootDSE" >> $conf = $root.configurationNamingContext >> $subnetcont = [ADSI]"LDAP://CN=Subnets,CN=Sites,$conf" >> $subnetcont.psbase.children >> $subnetobj = $subnetcont.create('subnet',"cn=$netmask") >> $subnetobj.put("siteObject","cn=$site,CN=Sites,$conf") >> >> $subnetobj.put("distinguishedName","CN=$netmask,CN=Subnets,CN=Sites,$c >> onf") >> $subnetobj.setinfo() >> } >> Add-ADSubnet "10.10.10.0/23" -site "MySite" >> >> "BZP" <p.audonnet@xxxxxx> wrote in message >> news:1189764786.080205.264730@xxxxxx >> Quote: >>> Hi, i don't manage to find an exemple of creating Subnet script. >>> It's more special than creat just simple user, it's on the >>> configuration partition so i'm not sure... >>> If someone could help me I try to make a script which search>>> subnet >>> too... >>> Thanks ! >>> >>> -- >>> P.A. > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Create a subnet in AD Like I said... You shouldn't need this line $subnetobj.put("distinguishedName","CN=$netmask.... What happens when you remove it. FYI: In all three tested environments I am using win2k3 SP2 "Shay Levi" <no@xxxxxx> wrote in message news:8766a944734f8c9c5168c2261e2@xxxxxx Quote: > Same error. > > Shay > http://scriptolog.blogspot.com > > > Quote: >> Odd.. I tried in both my Labs and in production Also.. you have to>> be logged as an Enterprise Admin. >> >> What happens if you Hardcode the LDAP paths >> $root = [ADSI]"LDAP://<SERVER>/rootDSE" >> "Shay Levi" <no@xxxxxx> wrote in message >> news:8766a94473128c9c50edad7e9a4@xxxxxx >> Quote: >>> I also tried to create it, I got stuck with the following (Your code >>> outputs the same >>> on my lab DC - W3K SP1) >>> Exception calling "setinfo" with "0" argument(s): "A constraint >>> violation >>> occurred. (Exception from HRESULT: 0x8007202F >>> )" >>> At line:10 char:19 >>> + $subnetobj.setinfo( <<<< ) >>> Shay >>> http://scriptolog.blogspot.com >>>> Try this, for some odd reason I had to specifically set the DN, but >>>> I did and it worked... >>>> >>>> ############### >>>> function Add-ADSubnet{ >>>> Param($NetMask,$Site) >>>> $root = [ADSI]"LDAP://rootDSE" >>>> $conf = $root.configurationNamingContext >>>> $subnetcont = [ADSI]"LDAP://CN=Subnets,CN=Sites,$conf" >>>> $subnetcont.psbase.children >>>> $subnetobj = $subnetcont.create('subnet',"cn=$netmask") >>>> $subnetobj.put("siteObject","cn=$site,CN=Sites,$conf") >>>> $subnetobj.put("distinguishedName","CN=$netmask,CN=Subnets,CN=Sites, >>>> $c >>>> onf") >>>> $subnetobj.setinfo() >>>> } >>>> Add-ADSubnet "10.10.10.0/23" -site "MySite" >>>> "BZP" <p.audonnet@xxxxxx> wrote in message >>>> news:1189764786.080205.264730@xxxxxx >>>>> Hi, i don't manage to find an exemple of creating Subnet script. >>>>> It's more special than creat just simple user, it's on the >>>>> configuration partition so i'm not sure... >>>>> If someone could help me I try to make a script which search>>>>> subnet >>>>> too... >>>>> Thanks ! >>>>> -- >>>>> P.A. > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Create a subnet in AD Same error. Shay http://scriptolog.blogspot.com Quote: > Odd.. I tried in both my Labs and in production Also.. you have to> be logged as an Enterprise Admin. > > What happens if you Hardcode the LDAP paths > $root = [ADSI]"LDAP://<SERVER>/rootDSE" > "Shay Levi" <no@xxxxxx> wrote in message > news:8766a94473128c9c50edad7e9a4@xxxxxx > Quote: >> I also tried to create it, I got stuck with the following (Your code >> outputs the same >> on my lab DC - W3K SP1) >> Exception calling "setinfo" with "0" argument(s): "A constraint >> violation >> occurred. (Exception from HRESULT: 0x8007202F >> )" >> At line:10 char:19 >> + $subnetobj.setinfo( <<<< ) >> Shay >> http://scriptolog.blogspot.com Quote: >>> Try this, for some odd reason I had to specifically set the DN, but >>> I did and it worked... >>> >>> ############### >>> function Add-ADSubnet{ >>> Param($NetMask,$Site) >>> $root = [ADSI]"LDAP://rootDSE" >>> $conf = $root.configurationNamingContext >>> $subnetcont = [ADSI]"LDAP://CN=Subnets,CN=Sites,$conf" >>> $subnetcont.psbase.children >>> $subnetobj = $subnetcont.create('subnet',"cn=$netmask") >>> $subnetobj.put("siteObject","cn=$site,CN=Sites,$conf") >>> $subnetobj.put("distinguishedName","CN=$netmask,CN=Subnets,CN=Sites, >>> $c >>> onf") >>> $subnetobj.setinfo() >>> } >>> Add-ADSubnet "10.10.10.0/23" -site "MySite" >>> "BZP" <p.audonnet@xxxxxx> wrote in message >>> news:1189764786.080205.264730@xxxxxx >>>> Hi, i don't manage to find an exemple of creating Subnet script. >>>> It's more special than creat just simple user, it's on the >>>> configuration partition so i'm not sure... >>>> If someone could help me I try to make a script which search>>>> subnet >>>> too... >>>> Thanks ! >>>> -- >>>> P.A. |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Create a subnet in AD I have one more place I can test it is Win2k3 SP1... I will post the results. "Brandon Shell" <tshell.mask@xxxxxx> wrote in message news:e75xhcu9HHA.1208@xxxxxx Quote: > Like I said... You shouldn't need this line > $subnetobj.put("distinguishedName","CN=$netmask.... > > What happens when you remove it. > > FYI: In all three tested environments I am using win2k3 SP2 > > "Shay Levi" <no@xxxxxx> wrote in message > news:8766a944734f8c9c5168c2261e2@xxxxxx Quote: >> Same error. >> >> Shay >> http://scriptolog.blogspot.com >> >> >> Quote: >>> Odd.. I tried in both my Labs and in production Also.. you have to>>> be logged as an Enterprise Admin. >>> >>> What happens if you Hardcode the LDAP paths >>> $root = [ADSI]"LDAP://<SERVER>/rootDSE" >>> "Shay Levi" <no@xxxxxx> wrote in message >>> news:8766a94473128c9c50edad7e9a4@xxxxxx >>> >>>> I also tried to create it, I got stuck with the following (Your code >>>> outputs the same >>>> on my lab DC - W3K SP1) >>>> Exception calling "setinfo" with "0" argument(s): "A constraint >>>> violation >>>> occurred. (Exception from HRESULT: 0x8007202F >>>> )" >>>> At line:10 char:19 >>>> + $subnetobj.setinfo( <<<< ) >>>> Shay >>>> http://scriptolog.blogspot.com >>>>> Try this, for some odd reason I had to specifically set the DN, but >>>>> I did and it worked... >>>>> >>>>> ############### >>>>> function Add-ADSubnet{ >>>>> Param($NetMask,$Site) >>>>> $root = [ADSI]"LDAP://rootDSE" >>>>> $conf = $root.configurationNamingContext >>>>> $subnetcont = [ADSI]"LDAP://CN=Subnets,CN=Sites,$conf" >>>>> $subnetcont.psbase.children >>>>> $subnetobj = $subnetcont.create('subnet',"cn=$netmask") >>>>> $subnetobj.put("siteObject","cn=$site,CN=Sites,$conf") >>>>> $subnetobj.put("distinguishedName","CN=$netmask,CN=Subnets,CN=Sites, >>>>> $c >>>>> onf") >>>>> $subnetobj.setinfo() >>>>> } >>>>> Add-ADSubnet "10.10.10.0/23" -site "MySite" >>>>> "BZP" <p.audonnet@xxxxxx> wrote in message >>>>> news:1189764786.080205.264730@xxxxxx >>>>>> Hi, i don't manage to find an exemple of creating Subnet script. >>>>>> It's more special than creat just simple user, it's on the >>>>>> configuration partition so i'm not sure... >>>>>> If someone could help me I try to make a script which search>>>>>> subnet >>>>>> too... >>>>>> Thanks ! >>>>>> -- >>>>>> P.A. >> |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Create a subnet in AD worked in my win2k3 SP1 environment as well. So I have test it in 3 SP2 and 1 SP1... they all work. Curious yours doesnt Shay. "Brandon Shell" <tshell.mask@xxxxxx> wrote in message news:uJfxHgu9HHA.5456@xxxxxx Quote: >I have one more place I can test it is Win2k3 SP1... I will post the >results. > > "Brandon Shell" <tshell.mask@xxxxxx> wrote in message > news:e75xhcu9HHA.1208@xxxxxx Quote: >> Like I said... You shouldn't need this line >> $subnetobj.put("distinguishedName","CN=$netmask.... >> >> What happens when you remove it. >> >> FYI: In all three tested environments I am using win2k3 SP2 >> >> "Shay Levi" <no@xxxxxx> wrote in message >> news:8766a944734f8c9c5168c2261e2@xxxxxx Quote: >>> Same error. >>> >>> Shay >>> http://scriptolog.blogspot.com >>> >>> >>> >>>> Odd.. I tried in both my Labs and in production Also.. you have to>>>> be logged as an Enterprise Admin. >>>> >>>> What happens if you Hardcode the LDAP paths >>>> $root = [ADSI]"LDAP://<SERVER>/rootDSE" >>>> "Shay Levi" <no@xxxxxx> wrote in message >>>> news:8766a94473128c9c50edad7e9a4@xxxxxx >>>> >>>>> I also tried to create it, I got stuck with the following (Your code >>>>> outputs the same >>>>> on my lab DC - W3K SP1) >>>>> Exception calling "setinfo" with "0" argument(s): "A constraint >>>>> violation >>>>> occurred. (Exception from HRESULT: 0x8007202F >>>>> )" >>>>> At line:10 char:19 >>>>> + $subnetobj.setinfo( <<<< ) >>>>> Shay >>>>> http://scriptolog.blogspot.com >>>>>> Try this, for some odd reason I had to specifically set the DN, but >>>>>> I did and it worked... >>>>>> >>>>>> ############### >>>>>> function Add-ADSubnet{ >>>>>> Param($NetMask,$Site) >>>>>> $root = [ADSI]"LDAP://rootDSE" >>>>>> $conf = $root.configurationNamingContext >>>>>> $subnetcont = [ADSI]"LDAP://CN=Subnets,CN=Sites,$conf" >>>>>> $subnetcont.psbase.children >>>>>> $subnetobj = $subnetcont.create('subnet',"cn=$netmask") >>>>>> $subnetobj.put("siteObject","cn=$site,CN=Sites,$conf") >>>>>> $subnetobj.put("distinguishedName","CN=$netmask,CN=Subnets,CN=Sites, >>>>>> $c >>>>>> onf") >>>>>> $subnetobj.setinfo() >>>>>> } >>>>>> Add-ADSubnet "10.10.10.0/23" -site "MySite" >>>>>> "BZP" <p.audonnet@xxxxxx> wrote in message >>>>>> news:1189764786.080205.264730@xxxxxx >>>>>>> Hi, i don't manage to find an exemple of creating Subnet script. >>>>>>> It's more special than creat just simple user, it's on the >>>>>>> configuration partition so i'm not sure... >>>>>>> If someone could help me I try to make a script which search>>>>>>> subnet >>>>>>> too... >>>>>>> Thanks ! >>>>>>> -- >>>>>>> P.A. >>> >>> |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Create a subnet in AD btw... I just looked at your error... that is because it actually verifies the IP/Mask fit try 10.0.0.0/24 "Shay Levi" <no@xxxxxx> wrote in message news:8766a944734f8c9c5168c2261e2@xxxxxx Quote: > Same error. > > Shay > http://scriptolog.blogspot.com > > > Quote: >> Odd.. I tried in both my Labs and in production Also.. you have to>> be logged as an Enterprise Admin. >> >> What happens if you Hardcode the LDAP paths >> $root = [ADSI]"LDAP://<SERVER>/rootDSE" >> "Shay Levi" <no@xxxxxx> wrote in message >> news:8766a94473128c9c50edad7e9a4@xxxxxx >> Quote: >>> I also tried to create it, I got stuck with the following (Your code >>> outputs the same >>> on my lab DC - W3K SP1) >>> Exception calling "setinfo" with "0" argument(s): "A constraint >>> violation >>> occurred. (Exception from HRESULT: 0x8007202F >>> )" >>> At line:10 char:19 >>> + $subnetobj.setinfo( <<<< ) >>> Shay >>> http://scriptolog.blogspot.com >>>> Try this, for some odd reason I had to specifically set the DN, but >>>> I did and it worked... >>>> >>>> ############### >>>> function Add-ADSubnet{ >>>> Param($NetMask,$Site) >>>> $root = [ADSI]"LDAP://rootDSE" >>>> $conf = $root.configurationNamingContext >>>> $subnetcont = [ADSI]"LDAP://CN=Subnets,CN=Sites,$conf" >>>> $subnetcont.psbase.children >>>> $subnetobj = $subnetcont.create('subnet',"cn=$netmask") >>>> $subnetobj.put("siteObject","cn=$site,CN=Sites,$conf") >>>> $subnetobj.put("distinguishedName","CN=$netmask,CN=Subnets,CN=Sites, >>>> $c >>>> onf") >>>> $subnetobj.setinfo() >>>> } >>>> Add-ADSubnet "10.10.10.0/23" -site "MySite" >>>> "BZP" <p.audonnet@xxxxxx> wrote in message >>>> news:1189764786.080205.264730@xxxxxx >>>>> Hi, i don't manage to find an exemple of creating Subnet script. >>>>> It's more special than creat just simple user, it's on the >>>>> configuration partition so i'm not sure... >>>>> If someone could help me I try to make a script which search>>>>> subnet >>>>> too... >>>>> Thanks ! >>>>> -- >>>>> P.A. > |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Create a subnet in AD After so rework.. this is a better solution function Add-ADSubnetObject{ Param($NetMask,$Site) $root = [ADSI]"LDAP://rootDSE" $conf = $root.configurationNamingContext $subnetcont = [ADSI]"LDAP://CN=Subnets,CN=Sites,$conf" $subnetobj = $subnetcont.create('subnet',"cn=$netmask") $subnetobj.put("siteObject","cn=$site,CN=Sites,$conf") $subnetobj.setinfo() } Add-ADSubnetObject -netmask "10.10.10.0/24" -site "MySite" "BZP" <p.audonnet@xxxxxx> wrote in message news:1189764786.080205.264730@xxxxxx Quote: > Hi, i don't manage to find an exemple of creating Subnet script. > It's more special than creat just simple user, it's on the > configuration partition so i'm not sure... > If someone could help me I try to make a script which search subnet> too... > > Thanks ! > > -- > P.A. > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Script to run only on a given subnet | VB Script | |||
| Windows browsing in an IP subnet with no DC | .NET General | |||
| Vista sharing and subnet | Vista networking & sharing | |||
| IPSec: IP-Rule with subnet | Vista networking & sharing | |||
| subnet problem | Vista networking & sharing | |||