PowerShell script to create a SystemUser in Microsoft CRM 2011

I wanted to bulk create a bunch of users in CRM. PowerShell and the Microsoft CRM 2011 REST/OData endpoint make it easy. Here is a function to create a SystemUser via PowerShell

PARAM([string][ValidateSet("crmserver.company.com", "dev-crmserver.company.com")]$ServerName="crmserver.company.com",

$SystemUserInfo = @{
$assembly = [Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
$json=new-object System.Web.Script.Serialization.JavaScriptSerializer

$http_request = New-Object -ComObject Msxml2.XMLHTTP
$http_request.open('POST', $url, $false)
$http_request.setRequestHeader("Accept", "application/json")
$http_request.setRequestHeader("Content-Type", "application/json; charset=utf-8")
if ($MyDebug){
return $SystemUserId


5 Responses to PowerShell script to create a SystemUser in Microsoft CRM 2011

  1. John K July 8, 2014 at 5:24 pm #

    Are you passing the business unit id GUID as a string with hyphens? How are you getting the BU GUID? does that come off the BU link properties? I presume the BU logical name is “My Business Unit”?

  2. John K July 8, 2014 at 5:26 pm #

    Is a “SystemUser” just a CRM User?

  3. jbmurphy July 8, 2014 at 5:34 pm #


  4. jbmurphy July 8, 2014 at 5:41 pm #

    Yes hyphens. I looked at the existing users in the REWST view:

  5. Eddie August 18, 2015 at 2:51 pm #

    Hey jbmurphy, i am very interest in getting this working in my organization.. first, is it possble to management roles through your script? second, are all the variables pass in the command line; example
    CRM-CreateSystemUser “”john”,”thompson”. is businessunitid and systemuserdomain defined within the script, or command line? Thanks!

Powered by WordPress. Designed by WooThemes