diff --git a/Extensions/MSGraph.psm1 b/Extensions/MSGraph.psm1 index 26fe015..0b07e62 100644 --- a/Extensions/MSGraph.psm1 +++ b/Extensions/MSGraph.psm1 @@ -43,6 +43,10 @@ function Invoke-InitializeModule Name = "Replace (Preview)" Value = "replace" }, + [PSCustomObject]@{ + Name = "Replace with assignments (Preview)" + Value = "replace_with_assignments" + }, [PSCustomObject]@{ Name = "Update (Preview)" Value = "update" @@ -2353,7 +2357,10 @@ function Reset-GraphObject # Clone the object before removing properties $obj = $fileObj.Object | ConvertTo-Json -Depth 50 | ConvertFrom-Json Start-GraphPreImport $obj $objectType - Remove-Property $obj "Assignments" + if ($global:cbImportType.SelectedValue -ne "replace_with_assignments"){ + # will use the assignments from the file for "replace_with_assignments" type + Remove-Property $obj "Assignments" + } Remove-Property $obj "isAssigned" if($global:cbImportType.SelectedValue -eq "update") @@ -2417,7 +2424,7 @@ function Reset-GraphObject } return $true } - elseif($global:cbImportType.SelectedValue -eq "replace") + elseif($global:cbImportType.SelectedValue -in @("replace","replace_with_assignments")) { $replace = $true $import = $true @@ -2466,8 +2473,13 @@ function Reset-GraphObject } } } - - Import-GraphObjectAssignment $newObj $objectType $curObject.Object.Assignments $fileObj.FileInfo.FullName -CopyAssignments | Out-Null + if ($global:cbImportType.SelectedValue -eq "replace") + { + Import-GraphObjectAssignment $newObj $objectType $curObject.Object.Assignments $fileObj.FileInfo.FullName -CopyAssignments | Out-Null + } + else { + Import-GraphObjectAssignment $newObj $objectType $obj.Assignments $file.FileInfo.FullName | Out-Null + } if($delete) { diff --git a/Xaml/BulkImportForm.xaml b/Xaml/BulkImportForm.xaml index 307fe08..daab27f 100644 --- a/Xaml/BulkImportForm.xaml +++ b/Xaml/BulkImportForm.xaml @@ -85,6 +85,7 @@ Always import: Always try to import the object. No detction of existing object (Default) Skip if object exists: Skip import if there is an existing object with the same name and type Replace: If an object is detected, it will be deleted. The assignments will be copied to the new imported object + Replace with assignments: If an object is detected, it will be deleted. The assignments will be copied from the imported object Update: If an object is detected, settings will be replaced from the import file diff --git a/Xaml/ImportForm.xaml b/Xaml/ImportForm.xaml index 9ac70d7..ab2a279 100644 --- a/Xaml/ImportForm.xaml +++ b/Xaml/ImportForm.xaml @@ -76,6 +76,7 @@ Always import: Always try to import the object. No detction of existing object (Default) Skip if object exists: Skip import if there is an existing object with the same name and type Replace: If an object is detected, it will be deleted. The assignments will be copied to the new imported object + Replace with assignments: If an object is detected, it will be deleted. The assignments will be copied from the imported object Update: If an object is detected, settings will be replaced from the import file