0

I have an SSIS package performing a refresh process for SQL Server. This process needs to perform certain queries under a different credential set than the one running the package. I've created a set of PowerShell scripts to handle requisite tasks, RefreshMaster.ps1 that calls GrantPerms.ps1.

GrantPerms.ps1 uses the CredentialManager module cmdlet Get-StoredCredential to retrieve the requisite credential set, necessary for a specified task. The module is installed on the c:\Program Files\WindowsPowerShell\Modules directory, which is included in the environmental variable PSModulePath. I used the following command to import the module for all users.

Import-Module CredentialManager

When I run Get-Module -ListAvailable , I see the module listed as Binary, Ver 2.0. When I run RefreshMaster.ps1 from PowerShell, everything works as it should, and yes I've tested to make sure the correct credentials are picked up and passed. However, when I call RefreshMaster.ps1 from SSIS, though an Execute Process task, I get an error:

The term 'Get-StoredCredential' is not recognized as the name of a cmdlet, function, script, file, or operable program.

Example Code:

#RefreshMaster.ps1
# Call GetCreds script
    $ScriptBlock = [ScriptBlock]::Create("\\MyServer\MyShare\GetCreds.ps1") 
    Invoke-Command -ScriptBlock $ScriptBlock | Out-Null


#GetCreds.ps1
# retrieve credentials from Windows Credetial Manager
    $storedCreds=Get-StoredCredential -Target 'MyCreds' -AsCredentialObject 

I can't seem to figure out how to get this to run properly from SSIS. All the rest of the code seems to run fine except for this call out to Get-StoredCredentials. Help please!

Steve Mangiameli
  • 688
  • 7
  • 15

1 Answers1

0

I installed the module at C:\Users\MyLogin\Documents\WindowsPowerShell\Modules and executed the package. It executed successfully without error. While this is an acceptable short term solution to the problem, I'd really like to understand why the module is not discover-able in any of the locations specified by PSModulePath.

Steve Mangiameli
  • 688
  • 7
  • 15