?
Solved

Powershell / quest commandlets script that can remove certain subnets for AD sites and services

Posted on 2011-10-31
4
Medium Priority
?
1,333 Views
Last Modified: 2012-05-12
Powershell / quest commandlets script that can remove certain subnets for AD sites and services.  We are consolidating AD sites and services and do not want to manually have to do this.  We have many subnets.
0
Comment
Question by:mjm21
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:KenMcF
ID: 37058601
Here is one example to remove a single subnet of 10.0.0.0/32. If you have a text file you could read the text file on subnets and loop through to delete all.

Get-QADObject -SearchRoot "CN=Subnets,CN=Sites,CN=Configuration,DC=DEVLAB,DC=LOCAL"  -searchscope onelevel | Where {$_.Name -eq "10.0.0.0/32"} | remove qadobject
0
 

Author Comment

by:mjm21
ID: 37063970
thanks very much

If I have a csv how the script look like to pulll from the list and delete all?  I would appreciate it!
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 2000 total points
ID: 37064215
What format is the CSV file in?

If it is like this

Subnet,Mask
10.1.1.0,/24
192.168.1.0,/24

then do this




 
$Subnets = import-csv c:\subnets.csv
Foreach ($Subnet in $Subnets){
Get-QADObject -SearchRoot "CN=Subnets,CN=Sites,CN=Configuration,DC=DEVLAB,DC=LOCAL"  -searchscope onelevel | 
	Where {$_.Name -eq "$($Subnet.Subnet)$($Subnet.Mask)"} | remove qadobject
}

Open in new window

0
 

Author Comment

by:mjm21
ID: 37064977
awsome !  I will try.....thanks a lot
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question