I am trying to invoke an AfterCreate script and at the moment I have added no logic in it, i just want to check if the script gets trigerred. But I am receiving the below error after account creation:
["sailpoint.connector.ConnectorException: Errors returned from IQService. Account creation rolledback due to partial success. Create operation is successful but post script execution failed : After script returned non zero exit code : 1 : "]
There is nothing special in the script, it is copied:
The service account already has permissions to edit the log file and I have disabled non TLS port on the IQservice configuration already. Account creation works fine one I remove this rule from the âNative Rulesâ config on the source.
Why you are seeing âAfter script returned non-zero exit code : 1â
The message means IQService did finish creating the account in Active Directory, but when it tried to launch the PowerShell file configured in Native Rules â AfterCreateScript, that script ended with an exit code other than 0.
IQService therefore rolls the provisioning back to avoid leaving the new AD object in an indeterminate state.
Because PowerShell sets its process exit code to 1 whenever an un-handled error is written to the error stream, even a single warning inside your script is enough to trigger this rollback. Your test file is already doing several things that commonly throw such errors:
Line
What might fail
Typical symptom
Import-Module ActiveDirectory
RSAT tools not installed, or the IQService service account does not have permission to load the module
The term âGet-ADUserâ is not recognized âŚ
Add-Type -Path "C:\SailPoint Files\IQService\Utils.dll" (and the second Add-Type utils.dll)
Typos in the path, 32-/64-bit mismatch, or the same assembly being loaded twice
Add-Type : Cannot add type. The type name already exists.
Using $env:Request
REQUEST is only present when IQService actually populates it; running the script from a normal PowerShell prompt leaves it $null, so StringReader throws
Exception calling âStringReaderâ with â1â argument(s): Value cannot be null.
Writing the log file
If the IQService Windows service account cannot create or append the file
Out-File : Access to the path ⌠is denied.
Any of the above will bubble up as an unhandled error â PowerShell sets $LASTEXITCODE = 1 â IQService interprets that as failure.
A quick way to prove the script is fired
Replace the entire file with just three lines and redeploy:
If the aftercreate_marker.log appears (and the task still rolls back), you know the script is launching but returning â 0.
If the file never appears, IQService isnât finding or executing the script at all (wrong path, wrong NativeRule name, or execution policy blocking).
Hardening the full script
Below is a minimal skeleton that safely loads SailPoint libraries, writes a log, and always ends with an explicit exit 0 unless a trapped error occurs. It shows exactly where to add your own logic later.
Forces any problem to jump into the catch block where you can log details and decide the exit code intentionally.
exit 0 / exit 1
Never rely on PowerShellâs implicit exit logic; IQService checks the native process exit code.
Import-Module ActiveDirectory inside try
If the module isnât present the script fails before touching AD objects, and you get a clear error in the log.
OneAdd-Type
Loading the same assembly twice throws a (non-terminating) warning that still yields exit-code 1 when $ErrorActionPreference is Stop.
Run the script by hand
In a PowerShell console on the IQService host, simulate IQService by setting $env:REQUEST = "<dummy/>"; .\AfterCreateScript.ps1 and watch for errors.
Common root causes & remedies
Symptom in IQService log
Likely root cause
Fix
Cannot load ActiveDirectory
RSAT tools missing on the IQService host, or the service account lacks module files in $env:PSModulePath
Install âActive Directory Domain Services and LDAP Toolsâ (RSAT) and restart the IQService service.
Access denied writing log
File ACL denies write to the service account (e.g., Local System or a dedicated AD account)
Grant Modify on the folder, or move logs to a location the account can write.
Execution policy error
Host still uses the default Restricted policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine (or sign the script).
Assembly already loaded
Duplicate Add-Type
Remove the second call or wrap it in `if (-not ([AppDomain]::CurrentDomain.GetAssemblies()
where {$_.GetName().Name -eq âUtilsâ})) { ⌠}`.
Next steps
Deploy the hardened template and watch the IQService debug log (iqservice-debug.log) plus your own AfterCreate_YYYYMMDD.log.
Once you consistently get exit 0, re-enable your real post-provisioning logic inside the marked section.
Remember that any non-zero exit code will cause IdentityIQ to roll back the AD account (delete it) and mark the provisioning task as Failed.
Following these guidelines will let you verify exactly when the script runs, capture a full error trail, and keep IQService satisfied with a clean exit code.
You logged in to IQService using your account and created PowerShell script, service account used in to connect IQService at SailPoint side is unable to execute the same script.
@KRM7 Ah no, there is no additional script, all the logic is in the AfterCreate Rule. The Svc Account that runs IQService is the same configured on the IQService Source and has Modify permissions on the IQservice folder.
ExecutionPolicy was set as Restricted which I enabled now and removed the second Add-type -path utils.dll; and the Script is now executed. However, I was wondering are there any further best practices for native rules? I will add the hardened rule mentioned above by @officialamitguptaa , thanks!