there are a number of calls to:
Get-SCSMClass System.Domain.User$
You should create a variable of that and use that variable over, rather than call the cmdlet repeatedly.
Also, it may be faster to use the new-scsmobject cmdlet with -nocommit rather than the lines in 137-141:
$newChannel = new-scsmobject $endpointClass -nocommit -propertyhash @{ Id = "Notification.$guid" ChannelName = $CRM_Epost_ChannelName DisplayName = $CRM_Epost_DisplayName TargetAddress = $CRM_Epost_TargetAddress Description = $CRM_Epost_Description }
it may be quicker to use get-scsmobject rather than get-scsmincident. Something like this:
$ic = get-scsmclass Workitem.Incident$ ($Id_paa_sak = (get-scsmobject $ic -filter "Title -eq $CRM_Title").DisplayName
Or something like it (my test get-scsmobject returned in 39 Milliseconds, but get-scsmincident took 150 milliseconds)