SCCM Migration Change Site code EXE style
Ok so I'm in the middle of migrating a large side by side site to SCCM. I have a problem, a firewall is blocking the remote execution of the right click tools for change site code. This method uses a VB script an a WMI connection. but something is blocking it from running. So I figure I will out smart it and use a VB script to move the clients.
Well that would be great but again I have a problem with MacAfee, Proventia, or maybe even a GPO is blocking the remote execution of the vbscript. I included the Vbscript I use incase you wanted it.
So I ask the list if there is any other way of doing this. does anybody have an EXE that can do the job without using vbscript.
Trevor Sullivan jumped right on it and writes this quick little app that does exactly what I needed using C#.
Just advertise this to the machines that are giving you a hard time.
Remember that when you advertise a site code change you should only receive a status of running in your advertisement report. If you receive anything else the client wasn't moved. This is because the client, once moved, no longer sees the old site so you never receive a successful status. Just give it a little time and it should show up in the new console.
Attached to this blog is everything you need.
*********************************************
Just run:
AssignSiteCode.exe 123
Here is the code behind the EXE.
using System;
using System.Management;
namespace AssignConfigMgrClient
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("Invalid syntax");
Environment.Exit(10);
}
if (args[0].Length != 3)
{
Console.WriteLine("Invalid site code. Please use 3 digits");
Environment.Exit(20);
}
string[] clientargs = new string[1];
clientargs[0] = args[0];
ManagementClass mo = new ManagementClass(new ManagementPath(@"root\ccm:sms_client"));
mo.InvokeMethod("SetAssignedSite", clientargs);
}
}
}