This commit is contained in:
Mikael Karlsson
2023-10-17 20:34:44 +11:00
parent ea3af64316
commit ab7b062946
33 changed files with 6545 additions and 4702 deletions

View File

@@ -10,7 +10,7 @@ This module manages Microsoft Grap fuctions like calling APIs, managing graph ob
#>
function Get-ModuleVersion
{
'3.9.1'
'3.9.2'
}
$global:MSGraphGlobalApps = @(
@@ -183,6 +183,14 @@ function Invoke-InitializeModule
Description = "Certificate for Azure App"
}) "GraphSilent"
Add-SettingsObject (New-Object PSObject -Property @{
Title = "Login with App in UI (Preview)"
Key = "GraphAzureAppLogin"
Type = "Boolean"
DefaultValue = $false
Description = "Login with specified app in the UI. Note: Change will require app restart"
}) "GraphSilent"
Add-SettingsObject (New-Object PSObject -Property @{
Title = "Refresh Objects after copy"
Key = "RefreshObjectsAfterCopy"
@@ -214,6 +222,15 @@ function Invoke-InitializeModule
DefaultValue = $false
Description = "Expand assignments when listing objects. This can be used in custom columns based on assignment info"
}) "GraphGeneral"
Add-SettingsObject (New-Object PSObject -Property @{
Title = "Use Graph 1.0 (Not Recommended)"
Key = "UseGraphV1"
Type = "Boolean"
DefaultValue = $false
Description = "This will use production verionof graph, v1.0. Note: Thot officially supported since this can have unpredicted results. Some parts will require Beta version of Graph."
}) "GraphGeneral"
}
function Get-GraphAppInfo
@@ -270,7 +287,7 @@ function Invoke-SettingsUpdated
function Initialize-GraphSettings
{
$script:defaultVersion = ""
}
function Invoke-GraphRequest
@@ -297,7 +314,7 @@ function Invoke-GraphRequest
$ODataMetadata = "full", # full, minimal, none or skip
[ValidateSet("beta","v1.0")]
$GraphVersion = "beta",
$GraphVersion = "",
[switch]
$AllPages,
@@ -317,6 +334,22 @@ function Invoke-GraphRequest
Connect-MSALUser
}
if(-not $GraphVersion)
{
if(-not $script:defaultVersion)
{
if((Get-SettingValue "UseGraphV1") -eq $true)
{
$script:defaultVersion = "v1.0"
}
else
{
$script:defaultVersion = "beta"
}
}
$GraphVersion = $script:defaultVersion
}
$params = @{}
$requestId = [Guid]::NewGuid().guid
@@ -1684,6 +1717,7 @@ function Show-GraphImportForm
$importedObjectsCurType = 0
$navigationPropObjects = @()
$arrImportedObjects = @()
foreach ($fileObj in $filesToImport)
{
if($allowUpdate -and $global:cbImportType.SelectedValue -ne "alwaysImport" -and (Reset-GraphObject $fileObj $global:dgObjects.ItemsSource))
@@ -1699,9 +1733,15 @@ function Show-GraphImportForm
ImportedObject = $importedObj
}
}
$arrImportedObjects += $importedObj
$importedObjectsCurType++
}
if($global:curObjectType.PostFilesImportCommand)
{
& $global:curObjectType.PostFilesImportCommand $global:curObjectType $arrImportedObjects $filesToImport
}
if($importedObjectsCurType -gt 0 -and $global:LoadedDependencyObjects -is [HashTable] -and $global:LoadedDependencyObjects.ContainsKey($global:curObjectType.Id))
{
Write-Log "Remove $($global:curObjectType.Title) from dependency cache"
@@ -1870,7 +1910,6 @@ function Show-GraphBulkImportForm
function Start-GraphObjectImport
{
Write-Status "Import objects" -Block
Write-Log "****************************************************************"
Write-Log "Start bulk import"
@@ -1920,6 +1959,8 @@ function Start-GraphObjectImport
$importedObjectsCurType = 0
$arrImportedObjects = @()
foreach ($fileObj in @($filesToImport))
{
$objName = Get-GraphObjectName $fileObj.Object $item.ObjectType
@@ -1943,11 +1984,17 @@ function Start-GraphObjectImport
ImportedObject = $importedObj
}
}
$arrImportedObjects = $importedObj
$importedObjects++
$importedObjectsCurType++
}
if($item.ObjectType.PostFilesImportCommand)
{
& $item.ObjectType.PostFilesImportCommand $item.ObjectType $arrImportedObjects $filesToImport
}
if($importedObjectsCurType -gt 0 -and $global:LoadedDependencyObjects -is [HashTable] -and $global:LoadedDependencyObjects.ContainsKey($item.ObjectType.Id))
{
Write-Log "Remove $($item.ObjectType.Title) from dependency cache"
@@ -2243,6 +2290,11 @@ function Import-GraphFile
Import-GraphObjectAssignment $newObj $file.ObjectType $objClone.Assignments $file.FileInfo.FullName | Out-Null
}
if($newObj)
{
$file | Add-Member -NotePropertyName "ImportedObject" -NotePropertyValue $newObj
}
if($PassThru -eq $true -and $newObj)
{
$newObj