This commit is contained in:
Mikael Karlsson
2022-08-02 22:22:54 +10:00
parent a60b83ede9
commit 37965cb290
293 changed files with 14781 additions and 10621 deletions

View File

@@ -20,7 +20,7 @@ $global:documentationProviders = @()
function Get-ModuleVersion
{
'1.3.0'
'1.4.0'
}
function Invoke-InitializeModule
@@ -1111,7 +1111,7 @@ function Get-IntentCategory
{
return (Get-LanguageString "SecurityTemplate.diskEncryption")
}
elseif($templateType -eq "???")
elseif($templateType -eq "endpointDetectionReponse")
{
return (Get-LanguageString "SecurityTemplate.eDR")
}
@@ -1123,6 +1123,10 @@ function Get-IntentCategory
{
return (Get-LanguageString "SecurityTemplate.aSR")
}
elseif($templateType -eq "firewall")
{
return (Get-LanguageString "SecurityTemplate.firewall")
}
elseif($templateType -eq "securityBaseline" -or
$templateType -eq "advancedThreatProtectionSecurityBaseline" -or
$templateType -eq "microsoftEdgeSecurityBaseline")
@@ -1367,7 +1371,7 @@ function Get-IntentSettingInfo
elseif($valueObj.'@odata.type' -eq '#microsoft.graph.deviceManagementAbstractComplexSettingInstance' -or
$defObj.'@odata.type' -eq '#microsoft.graph.deviceManagementAbstractComplexSettingDefinition')
{
$tmpDef = $category.settingDefinitions | Where id -eq $rawValue.implementationId
$tmpDef = $category.settingDefinitions | Where { $_.id -eq $rawValue.implementationId -or $_.id -eq $rawValue.'$implementationId' }
if($tmpDef)
{
$itemValue = $tmpDef.displayName
@@ -1634,6 +1638,16 @@ function Invoke-TranslateProfileObject
{
$categoryObj = (Get-Content $fi.FullName -Encoding UTF8) | ConvertFrom-Json
$script:CurrentSubCategory = ""
if($docProvider.TranslateSectionFile)
{
$retObj = & $docProvider.TranslateSectionFile $obj $objectType $fi $categoryObj
if($retObj -is [Boolean] -and $retObj -eq $true)
{
# Handled by custom function
continue
}
}
Invoke-TranslateSection $obj $categoryObj."$($fi.BaseName)" $objInfo
}
catch
@@ -3813,11 +3827,6 @@ function local:Invoke-StartDocumentatiom
if($fromExportFolder -eq $false)
{
$graphObjects = @(Get-GraphObjects -property $objectType.ViewProperties -objectType $objectType)
if($objectType.PostListCommand)
{
$graphObjects = & $objectType.PostListCommand $graphObjects $objectType
}
}
else
{
@@ -3844,7 +3853,7 @@ function local:Invoke-StartDocumentatiom
}
else
{
$sortProps = @((?? $objectType.NameProperty "displayName"))
$sortProps = @({$_.ObjectType.Title}, (?? $objectType.NameProperty "displayName"))
}
$sourceList += $groupSourceList | Sort-Object -Property $sortProps
}
@@ -3895,6 +3904,15 @@ function local:Invoke-StartDocumentatiom
$tmpCurObjectType = $null
$tmpCurObjectGroup = $null
$allObjectTypeObjects = @()
if($objGroup.GroupId -eq "EndpointSecurity")
{
$groupCategoryCount = ($sourceList | ForEach-Object { $_.CategoryName } | Select -Unique).Count
}
else
{
$groupCategoryCount = ($sourceList | ForEach-Object { $_.ObjectType.Id } | Select -Unique).Count
}
foreach($tmpObj in ($sourceList))
{
if($allObjectTypeObjects.Count -gt 0 -and $tmpCurObjectGroup -ne $tmpObj.ObjectType.GroupId -and $tmpCurObjectType -ne $tmpObj.ObjectType.Id)
@@ -3957,19 +3975,27 @@ function local:Invoke-StartDocumentatiom
$ret = & $global:cbDocumentationType.SelectedItem.NewObjectGroup $obj $documentedObj
if($ret -is [boolean] -and $ret -eq $true) { continue }
}
$tmpCurObjectGroup = $obj.ObjectType.GroupId
$tmpCurObjectGroup = $obj.ObjectType.GroupId
}
if($tmpCurObjectType -ne $obj.ObjectType.Id)
if(($objGroup.GroupId -eq "EndpointSecurity" -and $tmpObj.CategoryName -ne $tmpCurObjectType) -or
($objGroup.GroupId -ne "EndpointSecurity" -and $tmpCurObjectType -ne $obj.ObjectType.Id))
{
# New object type e.g Administrative Template, VPN profile etc.
if($global:cbDocumentationType.SelectedItem.NewObjectType)
{
Write-Status "Run NewObjectType for $($global:cbDocumentationType.SelectedItem.Name)"
$ret = & $global:cbDocumentationType.SelectedItem.NewObjectType $obj $documentedObj
$ret = & $global:cbDocumentationType.SelectedItem.NewObjectType $tmpObj $documentedObj $groupCategoryCount
if($ret -is [boolean] -and $ret -eq $true) { continue }
}
$tmpCurObjectType = $obj.ObjectType.Id
if($objGroup.GroupId -eq "EndpointSecurity")
{
$tmpCurObjectType = $tmpObj.CategoryName
}
else
{
$tmpCurObjectType = $obj.ObjectType.Id
}
$allObjectTypeObjects = @()
}
@@ -4042,7 +4068,7 @@ function local:Invoke-StartDocumentatiom
if($global:chkSkipNotConfigured.IsChecked -and $item.Value -eq $notConfiguredLoc)
{
# Skip unconfigured items based on value e.g. value = Not Configured
Write-Log "Skipping property $($itenm.Name) based on '$($notConfiguredLoc)' string value" 2
Write-Log "Skipping property $($item.Name) based on '$($notConfiguredLoc)' string value" 2
continue
}

