RESTful/scratch.ps1
$Header = @{} $APIKey = '' function getAuthToken { param ( [string]$ComputerName, [pscredential]$Credential ) $Body = @{ 'name' = $Credential.UserName 'password' = $Credential.GetNetworkCredential().Password } | convertto-json $Auth = Invoke-RestMethod -Uri http://$ComputerName/api/v1/authentication/signin` -Method Post -ContentType application/json -Body $Body $Auth #$Header.goodUntil = $Auth ### Want to figure out how to ensure the credentials arenet expired } function Set-APIKey {} Function Start-RestConnection {} function Get-APIKey {} function __isExpired__ ($Header) { ### How do I know if the token is good? } function __testConnection__ (OptionalParameters) { } |