This commit is contained in:
Mikael Karlsson
2021-07-07 21:50:48 +10:00
parent a0692159b5
commit 06688e7193
8 changed files with 259 additions and 59 deletions

View File

@@ -11,7 +11,7 @@ Objects can be compared based on Properties or Documentatation info.
function Get-ModuleVersion
{
'1.0.3'
'1.0.4'
}
function Invoke-InitializeModule
@@ -631,7 +631,7 @@ function Save-BulkCompareResults
if($compResultValues.Count -gt 0)
{
Write-Log "Save bulk comare results to $file"
$compResultValues | Select -Property $props | ConvertTo-Csv -NoTypeInformation | Out-File $file -Force -Encoding UTF8
$compResultValues | Select -Property $props | ConvertTo-Csv -NoTypeInformation | Out-File -LiteralPath $file -Force -Encoding UTF8
}
}
@@ -677,7 +677,7 @@ function Show-CompareForm
if($sf.ShowDialog() -eq "OK")
{
$csvInfo = Get-CompareCsvInfo $global:dgCompareInfo.ItemsSource $script:cmpForm.Tag
$csvInfo | Out-File $sf.FileName -Force -Encoding UTF8
$csvInfo | Out-File -LiteralPath $sf.FileName -Force -Encoding UTF8
}
}
@@ -789,7 +789,7 @@ function Start-CompareExportObject
}
else
{
$compareObj = Get-Content $global:txtCompareFile.Text | ConvertFrom-Json
$compareObj = Get-Content -LiteralPath $global:txtCompareFile.Text | ConvertFrom-Json
}
}
catch

View File

