Jump to content
Sign in to follow this  
ulfwil

ANSWERED Call Powershell Scripts From Ecr

Recommended Posts

Hi, 


Is there anyone having experience from calling Powershell scripts from with in an ECR?


I think it's a good idé to use powershell for easy things, rarely used. (I can understand if someone has comments on that statement)


 


My script is for example like this - to set Ulf Wilhelmsson to DND status


------------------------


try {

  import-module ippbx

  connect-ippbx -ServerName localhost -UseIpPbxLogin -CredentialsFile  "C:\Program Files (x86)\SwyxWare\IpPbxLogin.xml"

  Set-IpPbxUserPresenceState -UserEntry $(Get-IpPbxUser -UserName 'Ulf Wilhelmsson') -IsAway:$false -IsDND:$true

} catch {

  "Error in Set-IpPbxUserPresenceStatet $error ($?)"|out-file -Filepath  ... 

}

------------------------

 Works all right if run from GUI, but when called from ECR I got the following error 


 


"Error in Set-IpPbxUserPresenceStatet The variable '$Global:IpPbxServer' cannot be retrieved because it has not been set. "


 


So as far as I understand is the connect-ippbx statement not rising any error but the result of the operation seems not to work


The user credentials in the IpPbxLogin.xml have Administration rights.


 


The code in the ECR script looks like this.


----------------------------------------


strCommand = "Powershell.exe -executionpolicy remotesigned -windowstyle hidden -File " & strFullName 

PBXScriptOutputTrace "[uWDEBUG] " & strCommand

 

Set WshShell = CreateObject("WScript.Shell")

returnval = WshShell.Run(strCommand,0, true)

----------------------------------------


 


Anyone having any idéa?

Share this post


Link to post
Share on other sites

The reason might be this one: The credentials file created with Export-IpPbxCredential is Windows user specific. When you call powershell.exe from the ECR script it runs with the same account as the SwyxServer service. If you created the credential file with another account it cannot be decrypted later on from the service account user. 


Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.