Original Message:
Sent: Jun 14, 2023 05:49 AM
From: Keld Mollnitz
Subject: Issue with Running windows job - PowerShell script
I found the problem.
There was an error in TRAILER.WINDOWS which I corrected.
Original Message:
Sent: Jun 12, 2023 02:09 PM
From: Marilyn Singley
Subject: Issue with Running windows job - PowerShell script
Do you have the UC_EXT_INTERPRETERS_WINDOWS , UC_EXT_INTERPRETERS_UNIX in DIV_VARIABLES on Client 0 ?
EXAMPLE:
Key = POWERSHELL
Value1 = .ps1
Value2 = Powershell -File <FILE>
Then in the Job itself on the Process tab, call the Powershell interpreter:
:BEGIN_EXT_INT POWERSHELL
whatever the script is .ps1
:END_EXT_INT POWERSHELL
Original Message:
Sent: Jun 12, 2023 06:56 AM
From: Keld Mollnitz
Subject: Issue with Running windows job - PowerShell script
Hi @Kaj Wierda
I have similar issue with the following Powershell code:
[CmdletBinding()]
Param
(
[string]$BranchName = 'Test branch name'
)
Write-Host 'HELLO WORLD'
Write-Host $BranchName
It is working fine in V12.3.9, but not in 21.0.6. Can you explain that?
/Keld.
Original Message:
Sent: May 11, 2023 07:54 AM
From: Kaj Wierda
Subject: Issue with Running windows job - PowerShell script
This is not really an Automic issue, but rather interpreter behavior. Looks like your PowerShell script expects arguments to be passed in, as it starts with Param ( ...
Since you're not calling the script, but rather the actual PowerShell code this is not going to work.
Lets take this simple PowerShell example Sample1.ps:
Param (
[Parameter(Mandatory=$true)][string]$ip,
[Parameter(Mandatory=$true)][string]$port
Write-Host $ip
Write-Host $port
Normally you would run this using .\Sample1.ps -ip localhost -port 8080
In case you want to paste the PowerShell script into a JOBS object you would need to remove the Param section and explicitly define the values for the variables $ip and $port as in this Sample2.ps:
#Param (
#[Parameter(Mandatory=$true)][string]$ip,
#[Parameter(Mandatory=$true)][string]$port
#)
$ip = "localhost"
$port = "8080"
Write-Host $ip
Write-Host $port
Of course you can set the values using Automic variables vs hardcoding them.
Hope this clarifies it.
------------------------------
Kaj Wierda
Sr. Product Line Manager | Automation
Broadcom Software
Original Message:
Sent: May 09, 2023 10:46 AM
From: Shravan shetty
Subject: Issue with Running windows job - PowerShell script
Hi All,
we have a script that uploads files to a SharePoint site. Although we were unable to execute the script through Automic, we were able to test it successfully on the server by executing it directly in PowerShell ISE.
we created a Windows job, copy pasted script in process and executed it (Custom interpreter).
we are getting the following error -
Program 'UC4 Job Messenger' version '21.0.5+build.1675168838167' started
UCMDJP: *********************************************************************
UCMDJP: ** JOB 0000000000 (ProcID:0000006700) START AT 09.05.2023/09:39:30 **
UCMDJP: ** --------------------------------------------------------------- **
UCMDJP: ** USED: 0.000 CPU **
UCMDJP: *********************************************************************
Program 'UC4 Job Messenger' version '21.0.5+build.1675168838167' terminated normally
Disconnected from '127.0.0.1:2300' (socket handle = '1').
Param : The term 'Param' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At E:\Automic\Agents\Windows\temp\JALJAQEW.TXT.ps1:61 char:1
+ Param(
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (Param:String) [], CommandNotFou
ndException
+ FullyQualifiedErrorId : CommandNotFoundException
You cannot call a method on a null-valued expression.
At E:\Automic\Agents\Windows\temp\JALJAQEW.TXT.ps1:288 char:5
+ ÿÿÿ $FileStream.Close()
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Program 'UC4 Job Messenger' version '21.0.5+build.1675168838167' started
UCMDJP: *********************************************************************
UCMDJP: ** JOB 0000000000 (ProcID:0000006700) ENDED AT 09.05.2023/09:39:34 **
UCMDJP: ** --------------------------------------------------------------- **
UCMDJP: ** USED: 0.000 CPU **
UCMDJP: *********************************************************************
Program 'UC4 Job Messenger' version '21.0.5+build.1675168838167' terminated normally
Disconnected from '127.0.0.1:2300' (socket handle = '1').
Regards,
Shravan Shetty