Powershell Variables - Workflow Automation

Hi. 

I am looking to move some scripts over to ARS to run as a scheduled task. If we run this manually we are asked to select a location value which then maps to the correct CSV file in a specified location. 

Whats the best way of passing a value to the script at run time? I assume it would be four scheduled tasks based on how many locations we need to use? 

Thanks in advance 

function Run-Active-Roles ($Request)
{

Import-OneDrive_URL

}

function Import-OneDrive_URL {   
    param (   
        $AzureLocation = (Read-Host -Prompt 'Enter Azure location. GBR or CHE or APC or NAM')   
)

#Import CSV
$CSVImport = "C:\ARS-Scripts\_OneDrive_Export\$AzureLocation-OneDrive-for-Business-Users.csv"

Connect-QADService -Service "ARS.FQDN_HERE" -Proxy
Import-Csv $CSVImport | ForEach-Object {

$CurrentUser = [string]$_.UserName
$OneDriveSiteUrlContents = [string]$_.OneDriveSiteUrl

$TargetUser = Get-QADUser -LdapFilter "(userprincipalname=$CurrentUser)" | select -expandproperty DN

Set-QADUser -Identity $TargetUser -ObjectAttributes @{"ARS_VA_NAME_HERE"=$OneDriveSiteUrlContents}
    }
}

Parents
  • Have a look at Parameters under Workflow Options and Start Conditions.  Here you can either prompt the user for the parameter or use a script to supply it.

    So let's say you setup a single value string parameter "Input File".

    In the script being run by the workflow, you would get the contents of this parameter thus:

    Import-CSV $Workflow.Parameter("Input File")

Reply
  • Have a look at Parameters under Workflow Options and Start Conditions.  Here you can either prompt the user for the parameter or use a script to supply it.

    So let's say you setup a single value string parameter "Input File".

    In the script being run by the workflow, you would get the contents of this parameter thus:

    Import-CSV $Workflow.Parameter("Input File")

Children
No Data