@@ -4,7 +4,9 @@ function New-CIPPRestoreTask {
44 $Task ,
55 $TenantFilter ,
66 $backup ,
7- $overwrite
7+ $overwrite ,
8+ $APINAME ,
9+ $Headers
810 )
911 $Table = Get-CippTable - tablename ' ScheduledBackup'
1012 $BackupData = Get-CIPPAzDataTableEntity @Table - Filter " RowKey eq '$backup '"
@@ -99,7 +101,7 @@ function New-CIPPRestoreTask {
99101 $BackupConfig = $BackupData.intuneconfig | ConvertFrom-Json
100102 foreach ($backup in $backupConfig ) {
101103 try {
102- Set-CIPPIntunePolicy - TemplateType $backup.Type - TenantFilter $TenantFilter - DisplayName $backup.DisplayName - Description $backup.Description - RawJSON ($backup.TemplateJson ) - ErrorAction SilentlyContinue
104+ Set-CIPPIntunePolicy - TemplateType $backup.Type - TenantFilter $TenantFilter - DisplayName $backup.DisplayName - Description $backup.Description - RawJSON ($backup.TemplateJson ) - Headers $Headers - APINAME $APINAME - ErrorAction SilentlyContinue
103105 } catch {
104106 $ErrorMessage = Get-CippException - Exception $_
105107 " Could not restore Intune Configuration $DisplayName : $ ( $ErrorMessage.NormalizedError ) "
@@ -112,7 +114,7 @@ function New-CIPPRestoreTask {
112114 $BackupConfig = $BackupData.intunecompliance | ConvertFrom-Json
113115 foreach ($backup in $backupConfig ) {
114116 try {
115- Set-CIPPIntunePolicy - TemplateType $backup.Type - TenantFilter $TenantFilter - DisplayName $backup.DisplayName - Description $backup.Description - RawJSON ($backup.TemplateJson ) - ErrorAction SilentlyContinue
117+ Set-CIPPIntunePolicy - TemplateType $backup.Type - TenantFilter $TenantFilter - DisplayName $backup.DisplayName - Description $backup.Description - RawJSON ($backup.TemplateJson ) - Headers $Headers - APINAME $APINAME - ErrorAction SilentlyContinue
116118 } catch {
117119 $ErrorMessage = Get-CippException - Exception $_
118120 " Could not restore Intune Compliance $DisplayName : $ ( $ErrorMessage.NormalizedError ) "
@@ -126,7 +128,7 @@ function New-CIPPRestoreTask {
126128 $BackupConfig = $BackupData.intuneprotection | ConvertFrom-Json
127129 foreach ($backup in $backupConfig ) {
128130 try {
129- Set-CIPPIntunePolicy - TemplateType $backup.Type - TenantFilter $TenantFilter - DisplayName $backup.DisplayName - Description $backup.Description - RawJSON ($backup.TemplateJson ) - ErrorAction SilentlyContinue
131+ Set-CIPPIntunePolicy - TemplateType $backup.Type - TenantFilter $TenantFilter - DisplayName $backup.DisplayName - Description $backup.Description - RawJSON ($backup.TemplateJson ) - Headers $Headers - APINAME $APINAME - ErrorAction SilentlyContinue
130132 } catch {
131133 $ErrorMessage = Get-CippException - Exception $_
132134 " Could not restore Intune Protection $DisplayName : $ ( $ErrorMessage.NormalizedError ) "
@@ -281,7 +283,7 @@ function New-CIPPRestoreTask {
281283 foreach ($param in $ruleparams ) {
282284 if ($rule.PSObject.Properties [$param ]) {
283285 if ($param -eq ' Enabled' ) {
284- $cmdparams [$param ] = if ($rule.State -eq ' Enabled' ) {$true } else {$false }
286+ $cmdparams [$param ] = if ($rule.State -eq ' Enabled' ) { $true } else { $false }
285287 } else {
286288 $cmdparams [$param ] = $rule .$param
287289 }
@@ -301,7 +303,7 @@ function New-CIPPRestoreTask {
301303 foreach ($param in $ruleparams ) {
302304 if ($rule.PSObject.Properties [$param ]) {
303305 if ($param -eq ' Enabled' ) {
304- $cmdparams [$param ] = if ($rule.State -eq ' Enabled' ) {$true } else {$false }
306+ $cmdparams [$param ] = if ($rule.State -eq ' Enabled' ) { $true } else { $false }
305307 } else {
306308 $cmdparams [$param ] = $rule .$param
307309 }
@@ -438,7 +440,7 @@ function New-CIPPRestoreTask {
438440 foreach ($param in $ruleparams ) {
439441 if ($rule.PSObject.Properties [$param ]) {
440442 if ($param -eq ' Enabled' ) {
441- $cmdparams [$param ] = if ($rule.State -eq ' Enabled' ) {$true } else {$false }
443+ $cmdparams [$param ] = if ($rule.State -eq ' Enabled' ) { $true } else { $false }
442444 } else {
443445 $cmdparams [$param ] = $rule .$param
444446 }
@@ -458,7 +460,7 @@ function New-CIPPRestoreTask {
458460 foreach ($param in $ruleparams ) {
459461 if ($rule.PSObject.Properties [$param ]) {
460462 if ($param -eq ' Enabled' ) {
461- $cmdparams [$param ] = if ($rule.State -eq ' Enabled' ) {$true } else {$false }
463+ $cmdparams [$param ] = if ($rule.State -eq ' Enabled' ) { $true } else { $false }
462464 } else {
463465 $cmdparams [$param ] = $rule .$param
464466 }
0 commit comments