Configuring Site System Servers and DPs with Powershell

I am attempting to create a bunch of Site System Servers and automation within PowerShell would be perfect with the new CMDLETS, but I'm getting an error in my tests.

I have a CSV File with System Name and it's new site code:

Win7-SCCM-Test,DP1

The system above is a Windows 7 x64 VM that's up and running and even has the SCCM 2012 agent installed and is reporting perfectly.

Here's the code I would like to use and eventually expand the CSV file to include the hundreds of systems that we'll need:

$csv_info = Import-Csv c:\scripts\test.csv -Header DPServerName,DPSiteCode

foreach ($line in $csv_info) {
	New-CMSiteSystemServer ServerName $line.DPServerName -SiteCode $line.DPSiteCode
}

I'm getting a PowerShell error at the ServerName parameter:

New-CMSiteSystemServer : Cannot validate argument on parameter 'ServerName'.
System.Management.Automation.ValidationMetadataException
At line:1 char:1
+ New-CMSiteSystemServer
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-CMSiteSystemServer], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ConfigurationManagement.Cmdlets.HS.Commands.N
   ewSiteSystemServerCommand

I'm learning powershell and I can't find anything meaningful as of yet to determine what I need to change to allow this parameter to pass.  

September 16th, 2013 8:54am


What happens if you run
New-CMSiteSystemServer ServerName "Insert_name_here" -SiteCode "insert_sitecode_here"
manually?
Free Windows Admin Tool Kit Click here and download it now
September 16th, 2013 9:15am


What happens if you run
New-CMSiteSystemServer ServerName "Insert_name_here" -SiteCode "insert_sitecode_here"
manu
September 16th, 2013 9:18am

I'm still beating myself up with this commandlet and I can't find any supporting documentation since it's a "fast publish".  

Free Windows Admin Tool Kit Click here and download it now
September 18th, 2013 7:35am

hello Lee,

have you try to use FQDN. Servername.domain

csv should look like:

DPServername,DPSiteCode
Win7-SCCM-Test.domain,DP1


Try something like this:

$csv_path      = "c:\scripts\test.csv"
$csv_import    = Import-Csv $csv_path

ForEach ($item In $csv_import)
{
    $DPServername=$item.DPServername
    $DPSiteCode=$item.DPSiteCode
    New-CMSiteSystemServer ServerName $DPServername -SiteCode $DPSiteCode
}


September 18th, 2013 10:10am

So the FQDN is helping, but I found another problem on my end.  I wasn't connecting to the site through the Configuration Manager which seemed to alleviate most errors as well.

Now, I have a site code problem.  When creating a Site Server, doesn't it need its own Site Code?  Unique?  I put in a unique 3 character value but it kept throwing errors.  So in desperation for testing the command, I used the primary site code.  That worked, but now it's showing its site code that is identical (PRI).  And I do not yet see it in the hierarchy manager.

I ultimately need to make this a Distribution Point, but I'm confused on the site code issue.


And Akusnir, thanks for the reconfigured script!  I may use a version of that in my next test run!


Free Windows Admin Tool Kit Click here and download it now
September 18th, 2013 10:32am

No for DP you dont have a site code only for Secondary, Priamry and Cas Site.

I you create the Site with New-Sitesystemserver you need Add-Distributionpoint to add an DP to this site!

  • Edited by Akusnir 20 hours 2 minutes ago
September 18th, 2013 11:04am

Okay, perfect.  Thanks so much!
Free Windows Admin Tool Kit Click here and download it now
September 18th, 2013 11:04am

your welcome.

Maybe if you have comlete this task.

post the script. Maybe others will use this also.

Have fun.

September 18th, 2013 11:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics