Hello! This is my first time posting something on this forum, if i do break any rule of conduct by accident please let me know.
I have an issue where I'm trying to pass PowerCLI cmdlets through a powershell session. The session is initiated by a 3rd party program called "ActiveXpert network monitor" and it happens whenever a specific criteria is true (like my local machines CPU usage is too high or something).
Whenever a criteria is fullfilled, ActiveXpert starts an Action response and starts up a powershell.exe interpreter and executes the code below:
Start-Transcript -Path "C:\Windows\System32\WindowsPowerShell\v1.0\Log.txt" <-- used for logging
Set-Location "C:\ProgramData\ActiveXperts\Network Monitor\Scripts" <-- script location where pwshell will look
icacls "C:\ProgramData\ActiveXperts\Network Monitor\Scripts\Action (ps1)\temp.xml" /grant "NT AUTHORITY\SYSTEM:(F)" <-- granting user account SYSTEM full access to a credentialsfile
$CredFile =Get-VICredentialStoreItem -File C:\ProgramData\ActiveXperts\Network Monitor\Scripts\Action (ps1)\temp.xml <-- retrieves it from specified path
$hosts =$CredFile.Host Hosts name
$user =$CredFile.User Name for User accessing the host
$pass =$CredFile.Password Password for User accessing the host
Connect-VIServer -Server $hosts -User $user -Password $pass <-- passing credentials retrieved
Start-VM -VM "random VM name" <-- starting up specific VM name
Disconnect-VIServer -Confirm:$false <-- disconnecting from server host without prompts
Stop-Transcript <-- stops all logging
The script essentially uses installed PowerCLI module cmdlets to pass through in Powershell (because the ActiveXpert program can only initiate Powershell or Visual Studio or Windows Batch File).
So what's the issue? Well if you start up a powershell session and execute the script above in the shell, it works fine. But executing the same script from Activexpert, that is starting it's own powershell session and executing the script in it, generates an error saying "Get-VICredentialStoreItem: the specified path does not exist" even though it's fully fleshed out in the script. I'm running PowerCLI modules version 13.2 which should be compatible with my ESXI hosts that's at least version 6.7 and I'm also running 5.1 powershell version.
Other than setting executionpolicies to unrestricted and trying to add an enviroment variable for it to look in, I can't think of anything else. Does this issue seem familliar? If so what are your suggesstions?