18 lines
523 B
PowerShell
18 lines
523 B
PowerShell
function Update-Session {
|
|
[CmdletBinding()]
|
|
param (
|
|
[switch]
|
|
$Force
|
|
)
|
|
$_tokenStatus = Test-Session
|
|
if ($_tokenStatus -eq "NoToken") {
|
|
throw "No session available!"
|
|
}
|
|
if ($_tokenStatus -eq "Valid") {
|
|
return (Invoke-Request -Method PATCH -Controller user).expires
|
|
}
|
|
if ($_tokenStatus -eq "Expired" -or $Force) {
|
|
New-Session -URL $script:ipamURL -AppID $script:ipamAppID -Credentials $script:ipamCredentials
|
|
return $script:ipamExpires
|
|
}
|
|
} |