This function is part of my AADSites module, which can be downloaded here. For more info on the module see here.
To start the help files, I have chosen the function that has the most logic to deal with. Remove-AADsite has to deal with linked subnets, child objects such as servers including domain controllers.
If you have subnets associated to the site, remove-AADsite will warn you as such but offer -force:$true as an override
If you have child server objects (not DC's) within the site, remove-AADsite will warn you as such but offer -force:$true as an override
If you have child domain controller objects within the site, remove-AADsite will advise you to move the DC's out of the site before continuing. No override.
The -confirm:$false switch is availale to supress the confirm prompt.
To start the help files, I have chosen the function that has the most logic to deal with. Remove-AADsite has to deal with linked subnets, child objects such as servers including domain controllers.
If you have subnets associated to the site, remove-AADsite will warn you as such but offer -force:$true as an override
If you have child server objects (not DC's) within the site, remove-AADsite will warn you as such but offer -force:$true as an override
If you have child domain controller objects within the site, remove-AADsite will advise you to move the DC's out of the site before continuing. No override.
The -confirm:$false switch is availale to supress the confirm prompt.
NAME
Remove-AADsite
SYNOPSIS
Removes the AD site object that matches the name supplied
SYNTAX
Remove-AADsite [-Identity][[-force] ] [[-confirm] ] [ ]
DESCRIPTION
Removes the AD site object, if one exists, that matches the name given.
If there are configured domain controllers in the site, the site will not be removed.
If there are server objects in the site (that are not DC's), the command requires -force:$true option to remove the site.
If there are subnets associated with the site, the command requires -force:$true option to remove the site.
Returns True if the the site has been removed, False if not.
PARAMETERS
-Identity
Mandatory - The name of the object you want to remove.
Position 0.
-force
Optional - Set to true if you want to ignore warnings and remove the site
Position 1.
-confirm
Optional - Set to false if you want to remove the site without being
prompted
Position 2.
-------------------------- EXAMPLE 1 --------------------------
Simple usage
PS C:\> remove-AADSite -identity Sitename
-------------------------- EXAMPLE 2 --------------------------
Simple usage - remove a site without being prompted to confirm
PS C:\> remove-AADSite -identity Sitename -confirm:$false
-------------------------- EXAMPLE 3 --------------------------
Simple usage - force the removal of a site with associated subnets or non DC servers
PS C:\> remove-AADSite -identity Sitename -force:$true
Comments
Post a Comment