Public/New-DunePatchingWindow.ps1
|
function New-DunePatchingWindow { [CmdletBinding( SupportsShouldProcess, ConfirmImpact = 'None' )] param ( [Parameter(Mandatory)] [MonthlyDayOccurence]$MonthlyOccurence, [Parameter(Mandatory)] [dayofweek]$DayOfWeek, [Parameter(Mandatory)] [String]$TimeOfDay, #inPS7 use System.TimeOnly [Parameter()] [timespan]$Duration ) begin {} process { Write-Debug "$($MyInvocation.MyCommand)|process" $Body = @{ MonthlyOccurence = $MonthlyOccurence.ToString() DayOfWeek = $DayOfWeek.ToString() TimeOfDay = $TimeOfDay Duration = $Duration } if ($PSCmdlet.ShouldProcess($($Body | ConvertTo-Json -Depth 16 -Compress))) { $Return = Invoke-DuneApiRequest -Uri "patching/windows" -Method POST -Body $Body $ReturnObject = if ($Return.Content) { $Return.Content | ConvertFrom-Json | ConvertTo-DuneClassObject -Class DunePatchingWindow } return $ReturnObject } } end {} } |