Categories
Uncategorized

Workrite quick and dirty user creation from AD when you already have SSO

This is ugly but it’ll get you started, there are definitely better ways. User creation script for https://www.workrite.co.uk

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12



$Workriteuser="{workrite username}"
$WorkritePW="{workrite password}"
$WorkriteID="{workrite ID}"

$BaseOUS="OU=SomeOU,DC=domainname,DC=co,DC=uk”,"OU=SomeOtherOU,DC=domainname,DC=co,DC=uk"

$BaseOUS| ForEach-Object{

	get-aduser -properties mail,employeenumber -searchbase $_ -filter {enabled -eq "True" -and emailaddress -like "*@domainname.co.uk"} -resultsetsize 10000 | foreach-object {

	
	$mailaddress = $_.mail
	$firstname = $_.givenname
	$surname = $_.surname
	$employeeid = $_.employeenumber


	$url="https://app.workrite.co.uk/services/wr_service.asmx/CreateUserIncEmployeeId?coWsId=$WorkriteID&coLogin=$Workriteuser&coPassword=$WorkritePW&emailAddress=${mailaddress}&firstName=${firstname}&surname=${surname}&role=Student&facilitator=false&places=WholeCollege,Member&employeeId=${employeeid}&templateName="

	
	$url = $url -replace '\s',''


	[xml]$output = Invoke-WebRequest "$url"
		
		#API response 13 duplicate username
		if ($output.int."#text" -eq "13")
		{
			Write-Host "User $mailaddress already exists"
		}
		#API Response 0 success
		elseif ($output.int."#text" -eq "0")
		{
			Write-Host "User $mailaddress successfully created"
		}
	}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s