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
  • For whatever reason, I find teh VBS method to be much simpler -- but here's a sample section from a PowerShell Scheduled Task that we are running in ARS 6.7:

    All values (OverwriteFile, LogFilePath, LogFileName, Environment) are set via the GUI for the SchTask and read in at runtime...

    Just plop your "Work Code" after this section that reads in your parameters...

    Hope that helps you out...

    ---Clip---

    #Read in the Parameters for the Task
    $objTask = [ADSI]$Task.AdsPath
    $params = $objTask.InvokeGet("Parameters")

    $params | ForEach-Object -Process {
        if ($_.'Name' -eq "OverwriteFile")
        {
            $SetOverWritePolicy = [string]$_.'Value'
        }
        elseif ($_.'Name' -eq "LogFilePath")
        {
            $strLogFilePath = [string]$_.'Value'
        }
        elseif ($_.'Name' -eq "LogFileName")
        {
            $strLogFile = [string]$_.'Value'
            $strLogBackup = $strLogFile + "_backup"
        }
        elseif ($_.'Name' -eq "Environment")
        {
            $Environment = [string]$_.'Value'
        }
    }

    ---End---

Reply
  • For whatever reason, I find teh VBS method to be much simpler -- but here's a sample section from a PowerShell Scheduled Task that we are running in ARS 6.7:

    All values (OverwriteFile, LogFilePath, LogFileName, Environment) are set via the GUI for the SchTask and read in at runtime...

    Just plop your "Work Code" after this section that reads in your parameters...

    Hope that helps you out...

    ---Clip---

    #Read in the Parameters for the Task
    $objTask = [ADSI]$Task.AdsPath
    $params = $objTask.InvokeGet("Parameters")

    $params | ForEach-Object -Process {
        if ($_.'Name' -eq "OverwriteFile")
        {
            $SetOverWritePolicy = [string]$_.'Value'
        }
        elseif ($_.'Name' -eq "LogFilePath")
        {
            $strLogFilePath = [string]$_.'Value'
        }
        elseif ($_.'Name' -eq "LogFileName")
        {
            $strLogFile = [string]$_.'Value'
            $strLogBackup = $strLogFile + "_backup"
        }
        elseif ($_.'Name' -eq "Environment")
        {
            $Environment = [string]$_.'Value'
        }
    }

    ---End---

Children
No Data