View File

@@ -10,7 +10,7 @@ This module will also document some objects based on PowerShell functions
function Get-ModuleVersion
{
'1.3.0'
'1.4.0'
}
function Invoke-InitializeModule
@@ -26,6 +26,7 @@ function Invoke-InitializeModule
AddCustomProfileProperty = { Add-CDDocumentCustomProfileProperty @args }
PostAddValue = { Invoke-CDDocumentCustomPostAdd @args }
ObjectDocumented = { Invoke-CDDocumentCustomObjectDocumented @args }
TranslateSectionFile = { Invoke-CDDocumentTranslateSectionFile @args }
})
}
@@ -33,6 +34,8 @@ function Initialize-CDDocumentation
{
$script:allTenantApps = $null
$script:allTermsOfUse = $null
$script:allAuthenticationContextClasses = $null
$script:allCustomCompliancePolicies = $null
}
function Invoke-CDDocumentObject
@@ -145,6 +148,13 @@ function Invoke-CDDocumentObject
Properties = @("Name","Value","Category","SubCategory")
}
}
elseif($type -eq '#microsoft.graph.deviceComplianceScript')
{
Invoke-CDDocumentdeviceComplianceScript $documentationObj
return [PSCustomObject]@{
Properties = @("Name","Value","Category","SubCategory")
}
}
}
function Get-CDAllManagedApps
@@ -2036,7 +2046,7 @@ function Invoke-CDDocumentConditionalAccess
}
Add-CustomSettingObject ([PSCustomObject]@{
Name = $includeLabel
Name = Get-LanguageString "AzureIAM.UserActions.selectionInfo"
Value = $value
Category = $category
SubCategory = $userActionsLabel
@@ -2046,19 +2056,23 @@ function Invoke-CDDocumentConditionalAccess
if($obj.conditions.applications.includeAuthenticationContextClassReferences.Count -gt 0)
{
# Fix better text
$userActionsLabel = Get-LanguageString "AzureIAM.AuthContext.label"
$tmpObjs = @()
if(-not $script:allAuthenticationContextClasses)
{
$script:allAuthenticationContextClasses = (Invoke-GraphRequest -url "/identity/conditionalAccess/authenticationContextClassReferences" -ODataMetadata "minimal").value
}
foreach($id in ($obj.conditions.applications.includeAuthenticationContextClassReferences))
{
$tmpObjs += $id
}
$idObj = $script:allAuthenticationContextClasses | Where Id -eq $id
$tmpObjs += ?? $idObj.displayName $id
}
Add-CustomSettingObject ([PSCustomObject]@{
Name = $includeLabel
Name = Get-LanguageString "AzureIAM.AuthContext.checkBoxInfo"
Value = $tmpObjs -join $script:objectSeparator
Category = $category
SubCategory = $userActionsLabel
SubCategory = Get-LanguageString "AzureIAM.AuthContext.label"
EntityKey = "includeAuthenticationContextClassReferences"
})
}
@@ -3773,4 +3787,131 @@ function Invoke-CDDocumentCustomObjectDocumented
}
}
}
#endregion
#region
function Invoke-CDDocumentTranslateSectionFile
{
param($obj, $objectType, $fileInfo, $categoryObj)
if($obj.'@OData.Type' -eq "#microsoft.graph.windows10CompliancePolicy" -and $fileInfo.BaseName -eq "customcompliance_compliancewindows10")
{
$category = Get-Category $categoryObj."$($fileInfo.BaseName)".category
if($null -eq $obj.deviceCompliancePolicyScript)
{
$propValue = Get-LanguageString "BooleanActions.notConfigured"
}
else
{
$propValue = Get-LanguageString "BooleanActions.require"
}
Add-CustomSettingObject ([PSCustomObject]@{
Name = Get-LanguageString "SettingDetails.adminConfiguredComplianceSettingName"
Value = $propValue
EntityKey = "deviceCompliancePolicyScript"
Category = $category
SubCategory = $null
})
if($obj.deviceCompliancePolicyScript)
{
if($null -eq $script:allCustomCompliancePolicies)
{
$script:allCustomCompliancePolicies = (Invoke-GraphRequest -url "/deviceManagement/deviceComplianceScripts?`$select=displayName,id" -ODataMetadata "minimal").value
}
$customScript = $script:allCustomCompliancePolicies | Where Id -eq $obj.deviceCompliancePolicyScript.deviceComplianceScriptId
Add-CustomSettingObject ([PSCustomObject]@{
Name = Get-LanguageString "CustomCompliance.FilePicker.scriptFileLabel"
Value = $customScript.displayName
EntityKey = "deviceComplianceScriptName"
Category = $category
SubCategory = $null
})
if($obj.deviceCompliancePolicyScript.rulesContent)
{
$propValue = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($obj.deviceCompliancePolicyScript.rulesContent))
Add-CustomSettingObject ([PSCustomObject]@{
Name = Get-LanguageString "CustomCompliance.UploadFile.jsonFileLabel"
Value = $propValue
EntityKey = "jsonFileContent"
Category = $category
SubCategory = $null
})
}
}
return $true
}
return $false
}
#endregion
#region
function Invoke-CDDocumentdeviceComplianceScript
{
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
if($obj.publisher)
{
Add-BasicPropertyValue (Get-LanguageString "SettingDetails.publisher") $obj.publisher
}
Add-BasicAdditionalValues $obj $objectType
Add-BasicPropertyValue (Get-LanguageString "TableHeaders.configurationType") (Get-LanguageString "Titles.complianceScriptManagementPreview")
$category = Get-LanguageString "TableHeaders.settings"
$valueYes = Get-LanguageString "BooleanActions.yes"
$valueNo = Get-LanguageString "SettingDetails.no"
if($obj.detectionScriptContent)
{
$propValue = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($obj.detectionScriptContent))
Add-CustomSettingObject ([PSCustomObject]@{
Name = Get-LanguageString "ProactiveRemediations.Create.Settings.DetectionScriptMultiLineTextBox.label"
Value = $propValue
EntityKey = "detectionScriptContent"
Category = $category
SubCategory = $null
})
}
Add-CustomSettingObject ([PSCustomObject]@{
Name = Get-LanguageString "WindowsManagement.scriptContextLabel"
Value = (?: ($obj.runAsAccount -eq "system") $valueNo $valueYes)
EntityKey = "runAsAccount"
Category = $category
SubCategory = $null
})
Add-CustomSettingObject ([PSCustomObject]@{
Name = Get-LanguageString "WindowsManagement.enforceSignatureCheckLabel"
Value = (?: ($obj.enforceSignatureCheck -eq $false) $valueNo $valueYes)
EntityKey = "enforceSignatureCheck"
Category = $category
SubCategory = $null
})
Add-CustomSettingObject ([PSCustomObject]@{
Name = Get-LanguageString "WindowsManagement.runAs64BitLabel"
Value = (?: ($obj.runAs32Bit -eq $true) $valueNo $valueYes)
EntityKey = "runAs32Bit"
Category = $category
SubCategory = $null
})
}
#endregion

