function Invoke-InitializeModule { $module = Get-Module -Name Microsoft.Graph.Intune -ListAvailable if(-not $module) { $ret = [System.Windows.MessageBox]::Show("Intune PowerShell module not found!`n`nDo you want to install it?`n`nYes = Install intune module (Requires admin or it will fail)`nNo = Contune without module (Nothing will work)`nCancel = Quit", "Error", "YesNoCancel", "Error") if($ret -eq "Yes") { try { Install-Module -Name Microsoft.Graph.Intune -Force -ErrorAction SilentlyContinue } catch {} if(-not (Get-Module -Name Microsoft.Graph.Intune)) { [System.Windows.MessageBox]::Show("Failed to install Intune PowerShell module!`n`nRestart this as admin and try again`nor`nStart PowerShell as admin and run:`nInstall-Module -Name Microsoft.Graph.Intune", "Error", "OK", "Error") exit } } elseif($ret -eq "Cancel") { exit } } if(-not $global:authentication) { if((Get-Command Connect-MSGraph)) { $global:authentication = Connect-MSGraph -PassThru } } $global:graphURL = "https://graph.microsoft.com/beta" # Add settings $global:appSettingSections += (New-Object PSObject -Property @{ Title = "Intune" Id = "IntuneAzure" Values = @() }) Add-SettingsObject (New-Object PSObject -Property @{ Title = "Root folder" Key = "IntuneRootFolder" Type = "Folder" }) "IntuneAzure" Add-SettingsObject (New-Object PSObject -Property @{ Title = "App packages folder" Key = "IntuneAppPackages" Type = "Folder" }) "IntuneAzure" Add-SettingsObject (New-Object PSObject -Property @{ Title = "Add object type" Key = "AddObjectType" Type = "Boolean" DefaultValue = $true }) "IntuneAzure" Add-SettingsObject (New-Object PSObject -Property @{ Title = "Add company name" Key = "AddCompanyName" Type = "Boolean" DefaultValue = $true }) "IntuneAzure" Add-SettingsObject (New-Object PSObject -Property @{ Title = "Export Assignments" Key = "ExportIntuneAssignments" Type = "Boolean" DefaultValue = $true }) "IntuneAzure" Add-SettingsObject (New-Object PSObject -Property @{ Title = "Create groups" Key = "CreateIntuneGroupOnImport" Type = "Boolean" DefaultValue = $true }) "IntuneAzure" Add-SettingsObject (New-Object PSObject -Property @{ Title = "Convert synced groups" Key = "ConvertIntuneSyncedGroupOnImport" Type = "Boolean" DefaultValue = $true }) "IntuneAzure" Add-SettingsObject (New-Object PSObject -Property @{ Title = "Import Assignments" Key = "ImportAssignments" Type = "Boolean" DefaultValue = $true }) "IntuneAzure" #Add menu group and items Add-MenuSection (New-Object PSObject -Property @{ Title = "Intune/Azure Objects"; ID="IntuneGraphAPI"; Order = 10}) Add-MenuSection (New-Object PSObject -Property @{ Title = "Intune/Azure Management"; ID="IntuneGraphAPIEX"; Order = 20}) # Add default menu items Add-MenuItem (New-Object PSObject -Property @{ Title = 'Bulk Import' MenuID = "IntuneGraphAPIEX" Script = [ScriptBlock]{ Show-ImportAllForm } }) # Add default menu items Add-MenuItem (New-Object PSObject -Property @{ Title = 'Bulk Export' MenuID = "IntuneGraphAPIEX" Script = [ScriptBlock]{ Show-ExportAllForm } }) $global:Me = Invoke-GraphRequest "ME" $global:Organization = (Invoke-GraphRequest "Organization").Value $global:UpdateJsonForMigration = $true } function Show-ExportAllForm { param($Extension) $xmlStr = @" $($Extension.Xaml) $($Extension.Xaml) $($Extension.Xaml) $($Extension.Xaml)