3.9.0
This commit is contained in:
@@ -11,7 +11,7 @@ Objects can be compared based on Properties or Documentatation info.
|
||||
|
||||
function Get-ModuleVersion
|
||||
{
|
||||
'1.0.10'
|
||||
'1.0.11'
|
||||
}
|
||||
|
||||
function Invoke-InitializeModule
|
||||
@@ -516,7 +516,11 @@ function Start-BulkCompareExportObjects
|
||||
Write-Log "****************************************************************"
|
||||
$compareObjectsResult = @()
|
||||
|
||||
$txtNameFilter = (Get-XamlProperty $global:ccContentProviderOptions.Content "txtCompareNameFilter" "Text").Trim()
|
||||
$txtNameFilter = (Get-XamlProperty $global:ccContentProviderOptions.Content "txtCompareNameFilter" "Text")
|
||||
if($txtNameFilter -is [String])
|
||||
{
|
||||
$txtNameFilter = $txtNameFilter.Trim()
|
||||
}
|
||||
$rootFolder = (Get-XamlProperty $global:ccContentProviderOptions.Content "txtExportPath" "Text")
|
||||
|
||||
$compareProps = $script:defaultCompareProps
|
||||
|
||||
@@ -20,7 +20,7 @@ $global:documentationProviders = @()
|
||||
|
||||
function Get-ModuleVersion
|
||||
{
|
||||
'2.0.0'
|
||||
'2.0.1'
|
||||
}
|
||||
|
||||
function Invoke-InitializeModule
|
||||
@@ -1300,6 +1300,12 @@ function Get-IntentCategory
|
||||
{
|
||||
param($templateType)
|
||||
|
||||
if(-not $templateType)
|
||||
{
|
||||
Write-Log "Get-IntentCategory called with empty Category" 2
|
||||
return
|
||||
}
|
||||
|
||||
if($templateType.StartsWith("endpointSecurity"))
|
||||
{
|
||||
$templateType = $templateType.Substring(16)
|
||||
@@ -3588,7 +3594,7 @@ function Invoke-TranslateAssignments
|
||||
$hours = ($endTime.ToUniversalTime() - $endTime).Hours
|
||||
$endTime = $endTime.AddHours($hours)
|
||||
}
|
||||
$value = "$($instTime.ToShortDateString()) $($instTime.ToShortTimeString())"
|
||||
$value = "$($endTime.ToShortDateString()) $($endTime.ToShortTimeString())"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ This module will also document some objects based on PowerShell functions
|
||||
|
||||
function Get-ModuleVersion
|
||||
{
|
||||
'1.5.0'
|
||||
'1.6.0'
|
||||
}
|
||||
|
||||
function Invoke-InitializeModule
|
||||
@@ -1198,6 +1198,8 @@ function Add-CDDocumentCustomProfileProperty
|
||||
$requirementRulesSummary = @()
|
||||
$detectionRulesSummary = @()
|
||||
$returnCodes = @()
|
||||
$detectionRules = @()
|
||||
$requirementRules = @()
|
||||
foreach($rc in $obj.returnCodes)
|
||||
{
|
||||
$returnCodes += [PSCustomObject]@{
|
||||
@@ -1245,6 +1247,8 @@ function Add-CDDocumentCustomProfileProperty
|
||||
Add-ObjectScript $rule.displayName ("{0} - {1}" -f @($obj.displayName, "Requirement script")) $rule.ScriptContent
|
||||
}
|
||||
$requirementRulesSummary += ("{0} {1}" -f @((Get-LanguageString "Win32Requirements.AdditionalRequirements.RequirementTypeOptions.$lngId"),$textValue))
|
||||
|
||||
$requirementRules += Add-CDDocumentRequirementRule $rule
|
||||
}
|
||||
|
||||
if(($obj.detectionRules | Where '@OData.Type' -eq "#microsoft.graph.win32LobAppPowerShellScriptDetection"))
|
||||
@@ -1259,6 +1263,7 @@ function Add-CDDocumentCustomProfileProperty
|
||||
else
|
||||
{
|
||||
$detectionRulesType = Get-LanguageString "DetectionRules.RuleConfigurationOptions.manual"
|
||||
|
||||
foreach($rule in $obj.detectionRules)
|
||||
{
|
||||
if($rule.'@OData.Type' -eq "#microsoft.graph.win32LobAppFileSystemDetection")
|
||||
@@ -1276,7 +1281,10 @@ function Add-CDDocumentCustomProfileProperty
|
||||
$lngId = "mSI"
|
||||
$textValue = $rule.productCode
|
||||
}
|
||||
|
||||
$detectionRulesSummary += ("{0} {1}" -f @((Get-LanguageString "DetectionRules.Manual.RuleTypeOptions.$lngId"),$textValue))
|
||||
|
||||
$detectionRules += Add-CDDocumentDetectionRule $rule
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1285,6 +1293,8 @@ function Add-CDDocumentCustomProfileProperty
|
||||
$obj | Add-Member Noteproperty -Name "dependencyApps" -Value ($dependencyApps -join $objSeparator) -Force
|
||||
$obj | Add-Member Noteproperty -Name "supersededApps" -Value ($supersededApps -join $objSeparator) -Force
|
||||
$obj | Add-Member Noteproperty -Name "detectionRulesType" -Value $detectionRulesType -Force
|
||||
$obj | Add-Member Noteproperty -Name "requirementRulesTranslated" -Value $requirementRules -Force
|
||||
$obj | Add-Member Noteproperty -Name "detectionRulesTranslated" -Value $detectionRules -Force
|
||||
$obj | Add-Member Noteproperty -Name "returnCodes" -Value $returnCodes -Force
|
||||
$obj | Add-Member Noteproperty -Name "win10Release" -Value (Get-LanguageString "MinimumOperatingSystem.Windows.V10Release.release$($obj.minimumSupportedWindowsRelease)") -Force
|
||||
}
|
||||
@@ -1425,6 +1435,390 @@ function Add-CDDocumentCustomProfileProperty
|
||||
return $retValue
|
||||
}
|
||||
|
||||
function Add-CDDocumentRequirementRule
|
||||
{
|
||||
param($rule)
|
||||
|
||||
$strYes = Get-LanguageString "SettingDetails.yes"
|
||||
$strNo = Get-LanguageString "SettingDetails.no"
|
||||
|
||||
$ruleInfo = @()
|
||||
|
||||
if($rule.'@OData.Type' -eq "#microsoft.graph.win32LobAppFileSystemRequirement")
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.requirementType")
|
||||
value = (Get-LanguageString "Win32Requirements.AdditionalRequirements.RequirementTypeOptions.fileType")
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.FileRule.path")
|
||||
value = $rule.path
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.FileRule.fileOrFolder")
|
||||
value = $rule.fileOrFolderName
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.File.property")
|
||||
value = switch($rule.detectionType)
|
||||
{
|
||||
"createdDate" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.dateCreated") }
|
||||
"modifiedDate" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.dateModified") }
|
||||
"doesNotExist" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.doesNotExist") }
|
||||
"exists" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.fileOrFolderExists") }
|
||||
"sizeInMB" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.sizeInMB") }
|
||||
"version" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.version") }
|
||||
Default { Get-LanguageString "BooleanActions.notConfigured" }
|
||||
}
|
||||
}
|
||||
|
||||
if($rule.detectionValue -and $rule.operator)
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.FileRule.operator")
|
||||
value = (Get-CDDocumentOperatorString $rule.operator)
|
||||
}
|
||||
|
||||
$detectionValue = $rule.detectionValue
|
||||
if($rule.detectionType -eq "createdDate" -or $rule.detectionType -eq "modifiedDate")
|
||||
{
|
||||
try {
|
||||
$tmpDate = Get-Date $rule.detectionValue
|
||||
$detectionValue = $tmpDate.ToString()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.FileRule.value")
|
||||
value = $detectionValue
|
||||
}
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.associatedWith32Bit")
|
||||
value = (?: ($rule.check32BitOn64System -eq $true) ($strYes) ($strNo))
|
||||
}
|
||||
}
|
||||
elseif($rule.'@OData.Type' -eq "#microsoft.graph.win32LobAppRegistryRequirement")
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.requirementType")
|
||||
value = (Get-LanguageString "Win32Requirements.AdditionalRequirements.RequirementTypeOptions.registry")
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Registry.keyPath")
|
||||
value = $rule.keyPath
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Registry.valueName")
|
||||
value = $rule.valueName
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Registry.registryRequirement")
|
||||
value = switch($rule.detectionType)
|
||||
{
|
||||
"doesNotExist"
|
||||
{
|
||||
if($rule.valueName)
|
||||
{
|
||||
(Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.valueDoesNotExist")
|
||||
}
|
||||
else
|
||||
{
|
||||
(Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.keyDoesNotExist")
|
||||
}
|
||||
}
|
||||
"exists" {
|
||||
if($rule.valueName)
|
||||
{
|
||||
(Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.valueExists")
|
||||
}
|
||||
else
|
||||
{
|
||||
(Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.keyExists")
|
||||
}
|
||||
}
|
||||
"integer" { (Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.integerComparison") }
|
||||
"string" { (Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.stringComparison") }
|
||||
"version" { (Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.versionComparison") }
|
||||
Default { Get-LanguageString "BooleanActions.notConfigured" }
|
||||
}
|
||||
}
|
||||
|
||||
if($rule.detectionValue -and $rule.operator)
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Registry.operator")
|
||||
value = (Get-CDDocumentOperatorString $rule.operator)
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.value")
|
||||
value = $rule.detectionValue
|
||||
}
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.associatedWith32Bit")
|
||||
value = (?: ($rule.check32BitOn64System -eq $true) ($strYes) ($strNo))
|
||||
}
|
||||
}
|
||||
elseif($rule.'@OData.Type' -eq "#microsoft.graph.win32LobAppPowerShellScriptRequirement")
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.requirementType")
|
||||
value = (Get-LanguageString "Win32Requirements.AdditionalRequirements.RequirementTypeOptions.script")
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.scriptName")
|
||||
value = $rule.displayName
|
||||
}
|
||||
|
||||
<#
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.scriptContent")
|
||||
$scriptContent = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($rule.scriptContent))
|
||||
value = $scriptContent
|
||||
}
|
||||
#>
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.CustomScript.runAs32Bit")
|
||||
value = (?: ($rule.runAs32Bit -eq $true) ($strYes) ($strNo))
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.loggedOnCredentials")
|
||||
value = (?: ($rule.runAsAccount -ne "system") ($strYes) ($strNo))
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.enforceSignatureCheck")
|
||||
value = (?: ($rule.enforceSignatureCheck -eq $true) ($strYes) ($strNo))
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.requirementMethod")
|
||||
value = switch($rule.detectionType)
|
||||
{
|
||||
"string" { (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.RequirementMethodOptions.string") }
|
||||
"dateTime" { (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.RequirementMethodOptions.dateTime") }
|
||||
"integer" { (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.RequirementMethodOptions.integer") }
|
||||
"float" { (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.RequirementMethodOptions.float") }
|
||||
"version" { (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.RequirementMethodOptions.version") }
|
||||
"boolean" { (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.RequirementMethodOptions.boolean") }
|
||||
Default { Get-LanguageString "BooleanActions.notConfigured" }
|
||||
}
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Registry.operator")
|
||||
value = (Get-CDDocumentOperatorString $rule.operator)
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "Win32Requirements.AdditionalRequirements.Script.value")
|
||||
value = $rule.detectionValue
|
||||
}
|
||||
}
|
||||
return $ruleInfo
|
||||
}
|
||||
|
||||
function Add-CDDocumentDetectionRule
|
||||
{
|
||||
param($rule)
|
||||
|
||||
$ruleInfo = @()
|
||||
|
||||
if($rule.'@OData.Type' -eq "#microsoft.graph.win32LobAppFileSystemDetection")
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.ruleType")
|
||||
value = (Get-LanguageString "DetectionRules.Manual.RuleTypeOptions.file")
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.FileRule.path")
|
||||
value = $rule.path
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.FileRule.fileOrFolder")
|
||||
value = $rule.fileOrFolderName
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.FileRule.detectionMethod")
|
||||
value = switch($rule.detectionType)
|
||||
{
|
||||
"createdDate" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.dateCreated") }
|
||||
"modifiedDate" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.dateModified") }
|
||||
"doesNotExist" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.doesNotExist") }
|
||||
"exists" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.fileOrFolderExists") }
|
||||
"sizeInMB" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.sizeInMB") }
|
||||
"version" { (Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.version") }
|
||||
Default { Get-LanguageString "BooleanActions.notConfigured" }
|
||||
}
|
||||
}
|
||||
|
||||
if($rule.detectionValue -and $rule.operator)
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.FileRule.operator")
|
||||
value = (Get-CDDocumentOperatorString $rule.operator)
|
||||
}
|
||||
|
||||
$detectionValue = $rule.detectionValue
|
||||
if($rule.detectionType -eq "createdDate" -or $rule.detectionType -eq "modifiedDate")
|
||||
{
|
||||
try {
|
||||
$tmpDate = Get-Date $rule.detectionValue
|
||||
$detectionValue = $tmpDate.ToString()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.FileRule.value")
|
||||
value = $detectionValue
|
||||
}
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.associatedWith32Bit")
|
||||
value = (?: ($rule.check32BitOn64System -eq $true) (Get-LanguageString "SettingDetails.yes") (Get-LanguageString "SettingDetails.no"))
|
||||
}
|
||||
}
|
||||
elseif($rule.'@OData.Type' -eq "#microsoft.graph.win32LobAppRegistryDetection")
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.ruleType")
|
||||
value = (Get-LanguageString "DetectionRules.Manual.RuleTypeOptions.registry")
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.keyPath")
|
||||
value = $rule.keyPath
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.valueName")
|
||||
value = $rule.valueName
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.detectionMethod")
|
||||
value = switch($rule.detectionType)
|
||||
{
|
||||
"doesNotExist"
|
||||
{
|
||||
if($rule.valueName)
|
||||
{
|
||||
(Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.valueDoesNotExist")
|
||||
}
|
||||
else
|
||||
{
|
||||
(Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.keyDoesNotExist")
|
||||
}
|
||||
}
|
||||
"exists" {
|
||||
if($rule.valueName)
|
||||
{
|
||||
(Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.valueExists")
|
||||
}
|
||||
else
|
||||
{
|
||||
(Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.keyExists")
|
||||
}
|
||||
}
|
||||
"integer" { (Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.integerComparison") }
|
||||
"string" { (Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.stringComparison") }
|
||||
"version" { (Get-LanguageString "DetectionRules.Manual.RegistryRule.DetectionMethodOptions.versionComparison") }
|
||||
Default { Get-LanguageString "BooleanActions.notConfigured" }
|
||||
}
|
||||
}
|
||||
|
||||
if($rule.detectionValue -and $rule.operator)
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.operator")
|
||||
value = (Get-CDDocumentOperatorString $rule.operator)
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.value")
|
||||
value = $rule.detectionValue
|
||||
}
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.RegistryRule.associatedWith32Bit")
|
||||
value = (?: ($rule.check32BitOn64System -eq $true) (Get-LanguageString "SettingDetails.yes") (Get-LanguageString "SettingDetails.no"))
|
||||
}
|
||||
}
|
||||
else #win32LobAppProductCodeDetection
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.ruleType")
|
||||
value = (Get-LanguageString "DetectionRules.Manual.RuleTypeOptions.mSI")
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.MsiRule.productCode")
|
||||
value = $rule.productCode
|
||||
}
|
||||
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.MsiRule.productVersionCheck")
|
||||
value = (?: ($null -ne $rule.productVersion) (Get-LanguageString "SettingDetails.yes") (Get-LanguageString "SettingDetails.no"))
|
||||
}
|
||||
|
||||
if($null -ne $rule.productVersion)
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.MsiRule.operator")
|
||||
value = (Get-CDDocumentOperatorString $rule.productVersionOperator)
|
||||
}
|
||||
}
|
||||
|
||||
if($null -ne $rule.productVersion)
|
||||
{
|
||||
$ruleInfo += [PSCustomObject]@{
|
||||
property = (Get-LanguageString "DetectionRules.Manual.MsiRule.productVersion")
|
||||
value = (Get-CDDocumentOperatorString $rule.productVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ruleInfo
|
||||
}
|
||||
|
||||
function Get-CDDocumentOperatorString
|
||||
{
|
||||
param($operator)
|
||||
|
||||
$lngString = switch ($operator)
|
||||
{
|
||||
"notConfigured" { Get-LanguageString "BooleanActions.notConfigured" }
|
||||
"equal" { Get-LanguageString "DetectionRules.ComparisonOperators.equals" }
|
||||
"notEqual" { Get-LanguageString "DetectionRules.ComparisonOperators.notEqualTo" }
|
||||
"greaterThan" { Get-LanguageString "DetectionRules.ComparisonOperators.greaterThan" }
|
||||
"greaterThanOrEqual" { Get-LanguageString "DetectionRules.ComparisonOperators.greaterThanOrEqualTo" }
|
||||
"lessThan" { Get-LanguageString "DetectionRules.ComparisonOperators.lessThan" }
|
||||
"lessThanOrEqual" { Get-LanguageString "DetectionRules.ComparisonOperators.lessThanOrEqualTo" }
|
||||
"exists" { Get-LanguageString "DetectionRules.Manual.FileRule.DetectionMethodOptions.fileOrFolderExists" }
|
||||
Default { $operator }
|
||||
}
|
||||
|
||||
$lngString
|
||||
}
|
||||
|
||||
# App Config
|
||||
function Invoke-CDDocumentiosMobileAppConfiguration
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ This module is for the Endpoint Manager/Intune View. It manages Export/Import/Co
|
||||
#>
|
||||
function Get-ModuleVersion
|
||||
{
|
||||
'3.8.1'
|
||||
'3.9.0'
|
||||
}
|
||||
|
||||
function Invoke-InitializeModule
|
||||
@@ -89,7 +89,7 @@ function Invoke-InitializeModule
|
||||
Deactivating = { Invoke-EMDeactivateView }
|
||||
Activating = { Invoke-EMActivatingView }
|
||||
Authentication = (Get-MSALAuthenticationObject)
|
||||
Authenticate = { Invoke-EMAuthenticateToMSAL }
|
||||
Authenticate = { Invoke-EMAuthenticateToMSAL @args }
|
||||
AppInfo = (Get-GraphAppInfo "EMAzureApp" "d1ddf0e4-d672-4dae-b554-9d5bdfd93547" "EM")
|
||||
SaveSettings = { Invoke-EMSaveSettings }
|
||||
|
||||
@@ -120,7 +120,7 @@ function Invoke-InitializeModule
|
||||
ViewID = "IntuneGraphAPI"
|
||||
API = "/identity/conditionalAccess/policies"
|
||||
Permissons=@("Policy.Read.All","Policy.ReadWrite.ConditionalAccess","Application.Read.All")
|
||||
Dependencies = @("NamedLocations","Applications","TermsOfUse","AuthenticationStrengths")
|
||||
Dependencies = @("NamedLocations","Applications","TermsOfUse","AuthenticationStrengths","AssignmentFilters")
|
||||
GroupId = "ConditionalAccess"
|
||||
ImportExtension = { Add-ConditionalAccessImportExtensions @args }
|
||||
PreImportCommand = { Start-PreImportConditionalAccess @args }
|
||||
@@ -128,22 +128,19 @@ function Invoke-InitializeModule
|
||||
ExpandAssignmentsList = $false
|
||||
})
|
||||
|
||||
if((Get-SettingValue "PreviewFeatures" $false) -eq $true)
|
||||
{
|
||||
Add-ViewItem (New-Object PSObject -Property @{
|
||||
Title = "Terms of use"
|
||||
Id = "TermsOfUse"
|
||||
ViewID = "IntuneGraphAPI"
|
||||
ViewProperties = @("id", "displayName")
|
||||
Expand = "files"
|
||||
QUERYLIST = "`$expand=files"
|
||||
API = "/identityGovernance/termsOfUse/agreements"
|
||||
Permissons=@("Agreement.ReadWrite.All")
|
||||
PreImportCommand = { Start-PreImportTermsOfUse @args }
|
||||
PostExportCommand = { Start-PostExportTermsOfUse @args }
|
||||
GroupId = "ConditionalAccess"
|
||||
})
|
||||
}
|
||||
Add-ViewItem (New-Object PSObject -Property @{
|
||||
Title = "Terms of use"
|
||||
Id = "TermsOfUse"
|
||||
ViewID = "IntuneGraphAPI"
|
||||
ViewProperties = @("id", "displayName")
|
||||
Expand = "files"
|
||||
QUERYLIST = "`$expand=files"
|
||||
API = "/identityGovernance/termsOfUse/agreements"
|
||||
Permissons=@("Agreement.ReadWrite.All")
|
||||
PreImportCommand = { Start-PreImportTermsOfUse @args }
|
||||
PostExportCommand = { Start-PostExportTermsOfUse @args }
|
||||
GroupId = "ConditionalAccess"
|
||||
})
|
||||
|
||||
Add-ViewItem (New-Object PSObject -Property @{
|
||||
Title = "Named Locations"
|
||||
@@ -262,6 +259,7 @@ function Invoke-InitializeModule
|
||||
#QUERYLIST = "`$filter=endsWith(id,'Windows10EnrollmentCompletionPageConfiguration')"
|
||||
Permissons=@("DeviceManagementServiceConfig.ReadWrite.All")
|
||||
SkipRemoveProperties = @('Id')
|
||||
Dependencies = @("Applications")
|
||||
AssignmentsType = "enrollmentConfigurationAssignments"
|
||||
PropertiesToRemoveForUpdate = @('priority')
|
||||
GroupId = "WinEnrollment"
|
||||
@@ -670,6 +668,7 @@ function Invoke-InitializeModule
|
||||
GroupId = "EndpointAnalytics"
|
||||
Icon = "Report"
|
||||
AssignmentsType = "deviceHealthScriptAssignments"
|
||||
AssignmentProperties = @("target","runSchedule","runRemediationScript")
|
||||
PropertiesToRemoveForUpdate = @('version','isGlobalScript','highestAvailableVersion')
|
||||
})
|
||||
|
||||
@@ -733,13 +732,50 @@ function Invoke-InitializeModule
|
||||
Icon = "ConditionalAccess"
|
||||
GroupId = "EndpointSecurity"
|
||||
})
|
||||
|
||||
Add-ViewItem (New-Object PSObject -Property @{
|
||||
Title = "Authentication Context"
|
||||
Id = "AuthenticationContext"
|
||||
ViewID = "IntuneGraphAPI"
|
||||
API = "/identity/conditionalAccess/authenticationContextClassReferences"
|
||||
PropertiesToRemove = @("@odata.type")
|
||||
SkipRemoveProperties = @('Id')
|
||||
ImportOrder = 46
|
||||
PreImportCommand = { Start-PreImportCommandAuthenticationContext @args }
|
||||
Permissons=@("Policy.ReadWrite.ConditionalAccess")
|
||||
ExpandAssignmentsList = $false
|
||||
Icon = "ConditionalAccess"
|
||||
GroupId = "EndpointSecurity"
|
||||
})
|
||||
|
||||
Add-ViewItem (New-Object PSObject -Property @{
|
||||
Title = "W365 Provisioning Policies"
|
||||
Id = "W365ProvisioningPolicies"
|
||||
ViewID = "IntuneGraphAPI"
|
||||
API = "/deviceManagement/virtualEndpoint/provisioningPolicies"
|
||||
Permissons=@("CloudPC.ReadWrite.All")
|
||||
Icon = "Devices"
|
||||
GroupId = "DeviceConfiguration"
|
||||
})
|
||||
|
||||
Add-ViewItem (New-Object PSObject -Property @{
|
||||
Title = "W365 User Settings"
|
||||
Id = "W365UserSettings"
|
||||
ViewID = "IntuneGraphAPI"
|
||||
API = "/deviceManagement/virtualEndpoint/userSettings"
|
||||
Permissons = @("CloudPC.ReadWrite.All")
|
||||
Icon = "Devices"
|
||||
GroupId = "DeviceConfiguration"
|
||||
})
|
||||
}
|
||||
|
||||
function Invoke-EMAuthenticateToMSAL
|
||||
{
|
||||
param($params = @{})
|
||||
|
||||
$global:EMViewObject.AppInfo = Get-GraphAppInfo "EMAzureApp" "d1ddf0e4-d672-4dae-b554-9d5bdfd93547" "EM"
|
||||
Set-MSALCurrentApp $global:EMViewObject.AppInfo
|
||||
& $global:msalAuthenticator.Login -Account (?? $global:MSALToken.Account.UserName (Get-Setting "" "LastLoggedOnUser"))
|
||||
& $global:msalAuthenticator.Login -Account (?? $global:MSALToken.Account.UserName (Get-Setting "" "LastLoggedOnUser")) @params
|
||||
}
|
||||
|
||||
function Invoke-EMDeactivateView
|
||||
@@ -2060,6 +2096,29 @@ function Start-PreImportAssignmentsApplications
|
||||
}
|
||||
@{"Assignments"=$assignments}
|
||||
}
|
||||
elseif($obj.'@odata.type' -eq "#microsoft.graph.winGetApp")
|
||||
{
|
||||
Write-LogDebug "Wait for app to be published"
|
||||
$i = 2
|
||||
Start-Sleep -s ($i)
|
||||
$x = 0
|
||||
while($x -lt 10)
|
||||
{
|
||||
###!!!
|
||||
$appInfo = Invoke-GraphRequest -Url "$($objectType.API)/$($obj.id)" -ODataMetadata "skip"
|
||||
if($appInfo.publishingState -eq "Published")
|
||||
{
|
||||
Write-LogDebug "Application $($obj.displayName) is published"
|
||||
return
|
||||
}
|
||||
Start-Sleep -s ($i)
|
||||
$x++
|
||||
if($x -ge 5) { $i++ }
|
||||
}
|
||||
|
||||
Write-Log "Application '$($obj.displayName)' is not published. Skipping assignment" 2
|
||||
@{"Import"=$false}
|
||||
}
|
||||
}
|
||||
|
||||
function Start-PreDeleteApplications
|
||||
@@ -3246,6 +3305,11 @@ function Start-PreImportConditionalAccess
|
||||
}
|
||||
$obj.grantControls.authenticationStrength = $authSetting
|
||||
}
|
||||
|
||||
if($obj.sessionControls.disableResilienceDefaults -eq $false)
|
||||
{
|
||||
$obj.sessionControls.disableResilienceDefaults = $null
|
||||
}
|
||||
}
|
||||
|
||||
function Start-PostExportConditionalAccess
|
||||
@@ -3455,4 +3519,15 @@ function Start-PreImportCommandAuthenticationStrengths
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Authentication Strength
|
||||
function Start-PreImportCommandAuthenticationContext
|
||||
{
|
||||
param($obj, $objectType, $file, $assignments)
|
||||
|
||||
#@{ "Method" = "PATCH" }
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Export-ModuleMember -alias * -function *
|
||||
@@ -10,7 +10,7 @@ This module is for the Endpoint Info View. It shows read-only objects in Intune
|
||||
#>
|
||||
function Get-ModuleVersion
|
||||
{
|
||||
'3.5.0'
|
||||
'3.9.0'
|
||||
}
|
||||
|
||||
function Invoke-InitializeModule
|
||||
@@ -22,6 +22,7 @@ function Invoke-InitializeModule
|
||||
ID = "EMInfoGraphAPI"
|
||||
ViewPanel = $viewPanel
|
||||
AuthenticationID = "MSAL"
|
||||
AllowDelete = $false
|
||||
ItemChanged = { Show-GraphObjects -ObjectTypeChanged; Invoke-ModuleFunction "Invoke-GraphObjectsChanged"; Write-Status ""}
|
||||
Activating = { Invoke-EMInfoActivatingView }
|
||||
Authentication = (Get-MSALAuthenticationObject)
|
||||
@@ -87,6 +88,24 @@ function Invoke-InitializeModule
|
||||
Permissons=@("DeviceManagementServiceConfig.ReadWrite.All")
|
||||
ExpandAssignmentsList = $false
|
||||
})
|
||||
|
||||
Add-ViewItem (New-Object PSObject -Property @{
|
||||
Title = "Tenant Settings"
|
||||
Id = "TenantSettings"
|
||||
ViewID = "EMInfoGraphAPI"
|
||||
API = "deviceManagement/settings"
|
||||
NameProperty = "Name"
|
||||
AlwaysImport = $true
|
||||
#ExportFullObject = $true
|
||||
ViewProperties = @("Name")
|
||||
ShowButtons = @("Import","Export","View")
|
||||
Permissons=@("DeviceManagementConfiguration.ReadWrite.All")
|
||||
PreImportCommand = { Start-PreImportTenantSettings @args }
|
||||
GetObjectName = { Start-GetObjectNameTenantSettings @args }
|
||||
PostListCommand = { Start-PostListTenantSettings @args }
|
||||
Icon="TenantSettings"
|
||||
ExpandAssignmentsList = $false
|
||||
})
|
||||
}
|
||||
|
||||
function Invoke-EMInfoActivatingView
|
||||
@@ -107,4 +126,39 @@ function Invoke-EMInfoAuthenticateToMSAL
|
||||
{
|
||||
& $global:msalAuthenticator.Login -Account $usr
|
||||
}
|
||||
}
|
||||
|
||||
function Start-PreImportTenantSettings
|
||||
{
|
||||
param($obj, $objectType)
|
||||
|
||||
$objClone = $obj | ConvertTo-Json -Depth 50 | ConvertFrom-Json
|
||||
if($objClone.deviceComplianceCheckinThresholdDays -lt 1)
|
||||
{
|
||||
$objClone.deviceComplianceCheckinThresholdDays = 30
|
||||
}
|
||||
Remove-Property $objClone "@odata.type"
|
||||
$json = @{ "settings" = $objClone } | ConvertTo-Json -Depth 50
|
||||
(Invoke-GraphRequest -Url "deviceManagement" -Content $json -HttpMethod "PATCH") | Out-Null
|
||||
|
||||
return (@{"Import"=$false})
|
||||
}
|
||||
|
||||
function Start-GetObjectNameTenantSettings
|
||||
{
|
||||
param($objList, $objectType)
|
||||
|
||||
return "Tenant Settings"
|
||||
}
|
||||
|
||||
function Start-PostListTenantSettings
|
||||
{
|
||||
param($objList, $objectType)
|
||||
|
||||
if(($objList | measure).Count -eq 1)
|
||||
{
|
||||
$objList[0].Name = "Tenant Settings"
|
||||
#$objList[0] | Add-Member -MemberType NoteProperty -Name "SettingName" -Value "Tenant Settings"
|
||||
}
|
||||
$objList
|
||||
}
|
||||
@@ -10,7 +10,7 @@ This module manages Application objects in Intune e.g. uploading application fil
|
||||
#>
|
||||
function Get-ModuleVersion
|
||||
{
|
||||
'3.7.4'
|
||||
'3.9.0'
|
||||
}
|
||||
|
||||
#########################################################################################
|
||||
@@ -357,7 +357,7 @@ function Send-IntuneFileToAzureStorage
|
||||
$ids += $id
|
||||
|
||||
$start = $chunk * $chunkSizeInBytes
|
||||
$length = [Math]::Min($chunkSizeInBytes, $fileSize - $start)
|
||||
$length = [Math]::Min([uint64]($chunkSizeInBytes), [uint64]($fileSize - $start))
|
||||
$bytes = $reader.ReadBytes($length)
|
||||
|
||||
$currentChunk = $chunk + 1
|
||||
@@ -462,7 +462,7 @@ function Write-AzureStorageChunk
|
||||
|
||||
try
|
||||
{
|
||||
$response = Invoke-WebRequest $uri -Method Put -Headers $headers -Body $encodedBody
|
||||
$response = Invoke-WebRequest $uri -Method Put -Headers $headers -Body $encodedBody -UseBasicParsing
|
||||
if($retryCount -gt 0)
|
||||
{
|
||||
Write-Log "Chunk uploaded successfully"
|
||||
|
||||
@@ -10,7 +10,7 @@ This module manages Microsoft Grap fuctions like calling APIs, managing graph ob
|
||||
#>
|
||||
function Get-ModuleVersion
|
||||
{
|
||||
'3.8.1'
|
||||
'3.9.0'
|
||||
}
|
||||
|
||||
$global:MSGraphGlobalApps = @(
|
||||
@@ -819,6 +819,7 @@ function Show-GraphObjects
|
||||
if($ctrl.Name -eq "btnDelete")
|
||||
{
|
||||
$allowDelete = Get-SettingValue "EMAllowDelete"
|
||||
if($global:currentViewObject.ViewInfo.AllowDelete -eq $false) { $allowDelete = $false }
|
||||
$ctrl.Visibility = (?: ($allowDelete -eq $true) "Visible" "Collapsed")
|
||||
}
|
||||
elseif(-not $global:curObjectType.ShowButtons -or ($global:curObjectType.ShowButtons | Where-Object { $ctrl.Name -like "*$($_)" } ))
|
||||
@@ -2247,9 +2248,9 @@ function Reset-GraphObject
|
||||
$nameProp = ?? $fileObj.ObjectType.NameProperty "displayName"
|
||||
$curObject = $objectList | Where { $_.Object.$nameProp -eq $fileObj.Object.$nameProp -and $_.Object.'@OData.Type' -eq $fileObj.Object.'@OData.Type' }
|
||||
|
||||
if($global:cbImportType.SelectedValue -eq "skipIfExist" -and ($curObject | measure).Count -gt 0)
|
||||
if($global:cbImportType.SelectedValue -eq "skipIfExist" -and ($curObject | measure).Count -gt 0 -and $fileObj.ObjectType.AlwaysImport -ne $true)
|
||||
{
|
||||
Write-Log "Objects with name $($fileObj.Object.$nameProp) already exists. Object will not be imported"
|
||||
Write-Log "Object with name $($fileObj.Object.$nameProp) already exists. Object will not be imported"
|
||||
return $true
|
||||
}
|
||||
elseif(($curObject | measure).Count -gt 1)
|
||||
@@ -2259,7 +2260,12 @@ function Reset-GraphObject
|
||||
}
|
||||
elseif(($curObject | measure).Count -eq 1)
|
||||
{
|
||||
Write-Log "Update $((Get-GraphObjectName $fileObj.Object $fileObj.ObjectType)) with id $($curObject.Object.Id)"
|
||||
$idInfo = ""
|
||||
if([String]::IsNullOrEmpty($curObject.Object.Id) -eq $false)
|
||||
{
|
||||
$idInfo = " with id $($curObject.Object.Id)"
|
||||
}
|
||||
Write-Log "Update $((Get-GraphObjectName $fileObj.Object $fileObj.ObjectType))$idInfo"
|
||||
$objectType = $fileObj.ObjectType
|
||||
|
||||
# Clone the object before removing properties
|
||||
@@ -2538,7 +2544,6 @@ function Add-GraphMigrationInfo
|
||||
if($objType -eq "#microsoft.graph.groupAssignmentTarget" -or
|
||||
$objType -eq "#microsoft.graph.exclusionGroupAssignmentTarget")
|
||||
{
|
||||
#Add-GroupMigrationObject $objInfo.groupid
|
||||
Add-GraphMigrationObject $objInfo.groupid "/groups" "Group"
|
||||
}
|
||||
elseif($objType -eq "#microsoft.graph.allLicensedUsersAssignmentTarget" -or
|
||||
@@ -2660,13 +2665,13 @@ function Add-GraphMigrationObject
|
||||
if(-not $graphObj)
|
||||
{
|
||||
# Get object info
|
||||
$graphObj = Invoke-GraphRequest "$($grapAPI)/$objId" -ODataMetadata "none"
|
||||
$graphObj = Invoke-GraphRequest "$($grapAPI)/$objId" -ODataMetadata "none" -NoError
|
||||
}
|
||||
|
||||
if($graphObj)
|
||||
{
|
||||
# Add object to cache
|
||||
if($global:AADObjectCache.ContainsKey($objId) -eq $false) { $global:AADObjectCache.Add($objId, $ugraphObjserObj) }
|
||||
if($global:AADObjectCache.ContainsKey($objId) -eq $false) { $global:AADObjectCache.Add($objId, $graphObj ) }
|
||||
|
||||
# Add object to migration file
|
||||
if((Add-GraphMigrationObjectToFile $graphObj $path $objTypeName))
|
||||
@@ -2681,6 +2686,10 @@ function Add-GraphMigrationObject
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Log "No $objTypeName found with ID $($groupId). It might be deleted." 2
|
||||
}
|
||||
}
|
||||
|
||||
function Get-GraphMigrationObject
|
||||
@@ -2805,15 +2814,16 @@ function Get-GraphMigrationObjectsFromFile
|
||||
foreach($migObj in $migFileObj.Objects)
|
||||
{
|
||||
if($migObj.Type -like "*group*")
|
||||
{
|
||||
$obj = (Invoke-GraphRequest "/groups?`$filter=displayName eq '$($migObj.DisplayName)'").Value
|
||||
{
|
||||
$migTableGroupName = $migObj.DisplayName.Trim()
|
||||
$obj = (Invoke-GraphRequest "/groups?`$filter=displayName eq '$($migTableGroupName)'").Value
|
||||
if(-not $obj)
|
||||
{
|
||||
$groupFi = $null
|
||||
if($global:GraphMigrationTable)
|
||||
{
|
||||
$fi = [IO.FileInfo]$global:GraphMigrationTable
|
||||
$groupFi = [IO.FileInfo]($fi.DirectoryName + "\Groups\$((Remove-InvalidFileNameChars $migObj.DisplayName)).json")
|
||||
$groupFi = [IO.FileInfo]($fi.DirectoryName + "\Groups\$((Remove-InvalidFileNameChars $migTableGroupName)).json")
|
||||
}
|
||||
|
||||
if($groupFi.Exists -eq $true)
|
||||
@@ -2830,31 +2840,47 @@ function Get-GraphMigrationObjectsFromFile
|
||||
|
||||
Remove-Property $groupObj $prop.Name
|
||||
}
|
||||
$groupObj.displayName = $groupObj.displayName.Trim()
|
||||
$groupJson = ConvertTo-Json $groupObj -Depth 50
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Log "No group object found for $($migObj.DisplayName). Creating a cloud group with default settings" 2
|
||||
$groupName = $migTableGroupName
|
||||
Write-Log "No group object found for $groupName. Creating a cloud group with default settings" 2
|
||||
$dateStr = ((Get-Date).ToString("yyMMddHHmmss"))
|
||||
|
||||
if(($groupName.Length + $dateStr.Length) -gt 64)
|
||||
{
|
||||
$nickName = $groupName.Substring(0,(64-$dateStr.Length))
|
||||
}
|
||||
else
|
||||
{
|
||||
$nickName = $groupName
|
||||
}
|
||||
$nickName = $nickName + $dateStr
|
||||
|
||||
$groupJson = @"
|
||||
{
|
||||
"displayName": "$($migObj.DisplayName)",
|
||||
"groupTypes": [
|
||||
],
|
||||
"displayName": "$($groupName)",
|
||||
"mailEnabled": false,
|
||||
"mailNickname" "NotSet"
|
||||
"securityEnabled": true
|
||||
"mailNickname": "$($nickName)",
|
||||
"securityEnabled": true
|
||||
}
|
||||
"@
|
||||
}
|
||||
Write-Log "Create AAD Group $($migObj.DisplayName)"
|
||||
Write-Log "Create AAD Group $($migTableGroupName)"
|
||||
|
||||
$obj = Invoke-GraphRequest "/groups" -HttpMethod "POST" -Content $groupJson
|
||||
}
|
||||
$global:MigrationTableCache += (New-Object PSObject -Property @{
|
||||
OriginalId = $migObj.Id
|
||||
Id = $obj.Id
|
||||
Type = $migObj.Type
|
||||
})
|
||||
|
||||
if($obj)
|
||||
{
|
||||
$global:MigrationTableCache += (New-Object PSObject -Property @{
|
||||
OriginalId = $migObj.Id
|
||||
Id = $obj.Id
|
||||
Type = $migObj.Type
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3172,25 +3198,49 @@ function Set-GraphNavigationProperties
|
||||
# Is this the correct way of filter out Assignments, summaries etc.?
|
||||
if($prop.ContainsTarget -eq $true) { continue }
|
||||
|
||||
|
||||
if(-not ($oldObj."$($prop.Name)@odata.associationLink")) { continue }
|
||||
|
||||
$associationLink = $oldObj."$($prop.Name)@odata.associationLink" -replace $oldObj.Id,$newObj.Id
|
||||
$refBodyObjs = $null #@()
|
||||
$refBodyObjs = @()
|
||||
$refObjName = $null
|
||||
$refObjId = $null
|
||||
if($prop.Type -like "Collection(*")
|
||||
{
|
||||
$multiNavProperty = $true
|
||||
$method = "POST"
|
||||
}
|
||||
else
|
||||
{
|
||||
$multiNavProperty = $false
|
||||
$method = "PUT"
|
||||
}
|
||||
|
||||
if($FromOldObject -eq $true)
|
||||
{
|
||||
$navProp = Invoke-GraphRequest -URL $oldObj."$($prop.Name)@odata.navigationLink" -ODataMetadata "minimal" -NoError
|
||||
|
||||
if(-not $navProp) { continue }
|
||||
|
||||
if($multiNavProperty)
|
||||
{
|
||||
$navProperties = $navProp.Value
|
||||
}
|
||||
else
|
||||
{
|
||||
$navProperties = $navProp
|
||||
}
|
||||
|
||||
$refObjName = Get-GraphObjectName $navProp $navProp
|
||||
$refObjId = $navProp.Id
|
||||
|
||||
$refBodyObjs = ([PSCustomObject]@{
|
||||
"@odata.id" = ("https://$global:MSALGraphEnvironment/beta/$($objectType.API)('$($navProp.Id)')")
|
||||
})
|
||||
foreach($navProp in $navProperties)
|
||||
{
|
||||
$refBodyObjs += [PSCustomObject]@{
|
||||
RefObjName = $navProp.displayName ### NOT Correct. Migh be another property but we don't know the type
|
||||
RefObjId = $navProp.Id
|
||||
RefBody = ([PSCustomObject]@{
|
||||
"@odata.id" = ("https://$global:MSALGraphEnvironment/beta/$($objectType.API)('$($navProp.Id)')")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3199,50 +3249,58 @@ function Set-GraphNavigationProperties
|
||||
$idx = $oldObj."#CustomRef_$($prop.Name)".IndexOf("|:|")
|
||||
if($idx -gt -1)
|
||||
{
|
||||
$refObjName = $oldObj."#CustomRef_$($prop.Name)".SubString(0,$idx)
|
||||
$refObjNames = $oldObj."#CustomRef_$($prop.Name)".SubString(0,$idx)
|
||||
}
|
||||
else
|
||||
{
|
||||
$refObjName = $oldObj."#CustomRef_$($prop.Name)"
|
||||
}
|
||||
|
||||
$refObjects = Invoke-GraphRequest -URL "$($objectType.API)?`$filter=$($nameProp) eq '$($refObjName)'" -NoError
|
||||
$refObjNames = $oldObj."#CustomRef_$($prop.Name)"
|
||||
}
|
||||
|
||||
$objectsFound = ($refObjects.value | measure).Count
|
||||
foreach($refObjName in $refObjNames.Split(","))
|
||||
{
|
||||
$refObjects = Invoke-GraphRequest -URL "$($objectType.API)?`$filter=$($nameProp) eq '$($refObjName)'" -NoError
|
||||
|
||||
if($objectsFound -eq 1)
|
||||
{
|
||||
# Are there any references that allows multiple ref objects?
|
||||
foreach($refObj in $refObjects.value)
|
||||
$objectsFound = ($refObjects.value | measure).Count
|
||||
|
||||
if($objectsFound -eq 1)
|
||||
{
|
||||
$refBodyObjs = ([PSCustomObject]@{
|
||||
"@odata.id" = ("https://$global:MSALGraphEnvironment/beta/$($objectType.API)('$($refObj.Id)')")
|
||||
})
|
||||
$refObjId = $refObj.Id
|
||||
# Are there any references that allows multiple ref objects?
|
||||
foreach($refObj in $refObjects.value)
|
||||
{
|
||||
$refBodyObjs += [PSCustomObject]@{
|
||||
RefObjName = $refObjName
|
||||
RefObjId = $refObj.Id
|
||||
RefBody = ([PSCustomObject]@{
|
||||
"@odata.id" = ("https://$global:MSALGraphEnvironment/beta/$($objectType.API)('$($refObj.Id)')")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($objectsFound -gt 1)
|
||||
{
|
||||
Write-Log "Multiple objects ($objectsFound) found with $nameProp $refObjName. Skipping reference." 2
|
||||
continue
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Log "No object found with $nameProp $refObjName" 2
|
||||
continue
|
||||
}
|
||||
}
|
||||
elseif($objectsFound -gt 1)
|
||||
{
|
||||
Write-Log "Multiple objects ($objectsFound) found with $nameProp $refObjName. Skipping reference." 2
|
||||
continue
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Log "No object found with $nameProp $refObjName" 2
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
Write-Log "Add $refObjName ($refObjId) to navigation property $($prop.Name)"
|
||||
|
||||
$body = $refBodyObjs | ConvertTo-Json -Depth 50
|
||||
Invoke-GraphRequest -URL $associationLink -HttpMethod "PUT" -Content $body | Out-Null
|
||||
foreach($refObject in $refBodyObjs)
|
||||
{
|
||||
Write-Log "Add $($refObject.RefObjName) ($($refObject.RefObjId)) to navigation property $($prop.Name)"
|
||||
$body = $refObject.RefBody | ConvertTo-Json -Depth 50
|
||||
Invoke-GraphRequest -URL $associationLink -HttpMethod $method -Content $body | Out-Null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<#
|
||||
Add Navigation Property data to the object so it included in the exported json file
|
||||
Add Navigation Property data to the object so they are included in the exported json file
|
||||
#>
|
||||
function Add-GraphNavigationProperties
|
||||
{
|
||||
@@ -4032,6 +4090,12 @@ function Get-GraphObjectName
|
||||
{
|
||||
param($obj, $objectType)
|
||||
|
||||
if($objectType.GetObjectName)
|
||||
{
|
||||
return (& $objectType.GetObjectName $obj $objectType)
|
||||
|
||||
}
|
||||
|
||||
$obj."$((?? ($objectType.NameProperty) "displayName"))"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user