diff --git a/Extensions/EndpointManager.psm1 b/Extensions/EndpointManager.psm1 index a2950dc..547aa87 100644 --- a/Extensions/EndpointManager.psm1 +++ b/Extensions/EndpointManager.psm1 @@ -10,7 +10,7 @@ This module is for the Endpoint Manager/Intune View. It manages Export/Import/Co #> function Get-ModuleVersion { - '3.1.10' + '3.1.11' } function Invoke-InitializeModule @@ -119,6 +119,8 @@ function Invoke-InitializeModule Permissons=@("Policy.Read.All","Policy.ReadWrite.ConditionalAccess","Application.Read.All") Dependencies = @("NamedLocations","Applications") GroupId = "ConditionalAccess" + ImportExtension = { Add-ConditionalAccessImportExtensions @args } + PreImportCommand = { Start-PreImportConditionalAccess @args } }) Add-ViewItem (New-Object PSObject -Property @{ @@ -2432,5 +2434,61 @@ function Start-PreUpdateFeatureUpdates } #endregion +#region Conditional Access +function Add-ConditionalAccessImportExtensions +{ + param($form, $buttonPanel, $index = 0) + + $xaml = @" + + +"@ + $label = [Windows.Markup.XamlReader]::Parse($xaml) + + $CAStates = @() + $CAStates += [PSCustomObject]@{ + Name = "As Exported" + Value = "AsExported" + } + + $CAStates += [PSCustomObject]@{ + Name = "Report-only" + Value = "enabledForReportingButNotEnforced" + } + + $CAStates += [PSCustomObject]@{ + Name = "On" + Value = "enabled" + } + + $CAStates += [PSCustomObject]@{ + Name = "Off" + Value = "disabled" + } + + $global:cbImportCAState = [System.Windows.Controls.ComboBox]::new() + $global:cbImportCAState.DisplayMemberPath = "Name" + $global:cbImportCAState.SelectedValuePath = "Value" + $global:cbImportCAState.ItemsSource = $CAStates + $global:cbImportCAState.SelectedValue = "AsExported" + $global:cbImportCAState.Margin="0,5,0,0" + $global:cbImportCAState.HorizontalAlignment="Left" + $global:cbImportCAState.Width=250 + + @($label, $global:cbImportCAState) +} + +function Start-PreImportConditionalAccess +{ + param($obj, $objectType, $file, $assignments) + + if($global:cbImportCAState.SelectedValue -and $global:cbImportCAState.SelectedValue -ne "AsExported") + { + $obj.state = $global:cbImportCAState.SelectedValue + } +} +#endregion Export-ModuleMember -alias * -function * \ No newline at end of file diff --git a/Extensions/MSGraph.psm1 b/Extensions/MSGraph.psm1 index 6b22b1b..fa94a6d 100644 --- a/Extensions/MSGraph.psm1 +++ b/Extensions/MSGraph.psm1 @@ -10,7 +10,7 @@ This module manages Microsoft Grap fuctions like calling APIs, managing graph ob #> function Get-ModuleVersion { - '3.1.5' + '3.1.6' } $global:MSGraphGlobalApps = @( @@ -955,7 +955,7 @@ function Show-GraphImportForm } } - Add-GraphImportExtensions $script:importForm 1 + Add-GraphImportExtensions $script:importForm 1 $global:curObjectType if($global:txtImportPath.Text) { @@ -1010,9 +1010,9 @@ function Show-GraphBulkImportForm Selected = (?? $objType.BulkImport $true) ObjectType = $objType } - } - Add-GraphImportExtensions $script:importForm 0 + Add-GraphImportExtensions $script:importForm 0 $objType + } $column = Get-GridCheckboxColumn "Selected" $global:dgObjectsToImport.Columns.Add($column) @@ -1161,27 +1161,30 @@ function Add-GraphExportExtensions function Add-GraphImportExtensions { - param($form, $buttonIndex = 0) + param($form, $buttonIndex = 0, $objectTypes) - if($global:curObjectType.ImportExtension) + foreach($objectType in $objectTypes) { - $grid = $form.FindName("grdImportProperties") - $extraProperties = & $global:curObjectType.ExportExtension $global:curObjectType.ExportExtension $form "spExportSubMenu" 1 - for($i=0;($i + 1) -lt (($extraProperties) | measure).Count;$i ++) - { - $rd = [System.Windows.Controls.RowDefinition]::new() - $rd.Height = [double]::NaN - $grid.RowDefinitions.Add($rd) - $extraProperties[$i].SetValue([System.Windows.Controls.Grid]::RowProperty,$grid.RowDefinitions.Count) - $grid.Children.Add($extraProperties[$i]) + if($objectType.ImportExtension) + { + $grid = $form.FindName("grdImportProperties") + $extraProperties = & $objectType.ImportExtension $form "spExportSubMenu" 1 + for($i=0;($i + 1) -lt (($extraProperties) | measure).Count;$i ++) + { + $rd = [System.Windows.Controls.RowDefinition]::new() + $rd.Height = [double]::NaN + $grid.RowDefinitions.Add($rd) + $extraProperties[$i].SetValue([System.Windows.Controls.Grid]::RowProperty,$grid.RowDefinitions.Count) + $grid.Children.Add($extraProperties[$i]) - $i++ - $extraProperties[$i].SetValue([System.Windows.Controls.Grid]::RowProperty,$grid.RowDefinitions.Count) - $extraProperties[$i].SetValue([System.Windows.Controls.Grid]::ColumnProperty,1) - $grid.Children.Add($extraProperties[$i]) - + $i++ + $extraProperties[$i].SetValue([System.Windows.Controls.Grid]::RowProperty,$grid.RowDefinitions.Count) + $extraProperties[$i].SetValue([System.Windows.Controls.Grid]::ColumnProperty,1) + $grid.Children.Add($extraProperties[$i]) + + } } - } + } } function Show-GraphBulkDeleteForm @@ -2234,7 +2237,7 @@ function Import-GraphObject } } - $json = ConvertTo-Json $obj -Depth 10 + $json = ConvertTo-Json $obj -Depth 20 if($fromFile) { # Call Update-JsonForEnvironment before importing the object diff --git a/ReleaseNotes.md b/ReleaseNotes.md index ee3aa73..5293e28 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,5 +1,17 @@ # Release Notes +## 3.2.2 - 2021-09-23 + +**New features** + +- Added support for setting Conditional Access policy state during import. The default setting is to import Conditional Access policies with the same sate as they were exported. + This is based on feature request [Issue 25](https://github.com/Micke-K/IntuneManagement/issues/25) + Note: Security defaults must be disabled before Conditional Access policies can be imported as Enabled. + +**Fixes** + +* Fixed bugs when using the ImportExtension command + ## 3.2.1 - 2021-09-04 **New features** @@ -17,7 +29,7 @@ * General - * Custom Device Configuration profiles will convert encrypted OMA URI values when the full object is loaded instead during Copy and Export. + * Custom Device Configuration profiles will convert encrypted OMA URI values when the full object is loaded instead of only during Copy and Export. * All file exports are now saved in UTF8 * Compare