ecitsolutions / Autotask

A PowerShell module for Autotask Web Services API
MIT License
65 stars 18 forks source link

Get / Set AccountManager field #4

Closed teejayen closed 6 years ago

teejayen commented 6 years ago

Loving the module so far, and has made light work of a couple of bulk changes for us.

Currently, there's no easy way to bulk modify the Account Manager assigned to an account in Autotask - so leveraging the API through your PoSH module would work really well!

It would be invaluable to be able to Get / Set the AccountManager field using AtwsAccount.

klemmestad commented 6 years ago

Hi, glad you find our module useful! :)

The Account Manager field is exposed in the API as owner resource. I guess that is why you haven't found it yet. The field name is OwnerResourceId:

# Get Account Manager for $Account
$AccountManager = Get-AtwsResource -id $Account.OwnerResourceId
Write-Output ('The Account Manager for Account {0} is {1} {2}' -F $Account.AccountName, $AccountManager.FirstName, $AccountManager.LastName

# Bulk change Account Manager
$PreviousManager = Get-AtwsResource -Username '<previousmanager_username>'
$NewManager = Get-AtwsResource -Username '<newmanager_username>'

Get-AtwsAccount -OwnerResourceId $PreviousManager.id | Set-AtwsAccount -OwnerResourceId $NewManager.id
teejayen commented 6 years ago

Thanks very much, that works perfectly.