• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1384
  • Last Modified:

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

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
mjm21
Asked:
mjm21
  • 2
  • 2
1 Solution
 
KenMcFCommented:
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
 
mjm21Author Commented:
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
 
KenMcFCommented:
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
 
mjm21Author Commented:
awsome !  I will try.....thanks a lot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now