Simple API Instructions required :)
Hi All,
Thought I would turn my attention to API's ! and getting thoroughly frustrated at my failure !!
Would any one be kind enough to provide a simple example on how I get it to work !
What I would like is this :-
Create a custom Field in say the Agents area, lets call it "Field1"
Then I would like a script that uses the API to then populate that field with for example sake the hostname (just using that as an example which can be customised to a future needs later)
This script then attached to a threshold etc to be executed.
Is this even possible ? (yes I know this is available if I upgrade to super users and get the "Script based custom fields" functionality)
Would that script then update all the custom fields of all Agent's called "Field1"
Many Thanks in Advance Nick
Comments
-
# Import the PSAtera module Import-Module PSAtera # Define the Atera API Key $APIKey = "INSERT API KEY" # Connect to the Atera API Connect-AteraAPI -APIKey $APIKey # Define the customer custom field variable $CustomerCustomField = Get-AteraCustomerCustomField -Name "DNS1" # Check if the customer custom field is not null or empty if (![string]::IsNullOrEmpty($CustomerCustomField.Value)) { # Get the agent custom field $AgentCustomField = Get-AteraAgentCustomField -Name "DNS1" # Check if the agent custom field is empty if ([string]::IsNullOrEmpty($AgentCustomField.Value)) { # Populate the agent custom field with the contents of the customer custom field Set-AteraAgentCustomField -Name "DNS1" -Value $CustomerCustomField.Value } } else { # Output a message indicating that the customer custom field is empty or does not exist Write-Output "The customer custom field DNS1 is empty or does not exist." } # Disconnect from the Atera API Disconnect-AteraAPI
1 -
this grabs the DNS1 field from the customer and populates the agend field called DNS1
1 -
nice @COOLNETAU !
Does that work for you @BEKAHENI ?1 -
Thanks Coolnetau,
I will follow that this afternoon and report back.
Will be a good template to use for anythign else we want to populate :)
Cheers
0 -
Hi All,
Ok tried running it (inserting my own API) but I get the error "The term 'Connect-AteraAPI' is not recognized as the name of a cmdlet" when runnign it in powershell (As admin) on my own machine.
I have created the Custom field and named it DNS1
Thanks In advance
Nick
0 -
You must install the PSAtera module
- that in itself is a whole another can of worms lol
0
Topics
- All Topics
- 41 Getting started
- 25 Read before posting
- 8 Meet and greet
- 237 General
- 64 News and announcements
- 1 Swag
- 1 Roadmap updates
- 79 Resources
- 12 Knowledge Base
- 16 Webinars
- 1 Shared Script Library
- 2 Blog
- 19 Pro Tips
- 27 Got an idea?
- 3 Atera Academy
- 2 ActionAI
- 1 Copilot
- 140 Remote Monitoring and Management
- 84 Remote Monitoring
- 27 Patch Management
- 105 Professional Services Automation
- 64 Helpdesk
- 17 Billing
- 21 Reporting
- 36 Integrations & add-ons
- 20 Integrations
- 10 Add-ons
- 103 Scripting and automations
- 61 Scripts
- 30 Automations