18 lines
575 B
PowerShell
18 lines
575 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 [ps.ipam.methods]::PATCH -Controller [ps.ipam.controllers]::user).expires
|
|
}
|
|
if ($_tokenStatus -eq "Expired" -or $Force) {
|
|
New-Session -URL $script:psipamSession.URL -AppID $script:psipamSession.AppID -Credentials $script:psipamSession.Credentials
|
|
return
|
|
}
|
|
} |