Hi All,
We have tried to invoke the PowerShell script through rule, it is creating the .ps1 file , but script is not getting executed.
If we try the same script from application connector Rule(native rule), it is working.
Any help will be appreciated!!.
Code snippet We are using to create the file :
FileCreationRule.xml
$value = New-Item -Path ‘\ServerPath\E$\test\testfile1112.emp’ -ItemType “File”;
$log.Debug(“exiting New-FileCreation”);
return $value;
code snippet to invoke the PowerShell script from rule:
String ruleName= "FileCreationRule";
Rule rules = context.getObject(Rule.class, ruleName);
Application ad = context.getObject(Application.class, "Active Directory");
List iqServiceConfig = ad.getAttributes().get("IQServiceConfiguration");
Map iqServiceConfigMap = iqServiceConfig.get(0);
String host = iqServiceConfigMap.get("IQServiceHost");
int port = Integer.parseInt(iqServiceConfigMap.get("IQServicePort"));
Map dataMap = new HashMap();
dataMap.put("postScript", rules);
dataMap.put("Application", ad.getAttributes());
RPCService service = new RPCService(host, port,false, false);
service.setConnectorServices(new sailpoint.connector.DefaultConnectorServices());
RpcRequest request = new RpcRequest("ScriptExecutor", "runAfterScript", dataMap);
RpcResponse response = service.execute(request);
if (response == null) {
return null;
}
if (response.getErrors() != null && response.getErrors().size() > 0) {
throw new IllegalStateException(response.getErrors().toString());
}
return response.toXml();
Thanks,
Prathyusha