Jump to content


liquidcourage1

Create new Site Server as Distribution Point with Powershell

Recommended Posts

Is it possible to automate Site Server creation with PowerShell? I'm looking at creating Distribution Points at over 150 sites. Automating this would make it much faster and easier on everyone. My plan is to virtualize the servers and have them already staged at each site (Windows Server 2012, WDS and other pre-reqs already applied).

The goal is to run a script adding the server as a Site System and also making it a Distribution Point and possibly a Software Update Point as well.

Share this post


Link to post
Share on other sites

There is even a complete CMDLET for adding a new Distribution Point. Neil Peterson wrote a nice post about using that CMDLET: http://blogs.technet.com/b/neilp/archive/2013/03/23/at-long-last-add-cmdistributionpoint-powershell-cmdlet-included-in-configuration-manager-sp1-cu1.aspx

  • Like 1

Share this post


Link to post
Share on other sites

Okay... so I've starting testing this commandlet using PowerShell, but it's running into issues. I also have an open thread on TechNet, but no one has figured this out yet.

Here's the exact string of what's being entered and the error in PowerShell:

PS C:\Windows\system32> New-CMSiteSystemServer –ServerName "Win7-SCCM-Test" -SiteCode "DP1"
New-CMSiteSystemServer : Cannot validate argument on parameter 'ServerName'.
System.Management.Automation.ValidationMetadataException
At line:1 char:36
+ New-CMSiteSystemServer –ServerName "Win7-SCCM-Test" -SiteCode "DP1"
+                                    ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: ( [New-CMSiteSystemServer], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ConfigurationManagement.Cmdlets.HS.Commands.N
   ewSiteSystemServerCommand

So in essence, the parameter "ServerName" (which is a required parameter for obvious reasons) is failing for some reason and we can't figure it out. I'd like to be able to use this on a long list of servers that will become Site Servers and eventually Distribution Points/Software Update Points.

Share this post


Link to post
Share on other sites

So... the short story is that I have figured this out with some help on TechNet.

First of all, it's easier if you run PowerShell from the Configuration Manager Console as you can see in the picture below (source link here: http://cm12sdk.net/?page_id=1623) :

 

ConfigMgr_Console_2.png

Or insure that you're running ALL commands from the appropriate directory and then connect to the Primary or CAS server.

 

Type the following commands in PowerShell Console

  1. C:
  2. cd ‘.\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin’
  3. Import-Module .\ConfigurationManager.psd1
  4. Set-Location XXX:
  5. Now you are ready to manage your Configuration Manager infrastructure

 

Once you're in the right location, the server name input must be the FQDN if you want to mitigate errors. The SiteCode parameter needs to be based on your Primary site or secondary site code that the system will connect to.

 

So in my case I altered my code. The CSV format is here:

 

DPServerName,DPSiteCode

Server1, XX1

Server2, XX2

Server3, XX1

Code here:

$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
}

My next phase is to then use Powershell to do the same process and make them distribution and software update points. When I get a bit better at PowerShell, I'd like to integrate that step into this code as well.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.