- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Calling a Powershell Script from RSA
Hello,
Does anyone know how to call a .ps script from RSA AFX? The .ps script contains AD functions like get-ADUser , set-ADUser and the likes of it. Simply Importing the module with import-module and calling the function name doesn't connect with AD to get those functions. Is there anything I'm missing like opening a session with AD?
- Tags:
- Community Thread
- Discussion
- Forum Thread
- Identity G&L
- Identity Governance & Lifecycle
- IG&L
- IGL
- RSA Identity
- RSA Identity G&L
- RSA Identity Governance & Lifecycle
- RSA Identity Governance and Lifecycle
- RSA IGL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Do you see any error?
Can you post it here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
This is how I call the function test from RSA
Import-Module C:\abc\test.ps1 2>&1|Write-Host;
test 2>&1|Write-Host
After calling it shows 100% completed in RSA although there is no change in the End System.
This is the Actual Function that is being called in the End system.
Function test(){
Import-Module ActiveDirectory
$remlog ="C:\abc\remlog.log"
"Invoked">$remlog
$Users = Get-ADUser -Filter * -SearchBase "xxx" -Properties MemberOf >$remlog
$Users | Foreach-Object {
"Inside Loop">$remlog
$Groups = $_.MemberOf
foreach ($Group in $Groups) {
Remove-ADGroupMember $Group -Member $_ -Confirm:$true
}
"Outside">$remlog
}
"Final">$remlog
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
- Ensure the script works independently.
- Ensure you are not using relative paths. The scripts run by IGL are relative to the SSH server you are using.
- Check the SSH server logs or the logs generated by code for errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
- First of all make sure you have a SSHD server running on the target machine where you want to execute the powershell script. You can use Cigwin SSHD service for that.
- You will have to provide Host, Port, Timeout, LoginName and Password of the target machine in IG&L SSH Connector setting page.
- Then in the connector capability page, for whatever functionality you want to execute, you will have provide the Request body for the Command Code something like this
powershell.exe -InputFormat none -NoProfile -ExecutionPolicy Bypass -Command "exit <Absolute Path to your powershell script> -Param1 \"${Param1}\" -Param2 \"${Param2}\" "
In your case
<Absolute Path to your powershell script> should be C:\abc\test.ps1
Parameters are optional and implies only if your powershell script takes input parameters.
Note: Your powershell has a function, but there is no direct call to it in the code. You need to provide a call your test() function for it to be executed.
I hope this helps.
