Home Orchestrator

.net script with Powershell

Bostjan_CernjakBostjan_Cernjak Customer IT Monkey ✭

Hi,

Im trying to run just a basic runbook which grabs the string from the SR and do some magic in PS. When i run the script in ISE (with scorch account) it runs great, even if i try with step trought i completes, but when it is run auto it failes on .net script

I whent through many articles regarding powershell and orchestrator. Script is based on powershell bestpractices.


$DataBusInput1 = "\`d.T.~Ed/{613484C6-C7F4-41BB-B1CA-A388EC02C929}.{23AF8698-5852-4AC3-B8E6-529135D1D6F0}\`d.T.~Ed/"

$DataBusInput2 = "\`d.T.~Vb/{FE4626E4-3EAB-47CF-ACD0-64C3AAB9E86F}\`d.T.~Vb/"

#-----------------------------------------------------------------------

## Initialize result and trace variables

# $ResultStatus provides basic success/failed indicator

# $ErrorMessage captures any error text generated by script

# $Trace is used to record a running log of actions

$ResultStatus = ""

$ErrorMessage = ""

$Trace = (Get-Date).ToString() + "`t" + "Runbook activity script started" + " `r`n"

# Create argument array for passing data bus inputs to the external script session

$argsArray = @()

$argsArray += $DataBusInput1

$argsArray += $DataBusInput2


# Establish an external session (to localhost) to ensure 64bit PowerShell runtime using the latest version of PowerShell installed on the runbook server

# Use this session to perform all work to ensure latest PowerShell features and behavior available

$Session = New-PSSession -ComputerName $env:COMPUTERNAME -Authentication Default -EnableNetworkAccess


# Invoke-Command used to start the script in the external session. Variables returned by script are then stored in the $ReturnArray variable

$ReturnArray = Invoke-Command -Session $Session -Argumentlist $argsArray -ScriptBlock {


I also could not find the Powershell IP 1.2 anywhere.


Thanks anyone/everyone for the help

Bostjan

Answers

  • Peter_MiklianPeter_Miklian Customer Advanced IT Monkey ✭✭✭
    edited April 8

    @Bostjan_Cernjak try to using Try-Catch expression to show the error as @Stefan_Horz suggested in in this Forum?

    Did you check the ExecutionPolicy?

    I'd guess PS ISE could be using higher PS version than Orchestrator. Maybe some investigation in this direction could help?

    $host | Out-File c:\PS-version.txt -Append
    
Sign In or Register to comment.