This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to set Parameters in Scheduled Tasks wtih Powershell

Hi,

how can i set a Parameter for a Scheduled Task in ARS 6.5 with Powershell?

I added the parameters on the scheduled Task.

In the SDK is only a VBS HowTo (Topic "Specifying Parameters for Scheduled Tasks").

I tried it on different ways in Powershell:
---
$Task = Get-QADObject "<Scheduled Task>"
$Task.Parameters("NewName") = "Test123"
Error ParameterizedPropertyAssignmentFailed
---
$Task = Get-QADObject "<Scheduled Task>"
$Task.Put("NewName, "test123")
Error MethodNotFound
---

Regards
BEN


Parents
  • The above code wouldn't work for me in ARS 6.5. I've resorted to reading the edsaParameters value directly. The below code will create a $params object with properties on that object corresponding to the parameter names configured for the scheduled task. Access the parameters like this: $params.MyFirstParamater  $params.AnotherParameter

    #Read in the Parameters for the Task,

    #add them as properties on a $params object.

    $objTask = [ADSI]$Task.AdsPath

    $params = New-Object PSObject

    $objTask.edsaParameters| %{

        $xParameter=([xml]$_).DocumentElement

        Add-Member -InputObject $params NoteProperty $xParameter.Name $xParameter.'#text'

    }

Reply
  • The above code wouldn't work for me in ARS 6.5. I've resorted to reading the edsaParameters value directly. The below code will create a $params object with properties on that object corresponding to the parameter names configured for the scheduled task. Access the parameters like this: $params.MyFirstParamater  $params.AnotherParameter

    #Read in the Parameters for the Task,

    #add them as properties on a $params object.

    $objTask = [ADSI]$Task.AdsPath

    $params = New-Object PSObject

    $objTask.edsaParameters| %{

        $xParameter=([xml]$_).DocumentElement

        Add-Member -InputObject $params NoteProperty $xParameter.Name $xParameter.'#text'

    }

Children
No Data