Skip to content

Commit e982446

Browse files
add-member incase object does not yet exist.
1 parent ef06f9c commit e982446

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecJITAdminSettings.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Invoke-ExecJITAdminSettings {
1+
function Invoke-ExecJITAdminSettings {
22
<#
33
.FUNCTIONALITY
44
Entrypoint
@@ -19,9 +19,9 @@ Function Invoke-ExecJITAdminSettings {
1919

2020
if (-not $JITAdminConfig) {
2121
$JITAdminConfig = @{
22-
PartitionKey = 'JITAdminSettings'
23-
RowKey = 'JITAdminSettings'
24-
MaxDuration = $null # null means no limit
22+
PartitionKey = 'JITAdminSettings'
23+
RowKey = 'JITAdminSettings'
24+
MaxDuration = $null # null means no limit
2525
}
2626
}
2727

@@ -35,17 +35,17 @@ Function Invoke-ExecJITAdminSettings {
3535
}
3636
'Set' {
3737
$MaxDuration = $Request.Body.MaxDuration.value
38-
38+
Write-Host "MAx dur: $($MaxDuration)"
3939
# Validate ISO 8601 duration format if provided
4040
if (![string]::IsNullOrWhiteSpace($MaxDuration)) {
4141
try {
4242
# Test if it's a valid ISO 8601 duration
4343
$null = [System.Xml.XmlConvert]::ToTimeSpan($MaxDuration)
44-
$JITAdminConfig.MaxDuration = $MaxDuration
44+
$JITAdminConfig | Add-Member -NotePropertyName MaxDuration -NotePropertyValue $MaxDuration -Force
4545
} catch {
4646
$StatusCode = [HttpStatusCode]::BadRequest
4747
@{
48-
Results = "Error: Invalid ISO 8601 duration format. Expected format like PT4H, P1D, P4W, etc."
48+
Results = 'Error: Invalid ISO 8601 duration format. Expected format like PT4H, P1D, P4W, etc.'
4949
}
5050
break
5151
}
@@ -62,7 +62,7 @@ Function Invoke-ExecJITAdminSettings {
6262
$Message = if ($JITAdminConfig.MaxDuration) {
6363
"Successfully set JIT Admin maximum duration to $($JITAdminConfig.MaxDuration)"
6464
} else {
65-
"Successfully removed JIT Admin maximum duration limit"
65+
'Successfully removed JIT Admin maximum duration limit'
6666
}
6767

6868
Write-LogMessage -headers $Headers -API $APIName -message $Message -Sev 'Info'

0 commit comments

Comments
 (0)