How to retrieve and update data in Autotask using the API with PowerShell.
ever wondered if there's a simple way to retrieve and update data from autotask using the api in powershell well guess what there is hi everyone my name is chris tim and i'm from sundela consulting in this video i'm going to talk about how easy it is to pull some data from multitask and update it using the api and powershell now before we start i'm not a powershell expert or a developer and there may be a much better way to do this but it's always worked for me and it's always done what i've needed it to do i cannot take any credit for the script as it was given to me by somebody a lot cleverer than me okay so the first thing we're going to do is to start by creating an api user so over here you can see we have an api user we've got our username we've got our password set and one of the most important things is we have our tracking identifier so when you're setting up these api users because this is going to be a custom piece of code i need to select the custom box here which will give me this api tracking identifier once i have that information i can now go into powershell and i can start to get the script working so i normally use powershell ise because i find it a lot easier to use but of course you can use any kind of powershell application that you like so the very first thing you want to do is you want to start by installing the autotask module so you would simply type in here install autotask or install module autotask and you simply click on the play button and what this will do is it will go ahead and it will install the entire autotask module for you okay and this is the module that it's going to pull down from the powershell gallery and you can find more information on it below so once it's done it's thing it's now ready to be used so all we simply need to do code that's going to allow us to uh manipulate the api so here is that code so you can see very quickly all we're doing is we're creating a function we're putting in those details that we created earlier on so this is our tracking identifier our username and our password and then very simply we're just writing a little function here as a login function what it's going to do is it's going to go check to see if you're already logged in if you are it's going to tell you you're logged in otherwise it's going to go and initiate this login function so let's actually go ahead and do this so very simply you can see because the first time i've done this it says logging in and what it's going to do is go ahead and update this disk cache and it's going to go ahead and get all of this information this process doesn't take very long to do so we'll we'll speed up the video at this point so that you don't have to sit and watch this and there you go it's now done so now that we know it's done if we look up here under the modules we can simply see that if we click on the autotask module these are all of the commandlets that we can use to find this information inside autotask so the first thing we're going to do is we're going to use this atws account and we're going to go and pull some information from the account so let's go ahead and do that so very simply in here i'm going to type get atws account um then i'm going to say minus account name and in the account name field i'm basically going to use i'm going to use justice league and what that does is it pulls back the information on justice league so here you can see it's gone ahead and it's pulled back all of the information about the customer um including the city the state the address all of that kind of thing so the fact that it's pulling back that information is is a good indication that of course this is all working fine so what i'm actually going to do is i'm going to go into here in a new tab and i'm actually going to go now and and create an object so that we can pull some information out of this object and then we can go ahead and change it so if we look at this we'll see that the city in here is listed as gotham so i want to change this to actually say gotham city and just to show you if we actually click into the justice league you can see here the city is actually listed as gotham so let's go ahead and do this so we're going to start by creating a variable and into there we're going to we're going to input this object so we're going to do exactly the same thing that we had before so atws account and then we're going to say minus account name and we're going to use the same company okay so once we've entered that information in there we can now use this object here to pull uh to pull information like the city for example so we're going to go if we said you know dollar company dot city and then we click the play button what you will see is that this returns gotham okay it's a very very easy way for us to pull out specific fields within within this company information okay so let's go in now and say what if we want to change the city to to gotham city so very simply what we're going to do is we're going to use this company again and we're going to tell it that the city is going to be equal to this in this case we're going to change it to gotham city and then what we're going to do at this point we're now going to because we want to write something back in so we want to write this word gotham city back into this object what we're simply going to do in here is we're now going to use the set and if we look all the way down here um actually if i just type it in here so if we use the set atws account you will see that down here we have that information um about the account somewhere up here uh set atws account there you go you can see the atws account so what we're going to do is go set at ws account and then we're going to say that we want to input whatever is inside this object so we're going to input object and we're simply going to go dollar company okay and when we run this it'll basically go find the city called gotham okay and now if i actually go ahead and just down here or actually so if i go back and i just remove all of the rest of the stuff and i tell it to just pull the city information you can now see that it's updated the city to gotham city i go back in and i actually update the account directly within autotask what you will see at this point is again you will see it's now been updated to gotham city so that's it it really is as easy as that to read and write from the api using powershell so thank you for watching this video if you like what you see i'd really appreciate it if you could subscribe to this channel um there'll be a lot more of these kinds of videos coming very shortly
Get in touch and we'll talk through how it applies to your MSP.
Let's Talk