The real advantage of this script is the ability it gives you to update your ADSS subnets quickly
#Import the Active Directory module
Import-Module ActiveDirectory -NoClobber -DisableNameChecking -Scope Local
#Import the CSV with headers
$csvData = Import-Csv -Path D:\powershell\input\subnets.csv
#Checks for any count and breaks if not $null
if(!($csvData.Count)){break}
#Loop through each row in the CSV
foreach ($row in $csvData) {
#Get the ADSS site name and subnet from the current row
$adssSiteName = $row.Site
$subnet = $row.Name
#Set up the remove first – remove ‘-whatif’ and/or ‘-confirm’ when ready
Remove-ADReplicationSubnet -WhatIf -ea Inquire -wa SilentlyContinue -infa SilentlyContinue -Credential (GetCredential) -Server “yourpdce” -Name “$subnet” -Site “$adssSiteName” -Verbose -Confirm
#Add the new subnet(s)
#We use this command to install subnet in ADSS per site
New-ADReplicationSubnet -WhatIf -ea Inquire -wa SilentlyContinue -infa SilentlyContinue -Credential (Get-Credential) -Server “yourpdce” -Name “$subnet” -Site “$adssSiteName” -Verbose -Confirm
}
NOTE: Remember, when you need a new command, or the script is not working at all, check you have the modules installed, imported and updated for the command and help files:
find-command New-ADReplicationSubnet
* When you right click and export subnets in %SystemRoot%\system32\dssite.msc you get "Site" for ADSS Site anme and "Name" for the subnetss. Also notice you get blanks, so you might want to sort before you use the file and clear the subnets with no site names.
** You did use my Set-PSCrednetial PS Script right, to set Credential, right? :)