Fixed issue with installing Intune module

Added support for viewing object info
This commit is contained in:
Micke
2019-07-03 06:52:59 +10:00
parent 7d357af03e
commit 0cbfc3ae87
15 changed files with 305 additions and 25 deletions

View File

@@ -100,7 +100,7 @@ function Get-AppProtections
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-AppProtection})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-AppProtection}) -ViewFullObject ([scriptblock]{Get-AppProtectionObject $global:dgObjects.SelectedItem.Object}) -ForceFullObject
}
function Get-AppProtectionObjects
@@ -108,6 +108,26 @@ function Get-AppProtectionObjects
Get-GraphObjects -Url "/deviceAppManagement/managedAppPolicies"
}
function Get-AppProtectionObject
{
param($object, $additional = "")
if(-not $object.id) { return }
$objType = Get-AppProtectionObjectType $object."@odata.type"
$expand = ""
if($objType -eq "targetedManagedAppConfigurations")
{
$expand = "?`$expand=Apps"
}
if($objType)
{
Invoke-GraphRequest -Url "/deviceAppManagement/$objType/$($object.id)$($expand)"
}
}
function Export-AllAppProtections
{
param($path = "$env:Temp")

View File

@@ -146,7 +146,7 @@ function Get-Applications
$script:importParams = @{}
$script:importParams.Add("Extension", $importExtension)
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles @script:importParams}) # -copy ([scriptblock]{Copy-Application})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles @script:importParams}) -ViewFullObject ([scriptblock]{Get-ApplicationObject $global:dgObjects.SelectedItem.Object})
}
function Get-ApplicationObjects
@@ -154,6 +154,15 @@ function Get-ApplicationObjects
Get-GraphObjects -Url "/deviceAppManagement/mobileApps?`$filter=(microsoft.graph.managedApp/appAvailability%20eq%20null%20or%20microsoft.graph.managedApp/appAvailability%20eq%20%27lineOfBusiness%27%20or%20isAssigned%20eq%20true)&`$orderby=displayName"
}
function Get-ApplicationObject
{
param($object, $additional = "")
if(-not $Object.id) { return }
Invoke-GraphRequest -Url "/deviceAppManagement/mobileApps/$($Object.id)$additional"
}
function Export-AllApplications
{
param($path = "$env:Temp")

View File

@@ -100,7 +100,7 @@ function Get-AutoPilots
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-AutoPilot})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-AutoPilot}) -ViewFullObject ([scriptblock]{Get-AutoPilotObject $global:dgObjects.SelectedItem.Object})
}
function Get-AutoPilotObjects
@@ -108,6 +108,15 @@ function Get-AutoPilotObjects
Get-GraphObjects -Url "/deviceManagement/windowsAutopilotDeploymentProfiles"
}
function Get-AutoPilotObject
{
param($object, $additional = "")
if(-not $Object.id) { return }
Invoke-GraphRequest -Url "/deviceManagement/windowsAutopilotDeploymentProfiles/$($Object.id)$additional"
}
function Export-AllAutoPilots
{
param($path = "$env:Temp")

View File

@@ -102,7 +102,7 @@ function Get-AZBrandings
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -ViewFullObject ([scriptblock]{Get-AZBrandingObject $global:dgObjects.SelectedItem.Object})
}
function Get-AZBrandingObjects
@@ -114,6 +114,15 @@ function Get-AZBrandingObjects
}
}
function Get-AZBrandingObject
{
param($object, $additional = "")
if(-not $Object.locale) { return }
Invoke-AzureNativeRequest "LoginTenantBrandings/$($Object.locale)$additional"
}
function Export-AllAZBrandings
{
param($path = "$env:Temp")

View File

@@ -125,7 +125,7 @@ function Get-BaselineProfiles
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude @("*_Settings.json","*_assignments.json"))
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-BaselineProfile})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-BaselineProfile}) -ViewFullObject ([scriptblock]{Get-BaselineProfileObject $global:dgObjects.SelectedItem.Object})
}
function Get-BaselineProfileObjects
@@ -133,6 +133,18 @@ function Get-BaselineProfileObjects
Get-GraphObjects -Url "/deviceManagement/intents"
}
function Get-BaselineProfileObject
{
param($object, $additional = "")
if(-not $Object.id) { return }
$profile = Invoke-GraphRequest -Url "/deviceManagement/intents/$($Object.id)"
$settings = Invoke-GraphRequest -Url "/deviceManagement/intents/$($Object.id)/Settings"
@($profile, $settings)
}
function Export-AllBaselineProfiles
{
param($path = "$env:Temp")

View File

@@ -100,7 +100,7 @@ function Get-CompliancePolicies
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-CompliancePolicy})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-CompliancePolicy}) -ViewFullObject ([scriptblock]{Get-CompliancePolicyObject $global:dgObjects.SelectedItem.Object})
}
function Get-CompliancePolicyObjects
@@ -108,6 +108,15 @@ function Get-CompliancePolicyObjects
Get-GraphObjects -Url "/deviceManagement/deviceCompliancePolicies"
}
function Get-CompliancePolicyObject
{
param($object, $additional = "")
if(-not $Object.id) { return }
Invoke-GraphRequest -Url "/deviceManagement/deviceCompliancePolicies/$($Object.id)$additional"
}
function Export-AllCompliancePolicies
{
param($path = "$env:Temp")

View File

@@ -99,7 +99,7 @@ function Get-ConditionalAccess
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -ViewFullObject ([scriptblock]{Get-ConditionalAccessObject $global:dgObjects.SelectedItem.Object})
}
function Get-ConditionalAccessObjects
@@ -108,6 +108,22 @@ function Get-ConditionalAccessObjects
Get-AzureNativeObjects "Policies/Policies?top=10&nextLink=null&appId=&includeBaseline=true" -property @('policyName')
}
function Get-ConditionalAccessObject
{
param($object, $additional = "")
if(-not $Object.policyId) { return }
if($Object.baselineType -eq 0)
{
Invoke-AzureNativeRequest "Policies/$($Object.policyId)$additional"
}
else
{
Invoke-AzureNativeRequest "BaselinePolicies/$($Object.policyId)$additional"
}
}
function Export-AllConditionalAccess
{
param($path = "$env:Temp")

View File

@@ -99,7 +99,7 @@ function Get-DeviceConfigurations
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-DeviceConfiguration})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-DeviceConfiguration}) -ViewFullObject ([scriptblock]{Get-DeviceConfigurationObject $global:dgObjects.SelectedItem.Object})
}
function Get-DeviceConfigurationObjects
@@ -107,6 +107,15 @@ function Get-DeviceConfigurationObjects
Get-GraphObjects -Url "/deviceManagement/deviceConfigurations"#,"/deviceManagement/groupPolicyConfigurations"
}
function Get-DeviceConfigurationObject
{
param($object, $additional = "")
if(-not $Object.id) { return }
Invoke-GraphRequest -Url "/deviceManagement/deviceConfigurations/$($Object.id)$additional"
}
function Export-AllDeviceConfigurations
{
param($path = "$env:Temp")

View File

@@ -100,7 +100,7 @@ function Get-ESPs
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-ESP})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-ESP}) -ViewFullObject ([scriptblock]{Get-ESPObject $global:dgObjects.SelectedItem.Object})
}
function Get-ESPObjects
@@ -108,6 +108,15 @@ function Get-ESPObjects
Get-GraphObjects -Url "/deviceManagement/deviceEnrollmentConfigurations"
}
function Get-ESPObject
{
param($object, $additional = "")
if(-not $Object.id) { return }
Invoke-GraphRequest -Url "/deviceManagement/deviceEnrollmentConfigurations/$($Object.id)$additional"
}
function Export-AllESPs
{
param($path = "$env:Temp")

View File

@@ -101,7 +101,7 @@ function Get-GPOSettings
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-GPOSetting})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-GPOSetting}) -ViewFullObject ([scriptblock]{Get-GPOSettingObject $global:dgObjects.SelectedItem.Object})
}
function Get-GPOSettingObjects
@@ -109,6 +109,15 @@ function Get-GPOSettingObjects
Get-GraphObjects -Url "/deviceManagement/groupPolicyConfigurations"
}
function Get-GPOSettingObject
{
param($object, $additional = "")
if(-not $Object.id) { return }
@((Invoke-GraphRequest -Url "/deviceManagement/groupPolicyConfigurations/$($Object.id)$additional"),(Get-GPOObjectSettings $Object))
}
function Export-AllGPOSettings
{
param($path = "$env:Temp")

View File

@@ -99,7 +99,7 @@ function Get-MDMMAM
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -ViewFullObject ([scriptblock]{Get-MDMMAMObject $global:dgObjects.SelectedItem.Object})
}
function Get-MDMMAMObjects
@@ -107,6 +107,15 @@ function Get-MDMMAMObjects
Get-AzureNativeObjects "MdmApplications" -property @('appDisplayName')
}
function Get-MDMMAMObject
{
param($object, $additional = "")
if(-not $Object.objectId) { return }
Invoke-AzureNativeRequest "/MdmApplications/$($Object.objectId)$additional"
}
function Export-AllMDMMAM
{
param($path = "$env:Temp")

View File

@@ -3,7 +3,7 @@ function Invoke-InitializeModule
$module = Get-Module -Name Microsoft.Graph.Intune -ListAvailable
if(-not $module)
{
$ret = [System.Windows.MessageBox]::Show("Intune PowerShell module not found!`n`nDo you want to install it?`n`nYes = Install intune module (Requires admin or it will fail)`nNo = Contune without module (Nothing will work)`nCancel = Quit", "Error", "YesNoCancel", "Error")
$ret = [System.Windows.MessageBox]::Show("Intune PowerShell module not found!`n`nDo you want to install it?`n`nYes = Install intune module (Requires admin or it will fail)`nNo = Contune without module (No Azure modules will be loaded)`nCancel = Quit", "Error", "YesNoCancel", "Error")
if($ret -eq "Yes")
{
try
@@ -11,7 +11,7 @@ function Invoke-InitializeModule
Install-Module -Name Microsoft.Graph.Intune -Force -ErrorAction SilentlyContinue
}
catch {}
if(-not (Get-Module -Name Microsoft.Graph.Intune))
if(-not (Get-Module -Name Microsoft.Graph.Intune -ListAvailable -Refresh))
{
[System.Windows.MessageBox]::Show("Failed to install Intune PowerShell module!`n`nRestart this as admin and try again`nor`nStart PowerShell as admin and run:`nInstall-Module -Name Microsoft.Graph.Intune", "Error", "OK", "Error")
exit
@@ -21,6 +21,10 @@ function Invoke-InitializeModule
{
exit
}
else
{
return
}
}
if(-not $global:authentication)
@@ -31,9 +35,24 @@ function Invoke-InitializeModule
}
}
if(-not $global:authentication)
{
[System.Windows.MessageBox]::Show("Failed to connect to Azure with Intune PowerShell module!`n`nNo Intune extensions will be imported", "Error", "OK", "Error")
return
}
$global:Me = Invoke-GraphRequest "ME"
if(-not $global:Me)
{
[System.Windows.MessageBox]::Show("Failed to get information about current logged on Azure user!`n`nVerify connection and try again`n`nNo Intune modules will be imported!", "Error", "OK", "Error")
return
}
$global:Organization = (Invoke-GraphRequest "Organization").Value
$global:graphURL = "https://graph.microsoft.com/beta"
# Add settings
# Add settings
$global:appSettingSections += (New-Object PSObject -Property @{
Title = "Intune"
Id = "IntuneAzure"
@@ -113,9 +132,6 @@ function Invoke-InitializeModule
Script = [ScriptBlock]{ Show-ExportAllForm }
})
$global:Me = Invoke-GraphRequest "ME"
$global:Organization = (Invoke-GraphRequest "Organization").Value
$global:UpdateJsonForMigration = $true
}
@@ -617,9 +633,57 @@ function Add-DefaultObjectButtons
[scriptblock]
$import,
[scriptblock]
$copy
$copy,
[scriptblock]
$viewFullObject,
[switch]
$ForceFullObject,
[switch]
$hideview
)
if($hideview -ne $true)
{
$newBtn = New-Object System.Windows.Controls.Button
#View button
$newBtn.Content = 'View'
$newBtn.Name = 'btnView'
$newBtn.Margin = "5,0,0,0"
$newBtn.Width = "100"
$spSubMenu.AddChild($newBtn)
$script:viewFullObject = $viewFullObject
$script:ForceFullObject = ($ForceFullObject -eq $true)
if($view)
{
$newBtn.Add_Click($view)
}
else
{
$newBtn.Add_Click([scriptblock]{
if(-not $global:dgObjects.SelectedItem) { return }
if(-not $global:dgObjects.SelectedItem.Object) { return }
if($script:ForceFullObject -eq $true -and $script:ViewFullObject)
{
Write-Status "Loading full object info"
$objFullInfo = Invoke-Command -ScriptBlock $script:ViewFullObject
Write-Status ""
if($objFullInfo)
{
Show-ObjectInfo -object $objFullInfo -NoLoadFull
}
}
else
{
Show-ObjectInfo -Object $global:dgObjects.SelectedItem.Object
}
})
}
}
if($copy)
{
$newBtn = New-Object System.Windows.Controls.Button
@@ -665,6 +729,82 @@ function Add-DefaultObjectButtons
}
}
function Show-ObjectInfo
{
param(
$FormTitle = "Object info",
$object,
[switch]$NoLoadFull)
if(-not $object) { return }
[xml]$xaml = @"
<Window $wpfNS
Title="$FormTitle" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen">
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox Name="txtValue"
Grid.Column="1" Grid.Row="1"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="True"
IsReadOnly="True"
MinWidth="250" MinLines="5" AcceptsReturn="True" />
<WrapPanel Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Right" Margin="0,15,0,0">
<Button Name="btnFull" MinWidth="60" Margin="0,0,5,0" ToolTip="Load full info of the object" Visibility="Collapsed">Load full</Button>
<Button Name="btnCopy" MinWidth="60" Margin="0,0,5,0" ToolTip="Copy text to clipboard">Copy</Button>
<Button IsDefault="True" Name="btnOk" MinWidth="60" Margin="0,0,0,0">_Close</Button>
</WrapPanel>
</Grid>
</Window>
"@
$reader = (New-Object System.Xml.XmlNodeReader $xaml)
$script:inputBox = [Windows.Markup.XamlReader]::Load($reader)
$script:txtValue = $script:inputBox.FindName("txtValue")
$btnOk = $script:inputBox.FindName("btnOk")
$btnCopy = $script:inputBox.FindName("btnCopy")
$btnFull = $script:inputBox.FindName("btnFull")
$script:txtValue.Text = (ConvertTo-Json $Object -Depth 5)
$btnOk.Add_Click({
$script:inputBox.Close()
})
$btnCopy.Add_Click({
$script:txtValue.Text | Clip
})
if($script:ViewFullObject -and $NoLoadFull -ne $true)
{
$btnFull.Visibility = "Visible"
$btnFull.Add_Click({
Write-Status "Loading full object info"
$objFullInfo = Invoke-Command -ScriptBlock $script:ViewFullObject
Write-Status ""
if($objFullInfo)
{
$script:inputBox.Close()
Show-ObjectInfo -object $objFullInfo -NoLoadFull
}
})
}
$inputBox.ShowDialog() | Out-Null
}
########################################################################
#
# Export functions

