Powershell ISE vs Powershell.exe

Hi Team,

We created a Powershell script using ISE and we are running it on a task scheduler via Powershell.exe

What happens is that if run the script on Powershell ISE we are able to retrieve the data from Sailpoint but if are going to run it via Powershell.exe it is not able to retrieve the data.

No error is found when we try the Powershell.exe.

Is there any import module or library that should be added on the Powershell script that we develop in the Powershell ISE for it to run the same way on Powershell.exe and gather the data that is needed?

Hope you can help me.

Thanks.

Including the script would help the community troubleshoot the issue

1 Like

@ABV11 Here are the two Powershell modules that are available. Try Looking here https://www.powershellgallery.com/

install-module -name SailPointIdentityNow

Install-Module -Name PSSailpoint

Can you post the specific error you’re getting?

Hi Ivan,

Good day.

The same output on the PowerShell ISE and is that one I am seeing as well on the PowerShell.exe. No errors found.

Hey @ABV11,

Will you please get the Task File for the scheduled task you are running? You can get the file from C:\Windows\System32\Tasks. Open the file in a Notepad and copy the contents, then paste in a comment here (be sure to remove any information you deem sensitive before posting).

If you prefer, you can just take screenshots of the Task and its configuration instead of posting the XML data.

The first thing I would like to check is the account which is utilized for executing the scheduled task. Perhaps the account does not have the required permissions or the Modules used in the script are not in the scope of that user/account.


As far as PowerShell and PowerShell ISE go, they are the same but ISE is just a lightweight IDE (ISE stands for Integrated Scripting Environment) specifically for PowerShell.

Hi Bryan,

In your scheduled task, do you have a specific account you are running the PowerShell as or are you using the generic “Network User” that doesn’t run under any specific person’s context? As far as importing or installing any modules, it would be relative to the commands you are using to call SailPoint. If you are using native “Invoke-ResetMethod” or “Invoke-WebRequest”, those will work regardless.

My initial guess would be the context of the executing user doesn’t have permissions or access to the data required to push the call.

Hi Guys,

Just got this error, I just removed the trackingid. what we are using is the V3/Search in PowerShell ISE and PowerShell.exe

Invoke-RestMethod : {“detailCode”:“400.1.3 Illegal value”,“trackingId”:" 123456",“messages”:[{“locale”:“en-US”,“localeOrigin”:“DEFAULT”,“text”:"Illegal value

I am trying to convert this query into strings

From:

$query = @"
{“query”:{“query”:"(@accounts(source.name:\“Sailpoint\”) AND created: [now-72h TO now]) OR (@accounts(source.name:\“Sailpoint\”) AND attributes.startDate:[2024-04-02 TO 2024-04-12]"},"indices":["identities"],"includeNested":false,"sort":[“displayName`”]}
"@

To:

$body = @"
{"query":{"query":"(@accounts(source.name:"', $source, '") AND created: [now-', $duration, 'h TO now]) OR (@accounts(source.name:"', $source, '") AND attributes.startDate:[', $dateNow, ' TO ', $dateLater, '])“},"indices”:["identities"],"includeNested":false,"sort":["displayName"]}
"@

$response = Invoke-RestMethod ‘https:/sailpoint.api.identitynow.com/v3/search/’ -Method ‘POST’ -Headers $headers -Body $query
$response | ConvertTo-Json

Not sure if this is the same issue as this one

@ABV11 you can use this body

{"query":{
        "query":"(@accounts(source.name:\"$source\") AND created: [now-72h TO now]) OR (@accounts(source.name:\"$source\") AND attributes.startDate:[$datenow TO $dateLater])"},
 "indices":["identities"],
 "includeNested":false,
 "sort":["displayName"]}
"@
type or paste code here

Please mark it as solution if it works