@@ -20,7 +20,7 @@ $global:documentationProviders = @()
function Get-ModuleVersion
{
'1.0.2'
'1.0.3'
}
function Invoke-InitializeModule
@@ -681,9 +681,13 @@ function Invoke-TranslateADMXObject
#$presentationValues = (Invoke-GraphRequest -Url "$($definitionValue.'definition@odata.bind')/presentations?`$expand=presentation" -ODataMetadata "minimal").value
$presentationValues = $definitionValue.presentationValues
}
elseif($definitionValue.id)
{
$presentationValues = (Invoke-GraphRequest -Url "/deviceManagement/groupPolicyConfigurations/$($obj.id)/definitionValues/$($definitionValue.id)/presentationValues?`$expand=presentation" -ODataMetadata "minimal" @params).value
}
else
{
$presentationValues = (Invoke-GraphRequest -Url "/deviceManagement/groupPolicyConfigurations/$($obj.id)/definitionValues/$($definitionValue.id)/presentationValues?`$expand=presentation" -ODataMetadata "minimal" @params).value
$presentationValues = $null
}
$value = $null
@@ -3674,7 +3678,9 @@ function Invoke-CSVProcessItem
$itemsToExport = $itemsToExport | Select Name,Value | ConvertTo-Csv -NoTypeInformation
}
$itemsToExport | Out-File ($folder + "\$($objName).csv") -Encoding UTF8 -Force
$fileName = $folder + "\$((Remove-InvalidFileNameChars $objName)).csv"
Write-Log "Save documentation to $fileName"
$itemsToExport | Out-File -LiteralPath $fileName -Encoding UTF8 -Force
}
catch
{

View File

@@ -10,7 +10,7 @@ This module will also document some objects based on PowerShell functions
function Get-ModuleVersion
{
'1.0.1'
'1.0.2'
}
function Invoke-InitializeModule
@@ -76,6 +76,16 @@ function Invoke-CDDocumentObject
Properties = @("Name","Value","Category","SubCategory")
}
}
elseif($type -eq '#microsoft.graph.windows10CustomConfiguration' -or
$type -eq '#microsoft.graph.androidForWorkCustomConfiguration' -or
$type -eq '#microsoft.graph.androidWorkProfileCustomConfiguration' -or
$type -eq '#microsoft.graph.androidCustomConfiguration')
{
Invoke-CDDocumentCustomOMAUri $documentationObj
return [PSCustomObject]@{
Properties = @("Name","Value","Category","SubCategory")
}
}
}
function Get-CDAllManagedApps
@@ -2069,7 +2079,7 @@ function Invoke-CDDocumentPolicySet
###################################################
# Basic info
# Settings
###################################################
$addedSettings = @()
@@ -2145,4 +2155,115 @@ function Get-CDDocumentPolicySetValue
}
# ToDo: Add support for all PolicySet items
}
function Invoke-CDDocumentCustomOMAUri
{
param($documentationObj)
$obj = $documentationObj.Object
$objectType = $documentationObj.ObjectType
$script:objectSeparator = ?? $global:cbDocumentationObjectSeparator.SelectedValue ([System.Environment]::NewLine)
$script:propertySeparator = ?? $global:cbDocumentationPropertySeparator.SelectedValue ","
###################################################
# Basic info
###################################################
Add-BasicDefaultValues $obj $objectType
#Add-BasicPropertyValue (Get-LanguageString "TableHeaders.configurationType") (Get-LanguageString "PolicyType.custom")
$platformId = Get-ObjectPlatformFromType $obj
Add-BasicPropertyValue (Get-LanguageString "Inputs.platformLabel") (Get-LanguageString "Platform.$platformId")
###################################################
# Settings
###################################################
$addedSettings = @()
$category = Get-LanguageString "SettingDetails.customPolicyOMAURISettingsName"
foreach($setting in $obj.omaSettings)
{
Add-CustomSettingObject ([PSCustomObject]@{
Name = (Get-LanguageString "TableHeaders.name")
Value = $setting.displayName
EntityKey = "displayName_$($setting.omaUri)"
Category = $category
SubCategory = $setting.displayName
})
Add-CustomSettingObject ([PSCustomObject]@{
Name = (Get-LanguageString "TableHeaders.description")
Value = $setting.description
EntityKey = "description_$($setting.omaUri)"
Category = $category
SubCategory = $setting.displayName
})
Add-CustomSettingObject ([PSCustomObject]@{
Name = (Get-LanguageString "SettingDetails.oMAURIName")
Value = $setting.omaUri
EntityKey = "omaUri_$($setting.omaUri)"
Category = $category
SubCategory = $setting.displayName
})
if($setting.'@OData.Type' -eq '#microsoft.graph.omaSettingString')
{
$value = (Get-LanguageString "SettingDetails.stringName")
}
elseif($setting.'@OData.Type' -eq '#microsoft.graph.omaSettingBase64')
{
$value = (Get-LanguageString "SettingDetails.base64Name")
}
elseif($setting.'@OData.Type' -eq '#microsoft.graph.omaSettingBoolean')
{
$value = (Get-LanguageString "SettingDetails.booleanName")
}
elseif($setting.'@OData.Type' -eq '#microsoft.graph.omaSettingDateTime')
{
$value = (Get-LanguageString "SettingDetails.dateTimeName")
}
elseif($setting.'@OData.Type' -eq '#microsoft.graph.omaSettingFloatingPoint')
{
$value = (Get-LanguageString "SettingDetails.floatingPointName")
}
elseif($setting.'@OData.Type' -eq '#microsoft.graph.omaSettingInteger')
{
$value = (Get-LanguageString "SettingDetails.integerName")
}
elseif($setting.'@OData.Type' -eq '#microsoft.graph.omaSettingStringXml')
{
$value = (Get-LanguageString "SettingDetails.stringXMLName")
}
else
{
$value = $null
}
if($value)
{
Add-CustomSettingObject ([PSCustomObject]@{
Name = (Get-LanguageString "SettingDetails.dataTypeName")
Value = $value
EntityKey = "type_$($setting.omaUri)"
Category = $category
SubCategory = $setting.displayName
})
}
if($setting.isEncrypted -ne $true)
{
Add-CustomSettingObject ([PSCustomObject]@{
Name = (Get-LanguageString "SettingDetails.valueName")
Value = $setting.value
EntityKey = "value_$($setting.omaUri)"
Category = $category
SubCategory = $setting.displayName
})
}
}
}
#endregion

View File