View File

@@ -3,7 +3,7 @@
#https://docs.microsoft.com/en-us/office/vba/api/overview/word
function Get-ModuleVersion
{
'1.2.0'
'1.3.0'
}
function Invoke-InitializeModule
@@ -28,6 +28,7 @@ function Invoke-InitializeModule
Activate = { Invoke-WordActivate @args }
PreProcess = { Invoke-WordPreProcessItems @args }
NewObjectGroup = { Invoke-WordNewObjectGroup @args }
NewObjectType = { Invoke-WordNewObjectType @args }
Process = { Invoke-WordProcessItem @args }
PostProcess = { Invoke-WordPostProcessItems @args }
ProcessAllObjects = { Invoke-WordProcessAllObjects @args }
@@ -51,7 +52,7 @@ function Add-WordOptionsControl
$global:gdWordDocumentationLimitOptions.Visibility = (?: ($global:cbWordDocumentationLevel.SelectedValue -ne "limited") "Collapsed" "Visible")
$global:txtWordDocumentationLimitMaxLength.Text = Get-Setting "Documentation" "WordDocumentationLimitMaxLength" ""
$global:txtWordDocumentationLimitTruncateLength.Text = Get-Setting "Documentation" "WordDocumentationLimitTruncateLength" ""
$global:chkWordDocumentationLimitAttatch.IsChecked = ((Get-Setting "Documentation" "WordDocumentationLimitAttatch" "true") -ne "false")
$global:chkWordDocumentationLimitAttach.IsChecked = ((Get-Setting "Documentation" "WordDocumentationLimitAttatch" "true") -ne "false")
$global:txtWordDocumentTemplate.Text = Get-Setting "Documentation" "WordDocumentTemplate" ""
$global:txtWordDocumentName.Text = (Get-Setting "Documentation" "WordDocumentName" "%MyDocuments%\%Organization%-%Date%.docx")
@@ -61,6 +62,7 @@ function Add-WordOptionsControl
$global:txtWordHeader1Style.Text = Get-Setting "Documentation" "WordHeader1Style" "Heading 1"
$global:txtWordHeader2Style.Text = Get-Setting "Documentation" "WordHeader2Style" "Heading 2"
$global:txtWordHeader3Style.Text = Get-Setting "Documentation" "WordHeader3Style" "Heading 3"
$global:txtWordTableStyle.Text = Get-Setting "Documentation" "WordTableStyle" "Grid table 4 - Accent 3"
$global:txtWordTableHeaderStyle.Text = Get-Setting "Documentation" "WordTableHeaderStyle" ""
$global:txtWordCategoryHeaderStyle.Text = Get-Setting "Documentation" "WordCategoryHeaderStyle" ""
@@ -76,7 +78,7 @@ function Add-WordOptionsControl
$global:chkWordIncludeScripts.IsChecked = ((Get-Setting "Documentation" "WordIncludeScripts" "true") -ne "false")
$global:chkWordExcludeScriptSignature.IsChecked = ((Get-Setting "Documentation" "WordExcludeScriptSignature" "false") -ne "false")
$global:chkWordAttatchJsonFile.IsChecked = ((Get-Setting "Documentation" "WordAttatchJsonFile" "false") -ne "false")
$global:chkWordAttachJsonFile.IsChecked = ((Get-Setting "Documentation" "WordAttatchJsonFile" "false") -ne "false")
$global:txtWordScriptTableStyle.Text = Get-Setting "Documentation" "WordScriptTableStyle" ""
$global:txtWordScriptStyle.Text = Get-Setting "Documentation" "WordScriptStyle"
@@ -120,7 +122,7 @@ function Invoke-WordPreProcessItems
Save-Setting "Documentation" "WordDocumentationLevel" $global:cbWordDocumentationLevel.SelectedValue
Save-Setting "Documentation" "WordDocumentationLimitMaxLength" $global:txtWordDocumentationLimitMaxLength.Text
Save-Setting "Documentation" "WordDocumentationLimitTruncateLength" $global:txtWordDocumentationLimitTruncateLength.Text
Save-Setting "Documentation" "WordDocumentationLimitAttatch" $global:chkWordDocumentationLimitAttatch.IsChecked
Save-Setting "Documentation" "WordDocumentationLimitAttatch" $global:chkWordDocumentationLimitAttach.IsChecked
Save-Setting "Documentation" "WordAddCategories" $global:chkWordAddCategories.IsChecked
Save-Setting "Documentation" "WordAddSubCategories" $global:chkWordAddSubCategories.IsChecked
@@ -128,6 +130,7 @@ function Invoke-WordPreProcessItems
Save-Setting "Documentation" "WordHeader1Style" $global:txtWordHeader1Style.Text
Save-Setting "Documentation" "WordHeader2Style" $global:txtWordHeader2Style.Text
Save-Setting "Documentation" "WordHeader3Style" $global:txtWordHeader3Style.Text
Save-Setting "Documentation" "WordTableStyle" $global:txtWordTableStyle.Text
Save-Setting "Documentation" "WordTableHeaderStyle" $global:txtWordTableHeaderStyle.Text
Save-Setting "Documentation" "WordCategoryHeaderStyle" $global:txtWordCategoryHeaderStyle.Text
@@ -141,7 +144,7 @@ function Invoke-WordPreProcessItems
Save-Setting "Documentation" "WordIncludeScripts" $global:chkWordIncludeScripts.IsChecked
Save-Setting "Documentation" "WordExcludeScriptSignature" $global:chkWordExcludeScriptSignature.IsChecked
Save-Setting "Documentation" "WordAttatchJsonFile" $global:chkWordAttatchJsonFile.IsChecked
Save-Setting "Documentation" "WordAttatchJsonFile" $global:chkWordAttachJsonFile.IsChecked
Save-Setting "Documentation" "WordScriptTableStyle" $global:txtWordScriptTableStyle.Text
Save-Setting "Documentation" "WordScriptStyle" $global:txtWordScriptStyle.Text
@@ -465,11 +468,44 @@ function Invoke-WordNewObjectGroup
{
param($obj, $documentedObj)
$script:objectHeaderLevel = 2
$objectTypeString = Get-ObjectTypeString $obj.Object $obj.ObjectType
Add-DocText (?? $objectTypeString $obj.ObjectType.Title) $global:txtWordHeader1Style.Text
}
function Invoke-WordNewObjectType
{
param($obj, $documentedObj, [int]$groupCategoryCount = 0)
if($groupCategoryCount -le 1 -or -not $global:txtWordHeader3Style.Text) { return }
$script:objectHeaderLevel = 2
if($obj.ObjectType.GroupId -eq "EndpointSecurity")
{
$objectTypeString = $obj.CategoryName
}
else
{
$objectTypeString = $obj.ObjectType.Title
}
Add-DocText (?? $objectTypeString $obj.ObjectType.Title) (Get-ObjectLevelHeader)
$script:objectHeaderLevel = 3;
}
function local:Get-ObjectLevelHeader
{
if($script:objectHeaderLevel -eq 3 -and $global:txtWordHeader3Style.Text)
{
return $global:txtWordHeader3Style.Text
}
return $global:txtWordHeader2Style.Text
}
function Invoke-WordProcessItem
{
param($obj, $objectType, $documentedObj)
@@ -478,7 +514,7 @@ function Invoke-WordProcessItem
$objName = Get-GraphObjectName $obj $objectType
Add-DocText $objName $global:txtWordHeader2Style.Text
Add-DocText $objName (Get-ObjectLevelHeader)
$script:doc.Application.Selection.TypeParagraph()
@@ -604,7 +640,7 @@ function Invoke-WordProcessItem
}
}
if($global:chkWordAttatchJsonFile.IsChecked -eq $true)
if($global:chkWordAttachJsonFile.IsChecked -eq $true)
{
$fileName = Export-GraphObject $obj $objectType ([IO.Path]::GetTempPath()) -IsFullObject -PassThru -SkipAddID
if($fileName)
@@ -676,7 +712,7 @@ function Invoke-WordProcessAllObjects
{
$objTypeName = Get-LanguageString "SettingDetails.scopeTags"
Add-DocText $objTypeName $global:txtWordHeader2Style.Text
Add-DocText $objTypeName (Get-ObjectLevelHeader)
$script:doc.Application.Selection.TypeParagraph()
@@ -784,7 +820,7 @@ function Add-DocTableItems
if($script:truncateValueLength -gt 0)
{
$propValue = ($propValue.Substring(0, $script:truncateValueLength) + "...")
if($global:chkWordDocumentationLimitAttatch.IsChecked -eq $true)
if($global:chkWordDocumentationLimitAttach.IsChecked -eq $true)
{
$propValue = ("`r`n" + $propValue)
}
@@ -800,7 +836,7 @@ function Add-DocTableItems
$script:docTable.Cell($row, $i).Range.Text = $propValue
}
if($propValueFull -and $global:chkWordDocumentationLimitAttatch.IsChecked -eq $true)
if($propValueFull -and $global:chkWordDocumentationLimitAttach.IsChecked -eq $true)
{
if($null -ne $propValue)
{

View File

@@ -11,7 +11,7 @@ This module is for the Endpoint Manager/Intune View. It manages Export/Import/Co
#>
function Get-ModuleVersion
{
'3.6.0'
'3.7.0'
}
function Invoke-InitializeModule
@@ -180,12 +180,22 @@ function Invoke-InitializeModule
Expand = "scheduledActionsForRule(`$expand=scheduledActionConfigurations)"
API = "/deviceManagement/deviceCompliancePolicies"
Permissons=@("DeviceManagementConfiguration.ReadWrite.All")
Dependencies = @("Locations","Notifications")
Dependencies = @("Locations","Notifications","ComplianceScripts")
PostExportCommand = { Start-PostExportCompliancePolicies @args }
PreUpdateCommand = { Start-PreUpdateCompliancePolicies @args }
GroupId = "CompliancePolicies"
})
Add-ViewItem (New-Object PSObject -Property @{
Title = "Compliance Scripts"
Id = "ComplianceScripts"
ViewID = "IntuneGraphAPI"
API = "/deviceManagement/deviceComplianceScripts"
Permissons=@("DeviceManagementConfiguration.ReadWrite.All")
GroupId = "CompliancePolicies"
Icon = "Scripts"
})
Add-ViewItem (New-Object PSObject -Property @{
Title = "Intune Branding"
Id = "IntuneBranding"
@@ -644,6 +654,7 @@ function Invoke-InitializeModule
AssignmentsType = "deviceHealthScriptAssignments"
PropertiesToRemoveForUpdate = @('version','isGlobalScript','highestAvailableVersion')
})
}
function Invoke-EMAuthenticateToMSAL
@@ -1655,7 +1666,13 @@ function Start-PostImportAppProtection
$tmp = $newObject."@odata.type".Split('.')[-1]
$objectClass = Get-GraphObjectClassName $tmp
Invoke-GraphRequest -Url "/deviceAppManagement/$objectClass/$($obj.Id)/targetApps" -Content "{ apps: $(ConvertTo-Json $global:ImportObjectInfo.Apps -Depth 20)}" -HttpMethod POST | Out-Null
$apps = [PSCustomObject]@{
appGroupType = $obj.appGroupType
apps = @($global:ImportObjectInfo.Apps)
}
$json = $apps | ConvertTo-Json -Depth 20
Invoke-GraphRequest -Url "/deviceAppManagement/$objectClass/$($obj.Id)/targetApps" -Content $json -HttpMethod POST | Out-Null
}
catch {}
}
@@ -1683,7 +1700,11 @@ function Start-PreUpdateAppConfigurationApp
{
Write-Log "Update App Configuruation Apps"
$json = [PSCustomObject]@{ apps = @($obj.Apps) } | ConvertTo-Json -Depth 10
$apps = [PSCustomObject]@{
appGroupType = $obj.appGroupType
apps = @($obj.Apps)
}
$json = $apps | ConvertTo-Json -Depth 20
$objectClass = 'targetedManagedAppConfigurations'
Invoke-GraphRequest -Url "/deviceAppManagement/$objectClass/$($curObject.Object.Id)/targetApps" -Content $json -HttpMethod POST | Out-Null
@@ -1724,8 +1745,12 @@ function Start-PreUpdateAppProtection
try
{
Write-Log "Update App Protection Apps"
$json = [PSCustomObject]@{ apps = @($obj.Apps) } | ConvertTo-Json -Depth 10
$apps = [PSCustomObject]@{
appGroupType = $obj.appGroupType
apps = @($obj.Apps)
}
$json = $apps | ConvertTo-Json -Depth 20
Invoke-GraphRequest -Url "$api/targetApps" -Content $json -HttpMethod POST | Out-Null
}

View File

@@ -10,7 +10,7 @@ This module manages Authentication for the application with MSAL. It is also res
#>
function Get-ModuleVersion
{
'3.6.0'
'3.7.0'
}
$global:msalAuthenticator = $null
@@ -241,9 +241,11 @@ function Get-MSALUserInfo
if($global:Organization -is [array]) { $global:Organization = $global:Organization[0]}
Save-Setting $global:Organization.Id "_Name" $global:Organization.displayName
}
Set-EnvironmentInfo $global:Organization.displayName
}
else
{
Set-EnvironmentInfo
$global:Me = $null
$global:profilePhoto = $null
$global:Organization = $null

View File

@@ -10,7 +10,7 @@ This module manages Microsoft Grap fuctions like calling APIs, managing graph ob
#>
function Get-ModuleVersion
{
'3.6.0'
'3.7.0'
}
$global:MSGraphGlobalApps = @(
@@ -138,14 +138,6 @@ function Invoke-InitializeModule
Description = "Default value for Import Scope (Tags) when importing objects"
}) "ImportExport"
Add-SettingsObject (New-Object PSObject -Property @{
Title = "Allow update on import (Preview)"
Key = "AllowUpdate"
Type = "Boolean"
DefaultValue = $false
Description = "This will enable the option to update/replace an existing object during import"
}) "ImportExport"
Add-SettingsObject (New-Object PSObject -Property @{
Title = "Add ID to export file"
Key = "AddIDToExportFile"
@@ -1575,11 +1567,8 @@ function Show-GraphImportForm
Set-XamlProperty $script:importForm "cbImportType" "ItemsSource" $script:lstImportTypes
Set-XamlProperty $script:importForm "cbImportType" "SelectedValue" (Get-SettingValue "ImportType" "alwaysImport")
if((Get-SettingValue "AllowUpdate") -eq $true)
{
Set-XamlProperty $script:importForm "lblImportType" "Visibility" "Visible"
Set-XamlProperty $script:importForm "cbImportType" "Visibility" "Visible"
}
Set-XamlProperty $script:importForm "lblImportType" "Visibility" "Visible"
Set-XamlProperty $script:importForm "cbImportType" "Visibility" "Visible"
$column = Get-GridCheckboxColumn "Selected"
$global:dgObjectsToImport.Columns.Add($column)
@@ -1620,8 +1609,8 @@ function Show-GraphImportForm
Add-XamlEvent $script:importForm "btnImportSelected" "add_click" {
Write-Status "Import objects"
Get-GraphDependencyDefaultObjects
$allowUpdate = ((Get-SettingValue "AllowUpdate") -eq $true)
#Get-GraphDependencyDefaultObjects
$allowUpdate = $true
$filesToImport = $global:dgObjectsToImport.ItemsSource | Where Selected -eq $true
if($global:curObjectType.PreFilesImportCommand)
{
@@ -1650,7 +1639,7 @@ function Show-GraphImportForm
if($importedObjectsCurType -gt 0 -and $global:LoadedDependencyObjects -is [HashTable] -and $global:LoadedDependencyObjects.ContainsKey($global:curObjectType.Id))
{
Write-Log "Remove $($global:curObjectType.Title) from dependency cahce"
Write-Log "Remove $($global:curObjectType.Title) from dependency cache"
$global:LoadedDependencyObjects.Remove($global:curObjectType.Id)
}
@@ -1707,11 +1696,8 @@ function Show-GraphBulkImportForm
Set-XamlProperty $script:importForm "cbImportType" "SelectedValue" (Get-SettingValue "ImportType" "alwaysImport")
#Set-XamlProperty $script:importForm "txtImportNameFilter" "Text" (Get-Setting "" "ImportNameFilter")
if((Get-SettingValue "AllowUpdate") -eq $true)
{
Set-XamlProperty $script:importForm "lblImportType" "Visibility" "Visible"
Set-XamlProperty $script:importForm "cbImportType" "Visibility" "Visible"
}
Set-XamlProperty $script:importForm "lblImportType" "Visibility" "Visible"
Set-XamlProperty $script:importForm "cbImportType" "Visibility" "Visible"
Add-XamlEvent $script:importForm "browseImportPath" "add_click" ({
$folder = Get-Folder (Get-XamlProperty $script:importForm "txtImportPath" "Text") "Select root folder for import"
@@ -1828,14 +1814,13 @@ function Start-GraphObjectImport
$tmpFolder = Expand-FileName (Get-XamlProperty $script:importForm "txtImportPath" "Text")
Write-Log "Import root folder: $tmpFolder"
Get-GraphDependencyDefaultObjects
$importedObjects = 0
$txtNameFilter = $global:txtImportNameFilter.Text.Trim()
Save-Setting "" "ImportNameFilter" $txtNameFilter
if($txtNameFilter) { Write-Log "Name filter: $txtNameFilter" }
$allowUpdate = ((Get-SettingValue "AllowUpdate") -eq $true)
$allowUpdate = $true
foreach($item in ($script:importObjects | where Selected -eq $true | sort-object -property @{e={$_.ObjectType.ImportOrder}}))
{
@@ -1900,7 +1885,7 @@ function Start-GraphObjectImport
if($importedObjectsCurType -gt 0 -and $global:LoadedDependencyObjects -is [HashTable] -and $global:LoadedDependencyObjects.ContainsKey($item.ObjectType.Id))
{
Write-Log "Remove $($item.ObjectType.Title) from dependency cahce"
Write-Log "Remove $($item.ObjectType.Title) from dependency cache"
$global:LoadedDependencyObjects.Remove($item.ObjectType.Id)
}
Save-Setting "" "LastUsedFullPath" $folder
@@ -2456,7 +2441,7 @@ function Set-ScopeTags
$scopesIds = @()
$loadedScopeTags = $global:LoadedDependencyObjects["ScopeTags"]
$usingDefault = (($obj."$scopeTagProperty" | measure).Count -eq 1 -and ($obj."$scopeTagProperty")[0] -eq "0")
if($loadedScopeTags -and $global:chkImportScopes.IsChecked -eq $true -and $usingDefault -eq $false -and $global:MigrationTableCache)
if($loadedScopeTags -and $global:chkImportScopes.IsChecked -eq $true -and $usingDefault -eq $false -and $loadedScopeTags)
{
foreach($scopeId in $obj."$scopeTagProperty")
{
@@ -2864,6 +2849,8 @@ function Get-GraphDependencyObjects
{
param($objectType)
Get-GraphDependencyDefaultObjects
if($global:chkReplaceDependencyIDs.IsChecked -ne $true -or -not $objectType -or -not $objectType.Dependencies -or (($objectType.Dependencies) | Measure).Count -eq 0) { return }
$missingDeps = @()
@@ -2897,6 +2884,7 @@ function Add-GraphDependencyObjects
if(-not $depObjectType)
{
Write-Log "No ViewItem found with Id $dep" 2
$global:LoadedDependencyObjects.Add($dep,$null)
continue
}
@@ -2911,6 +2899,7 @@ function Add-GraphDependencyObjects
else
{
Write-Log "Export folder for dependency $dep not found" 2
$global:LoadedDependencyObjects.Add($depObjectType.Id,$null)
continue
}
@@ -3056,7 +3045,7 @@ function Export-GraphObject
Remove-Property $obj "Assignments"
}
$fileName = Get-GraphObjectName $obj $objectType
$fileName = (Get-GraphObjectName $obj $objectType).Trim('.')
if($SkipAddID -ne $true -and (Get-SettingValue "AddIDToExportFile") -eq $true -and $obj.Id -and $objectType.SkipAddIDOnExport -ne $true)
{
$fileName = ($fileName + "_" + $obj.Id)
@@ -3258,13 +3247,13 @@ function Get-GraphBatchObjects
{
param($objects, $txtNameFilter)
$curBatch = 1
$batchArr = @()
$curBatch = 1
$batchResults = @()
$batchArr = @()
$batchTotal = 0
$objectType = $null
foreach($obj in $objects)
{
{
$objectType = $obj.ObjectType
$objName = Get-GraphObjectName $obj.Object $obj.ObjectType
@@ -3290,28 +3279,75 @@ function Get-GraphBatchObjects
}
Write-Status "Get batch $curBatch $($obj.ObjectType.Title)" -Force
$batchTotal += $batchArr.Count
$batchTotal += $batchArr.Count
$json = $batchObj | ConvertTo-Json -Depth 50
$tmpResults = Invoke-GraphRequest -Url "`$batch" -Content $json -HttpMethod "POST" -Batch #-Url $api -property $obj.ObjectType.ViewProperties -objectType $obj.ObjectType -
$curResp = 1
foreach($batchResult in ($tmpResults.responses | Sort -Property Id))
$maxRetryCount = 10
$curRetry = 0
do
{
if($batchResult.Status -ne "200" -or -not $batchResult.body)
$retry = $false
$retryArr = @()
$retryAfter = 0
$tmpResults = Invoke-GraphRequest -Url "`$batch" -Content $json -HttpMethod "POST" -Batch #-Url $api -property $obj.ObjectType.ViewProperties -objectType $obj.ObjectType -
foreach($batchResult in ($tmpResults.responses | Sort -Property Id))
{
$reqObj = $batchObj.requests | where id -eq $batchResult.Id
Write-Log "Batch result $($batchResult.Status) for URL $($reqObj.URL). Skipping..." 2
continue
if($batchResult.Status -ne "200" -or -not $batchResult.body)
{
$reqObj = $batchObj.requests | where id -eq $batchResult.Id
if($batchResult.Status -eq 429 -and $reqObj)
{
if($batchResult.headers.'Retry-After' -and $batchResult.headers.'Retry-After' -gt $retryAfter)
{
try
{
$retryAfter = [int]$batchResult.headers.'Retry-After'
}
catch{}
}
$retryArr += $reqObj
}
else
{
Write-Log "Batch result $($batchResult.Status) for URL $($reqObj.URL). Skipping..." 2
}
continue
}
$batchResults += $batchResult.body
}
$batchResults += $batchResult.body
$curResp++
}
if($retryArr.Count -gt 0)
{
$curRetry++
if($curRetry -gt $maxRetryCount)
{
Write-Log "Max retry reached for batch process. Aborting..." 3
}
else
{
if($retryAfter -lt 5) { $retryAfter = 5 }
Write-Log "Batch result returned 429 - 'Too many requests'. Retrying $($retryArr.Count). Wait for $($retryAfter) seconds." 2
$retry = $true
$tmpBatchObj = [PSCustomObject]@{
requests = $retryArr
}
$json = $tmpBatchObj | ConvertTo-Json -Depth 50
Start-Sleep -Seconds $retryAfter
}
}
}while($retry)
$curBatch++
$batchArr = @()
}
}
if($batchResults.Count -ne $objects.Count)
{
Write-Log "Not all batch objects returned. Expected $($objects.Count) but only got $($batchResults.Count)"
}
if($objectType -and $batchResults.Count -gt 0)
{
$batchResultsTmp = $batchResults