Private/Save-NSPConditionalAccessJson.ps1
|
function Save-NSPConditionalAccessJson { <# .SYNOPSIS Writes an object as JSON atomically (temp file, then replace), so an interrupted save cannot leave a half-written file. #> [CmdletBinding()] param( [Parameter(Mandatory)]$InputObject, [Parameter(Mandatory)][string]$Path ) New-Item -ItemType Directory -Path (Split-Path -Parent $Path) -Force | Out-Null $temp = "$Path.tmp" ConvertTo-Json -InputObject $InputObject -Depth 32 | Set-Content -LiteralPath $temp -Encoding UTF8 Move-Item -LiteralPath $temp -Destination $Path -Force } |