Powershell issue with execute script

Hi, I am facing one issue with powershell api call. Here is the use case - I have written one ps script where I am calling Sailpoint API. I have scheduled this ps script in windows task scheduler. When task scheduler tries to execute it on its scheduled time, it prompt one pop up window with message -

"Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
‘PSGallery’?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is “N”):

here it will wait until I manually type A and once I enter A, it will display below message -

WARNING: Version ‘1.0.2’ of module ‘PSYaml’ is already installed at ‘C:\Program Files\WindowsPowerShell\Modules\PSYaml\1.0.2’. To reinstall this version ‘1.0.2’, run Install-Module or Updated-Module cmdlet with the -Force parameter.

After this message, scheduled script run successfully.

here is config from scheduler -

PS version:
Name Value


PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

So I am not getting why this pop up message appear all the time. Could you please suggestion to fix this pop up message permanently so that script will run automatically.

@tyler_mairose @dmbrown1386 @darrenjrobinson

What version of PSSailpoint is installed on that machine? Because I don’t even have PSYaml installed on my machine. I would assume it’s no longer needed because the PSSailpoint module no longer reads your client creds from the config yaml file generated from the sdk

You can find what version(s) you have installed by running

Get-Module PSSailpoint

You should only need to install the module once. Your script doesn’t need to install the module every time it runs.

Hello @hranjan3,

I was able to get this working on my machine.

I installed the PSSailPoint module from an administrative PowerShell 7 session and made sure that my clientID, clientSecret and base url were set in environment variables. Once I installed it, it never asked me again to install anything.

Did you install the module for all users?

@tyler_mairose does the latest version even leverage PSYaml? It looks to me like OP might have an older version installed that’s trying to pull client creds from the config.yaml file in the user’s home directory.

@mcheek It is still in there if you had the original sailpoint/config.yaml configuration. If you don’t use that old yaml file that piece of code will never get hit and won’t complain the cmdlet doesn’t exist.

I do need to remove that out of there as yaml and PowerShell don’t like each other very much, the other configuration options are definitely preferred.

Hs your script got import-module … or have you mistakenly left in install-module …?

Hi All,

I followed these steps to verify modules installed:

as I mentioned earlier manually I am able to run PS scripts but task scheduler has issue.

Could you please suggest fix for this issue.

There are multiple locations for PowerShell modules depending on the version of PowerShell you are running, plus System and User specific directories as well. You can check your current Module locations by running $env:PSModulePath.Split(';') to output those directories in an easy to read list. Looks like you running PowerShell version 7 from Task Scheduler, but the directory you showed is for WindowsPowerShell. Copying that PSSailPiont directory to C:\Program Files\PowerShell\Modules may be easiest fix.

Are you running the Task Scheduler under the context of a different user than the account you used to develop and test the scripts? If so it is likely that in that different user context the same dependencies aren’t met.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.