Blog Article: http://www.lazywinadmin.com/2013/11/powershell-add-ad-site-subnet.html

 

DESCRIPTION

This function allow you to add a subnet object in your active directory using ADSI

PARAMETERS

-Subnet <String>

Specifies the Name of the subnet to add

Required?                    true

Position?                    2

Default value

Accept pipeline input?       true (ByValue, ByPropertyName)

Accept wildcard characters?  false

 

-SiteName <String>

Specifies the Name of the Site where the subnet will be created

Required?                    true

Position?                    3

Default value

Accept pipeline input?       true (ByPropertyName)

Accept wildcard characters?  false

 

-Description <String>

 Specifies the Description of the subnet

Required?                    false

Position?                    named       

Default value

Accept pipeline input?       true (ByPropertyName)

Accept wildcard characters?  false

 

-location <String>       

Specifies the Location of the subnet

Required?                    false       

Position?                    named

Default value                       

Accept pipeline input?       true (ByPropertyName)       

Accept wildcard characters?  false

 

 

 

USING THE FUNCTION

 

  1. Download the file
  2. Unblock the file 
  3. Dot Source the file using the following method:
PowerShell
Edit|Remove
# Load the function in cache 
. .\Add-ADSubnet.ps1
 

 

 

EXAMPLE using a CSV File

 

PowerShell
Edit|Remove
Import-CSV .\Subnet.csv | Add-ADSubnet -verbose