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?
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.
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.
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"]}
"@
{"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