@@ -10,7 +10,7 @@ This module is for the Endpoint Manager/Intune View. It manages Export/Import/Co
#>
function Get-ModuleVersion
{
'3.1.5'
'3.1.6'
}
function Invoke-InitializeModule
@@ -249,6 +249,7 @@ function Invoke-InitializeModule
Id = "AdministrativeTemplates"
API = "/deviceManagement/groupPolicyConfigurations"
ViewID = "IntuneGraphAPI"
PostGetCommand = { Start-PostGetAdministrativeTemplate @args }
PostExportCommand = { Start-PostExportAdministrativeTemplate @args }
PostCopyCommand = { Start-PostCopyAdministrativeTemplate @args }
PostFileImportCommand = { Start-PostFileImportAdministrativeTemplate @args }
@@ -789,7 +790,8 @@ function Start-PostExportEndpointSecurity
$settings = Invoke-GraphRequest -Url "$($objectType.API)/$($obj.id)/settings"
$settingsJson = "{ `"settings`": $((ConvertTo-Json $settings.value -Depth 10 ))`n}"
$settingsJson | Out-File "$path\$((Get-GraphObjectName $obj $objectType))_Settings.json" -Force
$fileName = "$path\$((Remove-InvalidFileNameChars (Get-GraphObjectName $obj $objectType)))_Settings.json"
$settingsJson | Out-File -LiteralPath $fileName -Force
}
function Start-PostFileImportEndpointSecurity
@@ -842,7 +844,7 @@ function Start-PostFileImportDeviceConfiguration
if($obj.'@OData.Type' -like "#microsoft.graph.windows10GeneralConfiguration")
{
$tmpObj = Get-Content $importFile | ConvertFrom-Json
$tmpObj = Get-Content -LiteralPath $importFile | ConvertFrom-Json
if(($tmpObj.privacyAccessControls | measure).Count -gt 0)
{
@@ -976,7 +978,7 @@ function Start-PostExportIntuneBranding
{
if($obj.$imgType.Value)
{
$fileName = "$path\$((Remove-InvalidFileNameChars (Get-GraphObjectName $obj $objectType)))_$imgType.jpg"
$fileName = "$path\$((Get-GraphObjectName $obj $objectType))_$imgType.jpg"
[IO.File]::WriteAllBytes($fileName, [System.Convert]::FromBase64String($obj.$imgType.Value))
}
}
@@ -1095,7 +1097,7 @@ function Start-PostExportScripts
{
Write-Log "Export script $($obj.FileName)"
$fileName = [IO.Path]::Combine($exportPath, $obj.FileName)
[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($obj.scriptContent)) | Out-File $fileName -Force
[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($obj.scriptContent)) | Out-File -LiteralPath $fileName -Force
}
}
@@ -1280,7 +1282,7 @@ function Start-PostFileImportApplications
{
param($obj, $objectType, $file)
$tmpObj = Get-Content $file | ConvertFrom-Json
$tmpObj = Get-Content -LiteralPath $file | ConvertFrom-Json
if(-not $tmpObj.'@odata.type') { return }
@@ -1405,7 +1407,8 @@ function Start-PostExportAdministrativeTemplate
# Collect and save all the settings of the Administrative Templates profile
$settings = Get-GPOObjectSettings $obj
ConvertTo-Json $settings -Depth 10 | Out-File "$path\$((Get-GraphObjectName $obj $objectType))_Settings.json" -Force
$fileName = "$path\$((Remove-InvalidFileNameChars (Get-GraphObjectName $obj $objectType)))_Settings.json"
ConvertTo-Json $settings -Depth 10 | Out-File -LiteralPath $fileName -Force
}
function Start-PostCopyAdministrativeTemplate
@@ -1439,7 +1442,7 @@ function Start-LoadAdministrativeTemplate
$fi = [IO.FileInfo]$fileName
if($fi.Exists -eq $false) { return }
$obj = Get-Content $fi.FullName | ConvertFrom-Json
$obj = Get-Content -LiteralPath $fi.FullName | ConvertFrom-Json
if($obj.definitionValues)
{
@@ -1450,13 +1453,34 @@ function Start-LoadAdministrativeTemplate
if([IO.File]::Exists($settingsFile))
{
$definitionValues = Get-Content $settingsFile | ConvertFrom-Json
$definitionValues = Get-Content -LiteralPath $settingsFile | ConvertFrom-Json
$obj | Add-Member Noteproperty -Name "definitionValues" -Value $definitionValues -Force
}
$obj
}
function Start-PostGetAdministrativeTemplate
{
param($obj, $objectType)
$definitionValues = Get-GPOObjectSettings $obj.Object
if($definitionValues)
{
$obj.Object | Add-Member Noteproperty -Name "definitionValues" -Value $definitionValues -Force
}
<#
# Leave for now. This only loads the configured defenition values and not the values specified.
# That would require enumerating each definition value which takes time.
$definitionValues = (Invoke-GraphRequest "deviceManagement/groupPolicyConfigurations('$($obj.Id)')/definitionValues?`$expand=definition(`$select=id,classType,displayName,policyType,groupPolicyCategoryId)" -ODataMetadata "minimal").value
if($definitionValues)
{
$obj.Object | Add-Member Noteproperty -Name "definitionValues" -Value $definitionValues -Force
}
#>
}
#endregion
#region Policy Sets function
@@ -1510,8 +1534,8 @@ function Start-PostExportRoleDefinitions
{
param($obj, $objectType, $path)
$fileName = "$path\$((Get-GraphObjectName $obj $objectType)).json"
$tmpObj = Get-Content $fileName | ConvertFrom-Json
$fileName = "$path\$((Remove-InvalidFileNameChars (Get-GraphObjectName $obj $objectType))).json"
$tmpObj = Get-Content -LiteralPath $fileName | ConvertFrom-Json
if(($tmpObj.RoleAssignments | measure).Count -gt 0)
{
@@ -1530,7 +1554,7 @@ function Start-PostExportRoleDefinitions
if($roleAssignmentsArr.Count -gt 0)
{
$tmpObj.RoleAssignments = $roleAssignmentsArr
$tmpObj | ConvertTo-Json -Depth 10 | Out-File $fileName
$tmpObj | ConvertTo-Json -Depth 10 | Out-File -LiteralPath $fileName
}
}
}
@@ -1547,7 +1571,7 @@ function Start-PostFileImportRoleDefinitions
{
param($obj, $objectType, $file)
$tmpObj = Get-Content $file | ConvertFrom-Json
$tmpObj = Get-Content -LiteralPath $file | ConvertFrom-Json
$loadedScopeTags = $global:LoadedDependencyObjects["ScopeTags"]
if(($tmpObj.RoleAssignments | measure).Count -gt 0 -and ($loadedScopeTags | measure).Count -gt 0)
@@ -1743,9 +1767,12 @@ function Save-EMDefaultPolicy
if($fileName)
{
$oldFile = "$path\$((Get-GraphObjectName $obj $objectType)).json"
try { [IO.File]::Delete($oldFile) | Out-Null } Catch {}
$obj | ConvertTo-Json -Depth 10 | Out-File "$path\$fileName.json"
if([IO.File]::Exists($oldFile))
{
# Clean up from old version of the script that used the wrong name for Default policies
try { [IO.File]::Delete($oldFile) | Out-Null } Catch {}
}
$obj | ConvertTo-Json -Depth 10 | Out-File -LiteralPath "$path\$((Remove-InvalidFileNameChars $fileName)).json"
}
}
catch {}
@@ -1769,7 +1796,7 @@ function Get-EMSettingsObject
return
}
(Get-Content $fiSettings.FullName) | ConvertFrom-Json
(Get-Content -LiteralPath $fiSettings.FullName) | ConvertFrom-Json
}
else
{
@@ -1781,8 +1808,13 @@ function Add-EMAssignmentsToExportFile
{
param($obj, $objectType, $path, $Url = "")
$fileName = "$path\$((Get-GraphObjectName $obj $objectType)).json"
$tmpObj = Get-Content $fileName | ConvertFrom-Json
$fileName = "$path\$((Remove-InvalidFileNameChars (Get-GraphObjectName $obj $objectType))).json"
if([IO.File]::Exists($fileName) -eq $false)
{
Write-Log "File not found: $fileName. Could not add assignments" 3
return
}
$tmpObj = Get-Content -LiteralPath $fileName | ConvertFrom-Json
if(-not $url)
{
@@ -1799,7 +1831,7 @@ function Add-EMAssignmentsToExportFile
{
$tmpObj.Assignments = $assignments
}
ConvertTo-Json $tmpObj -Depth 10 | Out-File $fileName -Force
ConvertTo-Json $tmpObj -Depth 10 | Out-File -LiteralPath $fileName -Force
}
}

View File

@@ -10,7 +10,7 @@ This module manages Authentication for the application with MSAL. It is also res
#>
function Get-ModuleVersion
{
'3.0.2'
'3.0.3'
}
$global:msalAuthenticator = $null
@@ -830,7 +830,8 @@ function Connect-MSALUser
}
Write-LogDebug "User, tenant or app has changed"
Get-MSALUserInfo
Get-MSALUserInfo
Invoke-ModuleFunction "Invoke-GraphAuthenticationUpdated"
}
}

