< Back

Connect-AutomateAPI

Sat Jan 11, 2020 2:03 am

NAME Connect-AutomateAPI



SYNOPSIS

Connect to the Automate API.





SYNTAX

Connect-AutomateAPI [-Server <String>] [-AuthorizationToken <String>] [-SkipCheck] [-Quiet] [<CommonParameters>]



Connect-AutomateAPI [-Credential <PSCredential>] [-Server <String>] [-SkipCheck] [-TwoFactorToken <String>]

[-Force] [-Quiet] [<CommonParameters>]



Connect-AutomateAPI [-Server <String>] [-AuthorizationToken <String>] [-Verify] [-Quiet] [<CommonParameters>]





DESCRIPTION

Connects to the Automate API and returns a bearer token which when passed with each requests grants up to an hours

worth of access.





PARAMETERS

-Credential <PSCredential>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Server <String>

The address to your Automate Server. Example 'rancor.hostedrmm.com'



Required? false

Position? named

Default value $Script:CWAServer

Accept pipeline input? false

Accept wildcard characters? false



-AuthorizationToken <String>

Used internally when quietly refreshing the Token



Required? false

Position? named

Default value ($Script:CWAToken.Authorization -replace 'Bearer ','')

Accept pipeline input? false

Accept wildcard characters? false



-SkipCheck [<SwitchParameter>]

Used internally when quietly refreshing the Token



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Verify [<SwitchParameter>]

Specifies to test the current token, and if it is not valid attempt to obtain a new one using the current

credentials. Does not refresh (re-issue) the current token.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-TwoFactorToken <String>

Takes a string that represents the 2FA number



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Force [<SwitchParameter>]

Will not attempt to refresh a current session



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Quiet [<SwitchParameter>]

Will not output any standard messages. Returns $True if connection was successful.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

Three strings into Script variables, $CWAServer containing the server address, $CWACredentials containing the

bearer token and $CWACredentialsExpirationDate containing the date the credentials expire





NOTES





Version: 1.1

Author: Gavin Stone

Creation Date: 2019-01-20

Purpose/Change: Initial script development



Update Date: 2019-02-12

Author: Darren White

Purpose/Change: Credential and 2FA prompting is only if needed. Supports Token Refresh.



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Connect-AutomateAPI -Server "rancor.hostedrmm.com" -Credentials $CredentialObject -TwoFactorToken "999999"













-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Connect-AutomateAPI -Quiet















RELATED LINKS