Skip to content

Instantly share code, notes, and snippets.

@JeffJacobson
Last active March 30, 2023 20:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffJacobson/43e3146cca0bc83fd306260d727e9348 to your computer and use it in GitHub Desktop.
Save JeffJacobson/43e3146cca0bc83fd306260d727e9348 to your computer and use it in GitHub Desktop.
ArcGIS Online / Portal Powershell scripts

ArcGIS Online / Portal Powershell scripts

What the title says is what this snippet is.

class Token {
[string] $token
[System.DateTimeOffset] $expires
Token($response) {
$this.token = $response.token;
$this.expires = [System.DateTimeOffset]::FromUnixTimeMilliseconds($response.expires)
}
}
$rootUri = "https://www.arcgis.com/sharing/rest"
$params = @{
username = "me";
password = "mypassword";
expiration = '60'
referer = 'https://wsdot.maps.arcgis.com'
f = 'json'
}
$tokenUri = "$rootUri/generateToken"
$response = Invoke-RestMethod -Uri $tokenUri -Method Post -Body $params
$token = New-Object Token $response
return $token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment