Directives from a Director (MSP)

Powershell: AutoTask – Get Picklist Values

When using AutoTask’s API it’s required to lookup a various amount of picklist values that are used in updating you’re web request. This is a powershell way to pull those picklist values. The first part of the script validates your AT URI, the second part gets the entity data, in this case I was looking for “ticket” related fields.

Edit: Updated to give a more friendly output

# Username and password for Autotask
$ATurl = ""
$ATusername = "{AT Username}"
$ATpassword = ConvertTo-SecureString "{AT Password}" -AsPlainText -Force
$ATcredentials = New-Object System.Management.Automation.PSCredential($ATusername,$ATpassword)

$atws = New-WebServiceProxy -URI $ATurl -Credential $ATcredentials
$zoneInfo = $atws.getZoneInfo($ATusername)
$ATurl = $zoneInfo.URL.Replace(".asmx",".wsdl")
$atws = New-WebServiceProxy -URI $ATurl -Credential $ATcredentials
$entity= $atws.getFieldInfo("Ticket")
foreach ($picklist in $entity) {
	$picklist | select Name,Label,Description | ft
	foreach ($values in $picklist.PicklistValues) { $values | select Label,Value,IsActive }

$output= $atws.getThresholdAndUsageInfo()
Powershell: AutoTask – Get Picklist Values was last modified: March 30th, 2016 by TomLasswell

, ,

6 thoughts on “Powershell: AutoTask – Get Picklist Values

  • Pretendor says:

    guys, i need something like this accept it must be for the contacts

    • TomLasswell says:

      Just change this: $entity= $atws.getFieldInfo(“Ticket”)
      to this: $entity= $atws.getFieldInfo(“Contact”)

  • Anonymous says:

    When I run this, every line but the last one works. I get this error:

    New-WebServiceProxy : Object reference not set to an instance of an object.
    At line:1 char:28
    + $atws = New-WebServiceProxy <<<< -URI $zoneInfo.URL -Credential $credentials
    + CategoryInfo : NotSpecified: (:) [New-WebServiceProxy], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.NewWebServiceProxy

    The URL returns properly from the getZoneInfo() call, but the following creation of the web service does not work.

    Have you ever run into this issue or have any idea what the issue is?

    • TomLasswell says:

      thanks for catching that, the url being returned by the getZoneInfo() had the wrong extension and wasn’t referencing the .wsdl but the .asmx file which would result in the error you were seeing. I updated the script above to reflect a replace to use the right extension.

      • Anonymous says:

        Sweet, you the man. Can you offer any explanation why they return the asmx link if you need the wsdl one?

      • TomLasswell says:

        I’m using that command in this example to be universal, that command doesn’t understand what language you’re using to query it, it just returns that URL. I’m using it more to get the zone location (i.e. you might be where I might be for the beginning of the URL). This way it works for everyone. I posted this up, but I always hard-code my URL instead of looking it up in the script, why I missed the error on the .asmx.

Leave a Reply

%d bloggers like this: