Initial commit
This commit is contained in:
18
functions/private/Update-PSIPAMSession.ps1
Normal file
18
functions/private/Update-PSIPAMSession.ps1
Normal file
@@ -0,0 +1,18 @@
|
||||
function Update-PSIPAMSession {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[switch]
|
||||
$Force
|
||||
)
|
||||
$_tokenStatus = Test-PSIPAMSession
|
||||
if ($_tokenStatus -eq "NoToken") {
|
||||
throw "No session available!"
|
||||
}
|
||||
if ($_tokenStatus -eq "Valid") {
|
||||
return (Invoke-PSIPAMRequest -Method PATCH -Controller user).expires
|
||||
}
|
||||
if ($_tokenStatus -eq "Expired" -or $Force) {
|
||||
New-PSIPAMSession -URL $script:ipamURL -AppID $script:ipamAppID -Credentials $script:ipamCredentials
|
||||
return $script:ipamExpires
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user