-
Notifications
You must be signed in to change notification settings - Fork 1
/
Start-IntuneToolBox.ps1
142 lines (126 loc) · 5.3 KB
/
Start-IntuneToolBox.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<#
Version: 1.0
Author: Jannik Reinhard (jannikreinhard.com)
Script: Create-IntuneToolBox
Description:
Tool box with different intune helper
Release notes:
Version 1.0: Init
Version 1.1:
- Bugfix for dll loading error
- UI optiomization
- IMprove stability
Version 1.1.1:
- Fix loging from accounts withour profile picture
Version 1.1.2:
- Authentication stabilization
#>
###########################################################################################################
############################################ Functions ####################################################
###########################################################################################################
function Get-MessageScreen{
param (
[Parameter(Mandatory = $true)]
[String]$xamlPath
)
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
Add-Type -AssemblyName PresentationFramework
[xml]$xaml = Get-Content $xamlPath
$global:messageScreen = ([Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $xaml)))
$global:messageScreenTitle = $global:messageScreen.FindName("TextMessageHeader")
$global:messageScreenText = $global:messageScreen.FindName("TextMessageBody")
$global:button1 = $global:messageScreen.FindName("ButtonMessage1")
$global:button2 = $global:messageScreen.FindName("ButtonMessage2")
$global:messageScreenTitle.Text = "Initializing Intune Tool Box"
$global:messageScreenText.Text = "Starting initializing Intune Tool Box"
$global:messageScreen.Show() | Out-Null
[System.Windows.Forms.Application]::DoEvents()
}
function Import-AllModules
{
foreach($file in (Get-Item -path "$global:Path\modules\*.psm1"))
{
$fileName = [IO.Path]::GetFileName($file)
if($skipModules -contains $fileName) { Write-Warning "Module $fileName excluded"; continue; }
$module = Import-Module $file -PassThru -Force -Global -ErrorAction SilentlyContinue
if($module)
{
$global:messageScreenText.Text = "Module $($module.Name) loaded successfully"
}
else
{
$global:messageScreenText.Text = "Failed to load module $file"
}
}
}
###########################################################################################################
############################################## Start ######################################################
###########################################################################################################
# Variables
[array]$global:AllGroupsObservableCollection = New-Object System.Collections.ObjectModel.ObservableCollection[Object]
[array]$global:AllGroupsCollection = $null
[array]$global:AllGroupsItemObservableCollection = New-Object System.Collections.ObjectModel.ObservableCollection[Object]
[array]$global:AllGroupsItemAddObservableCollection = New-Object System.Collections.ObjectModel.ObservableCollection[Object]
[array]$global:AllGroupsItemAddCollection = $null
[array]$global:AllGroupMember = $null
[array]$global:AllGroupPolicies = $null
[array]$global:AllPolicies = $null
[array]$global:AllGroupCompliancePolicies = $null
[array]$global:AllCompliancePolicies = $null
[array]$global:AllGroupApps = $null
[array]$global:AllApps = $null
$global:Auth = $false
$global:SelectedGroupId = ""
$global:AllManagedItems = $null
$global:GroupCreationMode = ""
$global:Path = $PSScriptRoot
$global:SelectedIndex = -1
$global:GroupColorSelection = ("#00AAA8", "#1E7045", "#20874D", "#20874D", "#FE0096","#D9532C","#2D88EE","#D30BC4","#ED1111","#00AAA8")
# Start Start Screen
Get-MessageScreen -xamlPath ("$global:Path\xaml\message.xaml")
$global:messageScreenTitle.Text = "Initializing Intune Tool Box"
$global:messageScreenText.Text = "Starting initializing Intune Tool Box"
# Load custom modules
Import-AllModules
#Init
if (-not (Start-Init)){
Write-Error "Error while loading the dlls. Exit the script"
Write-Warning "Unblock all dlls and restart the powershell seassion"
$global:messageScreen.Hide()
Exit
}
# Load main windows
$returnMainForm = New-XamlScreen -xamlPath ("$global:Path\xaml\ui.xaml")
$global:formMainForm = $returnMainForm[0]
$xamlMainForm = $returnMainForm[1]
$xamlMainForm.SelectNodes("//*[@Name]") | % {Set-Variable -Name "WPF$($_.Name)" -Value $formMainForm.FindName($_.Name)}
$global:formMainForm.add_Loaded({
$global:messageScreen.Hide()
$global:formMainForm.Activate()
})
# Init User interface
$global:messageScreenText.Text = "Load User Interface"
Set-UserInterface
# Load the click actions
$global:messageScreenText.Text = "Load Actions"
Set-UiAction
Set-UiActionButton
# Authentication
$global:messageScreenText.Text = "Login to Microsoft Graph (Auth Windows could be in the backround)"
$auth = Set-LoginOrLogout
if($auth -eq $false){
Write-Error "Error during authentication"
Write-Warning "Please try again"
$global:messageScreen.Hide()
Exit
}
$global:messageScreenText.Text = "Get all managed Items"
Get-AllManagedItems | out-null
$global:messageScreenText.Text = "Get all Configuration Profiles"
Get-AllPolicies | out-null
$global:messageScreenText.Text = "Get all Compliance Policies"
Get-AllCompliancePolicies | out-null
$global:messageScreenText.Text = "Get all Apps"
Get-AllApps | out-null
# Start Main Windows
$global:formMainForm.ShowDialog() | out-null