Updating ARS scheduled task parameters with LDAPFilters in

Further to my post on doing this ( https://clan8blog.wordpress.com/2017/03/16/automating-ars-scheduled-task-parameters/) I realised that I’d left out one little trick, or two in getting and updating the scheduled task parameters:

  • The task parameters always get returned as strings so you need to convert these on the fly like this

if ( $debugLevel -eq ” ) { $defaultUsed = $true ; $debugLevel = 9 } else { $debugLevel = [int]$debugLevel }

  • A task parameter isn’t multivalued so you need to store these as comma separated strings and then convert in the script

if ( $emailAlert -eq ” ) { $defaultUsed = $true ; $emailAlert = $scriptOwner } else { $emailAlert = $emailAlert.split(“,”) }

Now you have another problem if you are using my method to upload any missing parameters as you can’t upload the array you just created! The solution is to convert it back to a comma separated string of course:  ’emailAlert’ = $($emailAlert -join “,”)

  • LDAPfilters will contain ampersands so you can’t store these in the scheduled task parameters, well you can but as with the email address example above, you need to do some conversions when you upload like this:   Convert the AMPERSANDS to “&” like this  ‘ldapFilter’     = $ldapFilter.Replace(“&”,”&”) and then upload

The reverse conversion happens automatically so no need to do a conversion.

Hope this helps

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.