View File

@@ -126,7 +126,7 @@ function Get-PowerShellScripts
$script:exportParams.Add("Extension", $exportExtension)
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-PowerShellScript})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-PowerShellScript}) -ViewFullObject ([scriptblock]{Get-PowerShellScriptObject $global:dgObjects.SelectedItem.Object})
#Add download button
$btnDownload = New-Object System.Windows.Controls.Button
@@ -146,6 +146,14 @@ function Get-PowerShellScriptObjects
Get-GraphObjects -Url "/deviceManagement/deviceManagementScripts"
}
function Get-PowerShellScriptObject
{
param($object, $additional = "")
if(-not $Object.id) { return }
Invoke-GraphRequest -Url "/deviceManagement/deviceManagementScripts/$($object.id)$additional"
}
function Export-AllPowerShellScripts
{
param($path = "$env:Temp")
@@ -185,7 +193,8 @@ function Export-SinglePowerShellScript
if(Test-Path $path)
{
Write-Status "Export $($psObj.displayName)"
$obj = Invoke-GraphRequest -Url "/deviceManagement/deviceManagementScripts/$($psObj.id)?`$expand=assignments"
$obj = Get-PowerShellScriptObject -object $psObj -additional "?`$expand=assignments"
#$obj = Invoke-GraphRequest -Url "/deviceManagement/deviceManagementScripts/$($psObj.id)?`$expand=assignments"
if($obj)
{
$fileName = "$path\$((Remove-InvalidFileNameChars $obj.displayName)).json"
@@ -215,7 +224,8 @@ function Copy-PowerShellScript
{
# Export profile
Write-Status "Export $($dgObjects.SelectedItem.displayName)"
$obj = Invoke-GraphRequest -Url "/deviceManagement/deviceManagementScripts/$($dgObjects.SelectedItem.id)"
$obj = Get-PowerShellScriptObject -object $dgObjects.SelectedItem.Object
#$obj = Invoke-GraphRequest -Url "/deviceManagement/deviceManagementScripts/$($dgObjects.SelectedItem.id)"
if($obj)
{
# Import new profile
@@ -289,7 +299,9 @@ function Import-PowerShellScriptObjects
function Invoke-DownloadScript
{
if(-not $global:dgObjects.SelectedItem.Object.id) { return }
$obj = Invoke-GraphRequest -Url "/deviceManagement/deviceManagementScripts/$($global:dgObjects.SelectedItem.Object.id)"
$obj = Get-PowerShellScriptObject -object $dgObjects.SelectedItem.Object
#$obj = Invoke-GraphRequest -Url "/deviceManagement/deviceManagementScripts/$($global:dgObjects.SelectedItem.Object.id)"
if($obj.scriptContent)
{
Write-Log "Download PowerShell script '$($obj.FileName)' from $($obj.displayName)"

View File

@@ -26,7 +26,6 @@ function Get-SupportedImportObjects
})
}
function Get-SupportedExportObjects
{
$global:exportObjects += (New-Object PSObject -Property @{
@@ -101,7 +100,7 @@ function Get-TermsAndConditions
$global:lstFiles.ItemsSource = @(Get-JsonFileObjects $global:txtImportPath.Text -Exclude "*_Settings.json")
}
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-TermsAndCondition})
Add-DefaultObjectButtons -export ([scriptblock]{Show-DefaultExportGrid @script:exportParams}) -import ([scriptblock]{Show-DefaultImportGrid -ImportAll $script:importAll -ImportSelected $script:importSelected -GetFiles $script:getImportFiles}) -copy ([scriptblock]{Copy-TermsAndCondition}) -ViewFullObject ([scriptblock]{Get-TermsAndConditionObject $global:dgObjects.SelectedItem.Object})
}
function Get-TermsAndConditionObjects
@@ -109,6 +108,15 @@ function Get-TermsAndConditionObjects
Get-GraphObjects -Url "/deviceManagement/termsAndConditions"
}
function Get-TermsAndConditionObject
{
param($object, $additional = "")
if(-not $Object.id) { return }
Invoke-GraphRequest -Url "/deviceManagement/termsAndConditions/$($Object.id)$additional"
}
function Export-AllTermsAndConditions
{
param($path = "$env:Temp")