Open eightsixeight opened 10 months ago
We're committed to having complete parity with the NinjaOne API without anyone needing to pay-per-function.
Let me know what function/endpoint you're looking for and I'm happy to let you know whether it's something we're already adding - we're working on everything added in 5.6 at the moment for the 2.0.0 stable release this week.
So we can't do things the Ninja API doesn't support, as it stands now the device/{id}/script/run
endpoint requires authorization_code
authentication. Ninja can enable sliding refresh tokens which allows you to do interactive authentication once and then reuse / refresh the token as long as it doesn't expire fully. (30 days from memory) which is the workaround we use currently for running scripts from HaloPSA.
Sounds perfect..
With your script I was able to get
Expires 12/14/2023 1:32:11 PM Access Xr6YAvcfxC_...... Code bbf5c3d7-708d…… Refresh bbf5c3d7-708d-4afc-....... Type Bearer
Not sure what to do next..
You'll need to reach out to your NinjaOne account manager and ask them to enable sliding refresh tokens. I'll get our documentation improved tomorrow as it doesn't currently cover Token
auth and it should.
ok once done, can you point me to next steps once i get these to perform a run script ?
got the sliding refresh, what is next ?
@eightsixeight - what exactly do want to accomplish. I cannot work it out from the information in this issue. Can you give a quick description of your goal ?
@xasz simply call the API to run SCRIPT x on device Y....
As you have credentials you can connect via Connect-NinjaOne
and then use the cmdlet Invoke-NinjaOneDeviceScript
Do you know that you can schedule a script in ninja? I think you should ask this in the NinjaOne Discord.
yes i dont want to scedule it.. i want another powershell to call this on demand.
$whois = Get-NinjaOneDeviceLastLoggedOnUser -deviceId 443
foreach ($userinfo in $whois.userName) {
Write-Host " User is $userinfo"
}
Invoke-NinjaOneDeviceScript -deviceId 443 -type 'SCRIPT' -scriptId 20 -runAs $userinfo -Debug -Verbose
results in powershell spitting out, Requested for script blah on device blah successfuly...
spits out on ninja..
Result: Failed. Unable to retrieved credential information.
need to run as system or logged in or whatever....
Please provide an working example and the full error message. Please use the correct code formatting markdown.
Would like to hire you to complete a function in your powershell for ninja one..
seems ninja doesnt want to help at all.
please contact me for more information