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
- 42 Getting started
- 26 Read before posting
- 8 Meet and greet
- 257 General
- 71 News and announcements
- 2 Swag
- 1 Roadmap updates
- 83 Resources
- 12 Knowledge Base
- 17 Webinars
- 1 Shared Script Library
- 2 Blog
- 21 Pro Tips
- 28 Got an idea?
- 3 Atera Academy
- 2 ActionAI
- 1 Copilot
- 142 Remote Monitoring and Management
- 85 Remote Monitoring
- 28 Patch Management
- 107 Professional Services Automation
- 65 Helpdesk
- 17 Billing
- 22 Reporting
- 41 Integrations & add-ons
- 22 Integrations
- 11 Add-ons
- 108 Scripting and automations
- 62 Scripts
- 32 Automations