View File

@@ -124,6 +124,13 @@ function Get-GraphAppInfo
$appObj
}
function Invoke-GraphAuthenticationUpdated
{
$global:MigrationTableCache = $null
$global:LoadedDependencyObjects = $null
$global:migFileObj = $null
}
function Invoke-GraphRequest
{
param (
@@ -661,7 +668,7 @@ function Show-GraphExportForm
}
}
Add-GraphExportExtensions $script:exportForm 1
Add-GraphExportExtensions $script:exportForm 1 $global:curObjectType
Show-ModalForm "Export $($global:curObjectType.Title) objects" $script:exportForm -HideButtons
}
@@ -695,9 +702,9 @@ function Show-GraphBulkExportForm
Selected = (?? $objType.BulkExport $true)
ObjectType = $objType
}
}
Add-GraphExportExtensions $script:exportForm 0
Add-GraphExportExtensions $script:exportForm 0 $objType
}
$column = Get-GridCheckboxColumn "Selected"
$global:dgObjectsToExport.Columns.Add($column)
@@ -979,25 +986,29 @@ function Show-GraphBulkImportForm
function Add-GraphExportExtensions
{
param($form, $buttonIndex = 0)
if($global:curObjectType.ExportExtension)
param($form, $buttonIndex = 0, $objectTypes)
#$global:curObjectType
foreach($objectType in $objectTypes)
{
$grid = $form.FindName("grdExportProperties")
$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.ExportExtension)
{
$grid = $form.FindName("grdExportProperties")
$extraProperties = & $objectType.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])
$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])
}
}
}
}
@@ -1155,7 +1166,7 @@ function Get-GraphFileObjects
}
else
{
$graphObj = (ConvertFrom-Json (Get-Content $file.FullName -Raw))
$graphObj = (ConvertFrom-Json (Get-Content -LiteralPath $file.FullName -Raw))
}
$obj = New-Object PSObject -Property @{
@@ -1470,6 +1481,11 @@ function Add-GraphMigrationObject
$migFileName = Join-Path $path "MigrationTable.json"
if($global:migFileObj -and $global:migFileObj.TenantId -ne $global:organization.Id)
{
$global:migFileObj = $null
}
if(-not $global:migFileObj)
{
if(-not ([IO.File]::Exists($migFileName)))
@@ -1572,14 +1588,14 @@ function Get-GraphMigrationObjectsFromFile
if($global:GraphMigrationTable)
{
$fi = [IO.FileInfo]$global:GraphMigrationTable
$groupFi = [IO.FileInfo]($fi.DirectoryName + "\Groups\$($migObj.DisplayName).json")
$groupFi = [IO.FileInfo]($fi.DirectoryName + "\Groups\$((Remove-InvalidFileNameChars $migObj.DisplayName)).json")
}
if($groupFi.Exists -eq $true)
{
# ToDo: Create group from Json (could be a dynamic group)
# Warn if synched group
$groupObj = (Get-Content $groupFi.FullName) | ConvertFrom-Json
$groupObj = (Get-Content -LiteralPath $groupFi.FullName) | ConvertFrom-Json
#isAssignableToRole - For Role assignment groupd.
$keepProps = @("displayName","description","mailEnabled","mailNickname","securityEnabled","membershipRule","groupTypes", "membershipRuleProcessingState")
@@ -1832,8 +1848,9 @@ function Export-GraphObject
Remove-Property $obj "Assignments"
}
$obj | ConvertTo-Json -Depth 10 | Out-File ([IO.Path]::Combine($exportFolder, (Remove-InvalidFileNameChars "$((Get-GraphObjectName $obj $objectType)).json")))
#$obj | ConvertTo-Json -Depth 10 | Out-File ([IO.Path]::Combine($exportFolder, (Remove-InvalidFileNameChars "$((Get-GraphObjectName $obj $objectType)).json")))
$obj | ConvertTo-Json -Depth 10 | Out-File -LiteralPath ([IO.Path]::Combine($exportFolder, (Remove-InvalidFileNameChars "$((Get-GraphObjectName $obj $objectType)).json")))
if($objectType.PostExportCommand)
{
& $objectType.PostExportCommand $obj $objectType $exportFolder