Ended up working it out. Simple oversight on my part...I was stepping on my
own variables:

---------------------

ForEach ($Site in $Sites) {
 $SubnetName = $Site.subnet
 $Description = $Site.description
 $Site = $Site.site
 $Location = $Site.location

New-ADReplicationSubnet -Name $SubnetName -Site $ADSite -Description
$Description -Location $Location -PassThru

------------------------

Just had to change the name of the $Site variable to something else. Thanks
for chiming in guys.

- Sean

On Wed, Sep 28, 2016 at 2:57 PM, Michael B. Smith <[email protected]>
wrote:

> What is $Location.GetType().fullname ?? I’d guess it isn’t a system.string
> and it needs to be.
>
>
>
> *From:* [email protected] [mailto:listsadmin@lists.
> myitforum.com] *On Behalf Of *Sean Martin
> *Sent:* Wednesday, September 28, 2016 5:41 PM
> *To:* [email protected]
> *Subject:* [NTSysADM] Adding Subnets to Sites and Services via PowerShell
>
>
>
> I have a nagging issue with a script I recently put together to add a few
> hundred subnets to ADSS. The script simply imports a csv with four headers:
> Subnet, Description, Location, Site; builds the variables and then runs the
> following command:
>
>
>
> New-ADReplicationSubnet -Name $Subnet -Site $Site -Description
> $Description -Location $Location -PassThru
>
>
>
> When I run the script, the subnet is created successfully but the location
> field is blank. Our location fields are in the format: St/City/Location
>
>
>
> However, within powershell, if I manually populate the variables and run
> the same command, the location is added successfully.
>
>
>
> $Subnet = "1.1.1.0/24"$
>
> $Description = "Test Subnet"
>
> $Site = "SiteName"
>
> $Location = "AK/Anchorage/Test Subnet"
>
>
>
> New-ADReplicationSubnet -Name $Subnet -Site $Site -Description
> $Description -Location $Location -PassThru
>
>
>
> Is the data handled differently when importing from CSV? Do I need to
> include escape characters? I admittedly haven't done a ton of research yet,
> hoping this was an easy one that someone can assist with.
>

Reply via email to