Skip to content

Commit

Permalink
Merge pull request #7 from MG-Cloudflow/dev
Browse files Browse the repository at this point in the history
v0.2.0-alpha
  • Loading branch information
MG-Cloudflow authored Jul 12, 2024
2 parents 86a3374 + 201c178 commit aa95fc1
Show file tree
Hide file tree
Showing 16 changed files with 383 additions and 29 deletions.
14 changes: 13 additions & 1 deletion Main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ and logging are implemented to catch and log errors during these processes.
.NOTES
Author: Maxime Guillemin | CloudFlow
Date: 21/06/2024
Date: 09/07/2024
.EXAMPLE
Show-Window
Displays the main window of the application.
#>

$currentVersion = "v0.2.0-alpha"
# Define the log file path
$logFile = ".\IntuneToolkit.log"

Expand Down Expand Up @@ -88,13 +90,16 @@ function Show-Window {
$BackupButton = $Window.FindName("BackupButton")
$RestoreButton = $Window.FindName("RestoreButton")
$ExportToCSVButton = $Window.FindName("ExportToCSVButton")
$ExportToMDButton = $Window.FindName("ExportToMDButton")
$ConfigurationPoliciesButton = $Window.FindName("ConfigurationPoliciesButton")
$DeviceConfigurationButton = $Window.FindName("DeviceConfigurationButton")
$ComplianceButton = $Window.FindName("ComplianceButton")
$AdminTemplatesButton = $Window.FindName("AdminTemplatesButton")
$ApplicationsButton = $Window.FindName("ApplicationsButton")
$AppConfigButton = $Window.FindName("AppConfigButton")
$RemediationScriptsButton = $Window.FindName("RemediationScriptsButton")
$PlatformScriptsButton = $Window.FindName("PlatformScriptsButton")
$MacosScriptsButton = $Window.FindName("MacosScriptsButton")
$SearchBox = $Window.FindName("SearchBox")
$SearchButton = $Window.FindName("SearchButton")
$SearchFieldComboBox = $Window.FindName("SearchFieldComboBox")
Expand All @@ -116,10 +121,17 @@ function Show-Window {
. .\Scripts\BackupButton.ps1
. .\Scripts\RestoreButton.ps1
. .\Scripts\ExportToCSVButton.ps1
. .\Scripts\ExportToMDButton.ps1
. .\Scripts\Show-SelectionDialog.ps1
. .\Scripts\SearchButton.ps1
. .\Scripts\RemediationScriptsButton.ps1
. .\Scripts\PlatformScriptsButton.ps1
. .\Scripts\AppConfigButton.ps1
. .\Scripts\MacosScriptsButton.ps1
# Check for the latest version
. .\Scripts\CheckVersion.ps1

Check-LatestVersion -currentVersion $currentVersion

Write-IntuneToolkitLog "Successfully imported external scripts"

Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ The Intune Toolkit is a PowerShell-based solution designed to simplify the manag
- Device Configuration Policies
- Device Compliance Policies
- Mobile Applications
- App Configuration Policies
- Administrative Templates
- Platform Scripts

- Mac OS Scripts
- **Assignment Management:**
- Add and delete assignments for selected policies.
- Search Security Groups.
Expand All @@ -26,6 +29,25 @@ The Intune Toolkit is a PowerShell-based solution designed to simplify the manag
- Back up and restore assignments to policies and apps.
- **Export Assignments:**
- Export assignments to CSV

- Document Assignments to Markdown File
- Selected Policies / applications
- Bulk Export of Policy Type
- **Logging:** Detailed logging for all major actions and error handling.

## Release Notes
# v0.2.0-alpha
- **Features**
- Mac OS Scripts
- App Configuration Policies
- Document To markdown
- Selected Policies / applications
- Bulk Export of Policy Type
- Basic Version Check to latest Release Version on Github
- **Bug Fixes**
- Build in safety when no filters Exists ( Second Attempt ;-) )
# v0.1.1-alpha
=======
- **Logging:** Detailed logging for all major actions and error handling.

## Release Notes
Expand Down
17 changes: 9 additions & 8 deletions Scripts/AddAssignmentButton.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ $AddAssignmentButton.Add_Click({
Write-IntuneToolkitLog "Processing selected policy: $($selectedPolicy.PolicyId)" -component "AddAssignment-Button" -file "AddAssignmentButton.ps1"

# Get current assignments
if ($global:CurrentPolicyType -eq "mobileApps") {
$urlGetAssignments = "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps('$($selectedPolicy.PolicyId)')/assignments"
if ($global:CurrentPolicyType -eq "mobileApps" -or $global:CurrentPolicyType -eq "mobileAppConfigurations") {
$urlGetAssignments = "https://graph.microsoft.com/beta/deviceAppManagement/$($global:CurrentPolicyType)('$($selectedPolicy.PolicyId)')/assignments"
$assignments = (Invoke-MgGraphRequest -Uri $urlGetAssignments -Method GET).value
} else {
$urlGetAssignments = "https://graph.microsoft.com/beta/deviceManagement/$($global:CurrentPolicyType)('$($selectedPolicy.PolicyId)')/assignments"
$urlGetAssignments = "https://graph.microsoft.com/beta/deviceManagement/$($global:CurrentPolicyType)('$($selectedPolicy.PolicyId)')?`$expand=assignments"
$assignments = (Invoke-MgGraphRequest -Uri $urlGetAssignments -Method GET).assignments
}
Write-IntuneToolkitLog "Fetching current assignments from: $urlGetAssignments" -component "AddAssignment-Button" -file "AddAssignmentButton.ps1"
$assignments = (Invoke-MgGraphRequest -Uri $urlGetAssignments -Method GET).value
Write-IntuneToolkitLog "Fetched assignments: $($assignments.Count)" -component "AddAssignment-Button" -file "AddAssignmentButton.ps1"

# Determine the target type based on the assignment type
Expand Down Expand Up @@ -97,7 +98,7 @@ $AddAssignmentButton.Add_Click({
$bodyObject = @{
mobileAppAssignments = $assignments
}
} elseif ($global:CurrentPolicyType -eq "deviceManagementScripts") {
} elseif ($global:CurrentPolicyType -eq "deviceManagementScripts" -or $global:CurrentPolicyType -eq "deviceShellScripts") {
$newAssignment = @{
target = @{
'@odata.type' = $targetType
Expand All @@ -114,7 +115,7 @@ $AddAssignmentButton.Add_Click({
$bodyObject = @{
deviceManagementScriptAssignments = $assignments
}
}else {
} else {
$newAssignment = @{
target = @{
'@odata.type' = $targetType
Expand All @@ -138,8 +139,8 @@ $AddAssignmentButton.Add_Click({
Write-IntuneToolkitLog "Body for update: $body" -component "AddAssignment-Button" -file "AddAssignmentButton.ps1"

# Update the assignments
if ($global:CurrentPolicyType -eq "mobileApps") {
$urlUpdateAssignments = "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps('$($selectedPolicy.PolicyId)')/assign"
if ($global:CurrentPolicyType -eq "mobileApps" -or $global:CurrentPolicyType -eq "mobileAppConfigurations") {
$urlUpdateAssignments = "https://graph.microsoft.com/beta/deviceAppManagement/$($global:CurrentPolicyType)('$($selectedPolicy.PolicyId)')/assign"
} else {
$urlUpdateAssignments = "https://graph.microsoft.com/beta/deviceManagement/$($global:CurrentPolicyType)('$($selectedPolicy.PolicyId)')/assign"
}
Expand Down
32 changes: 32 additions & 0 deletions Scripts/AppConfigButton.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<#
.SYNOPSIS
Handles the click event for the AppConfigButton to load application configuration policies.
.DESCRIPTION
This script is triggered when the AppConfigButton is clicked. It sets the global policy type to mobileAppConfigurations and calls the Load-PolicyData function to load application configuration policies. It includes logging for each major step and error handling.
.NOTES
Author: Maxime Guillemin | CloudFlow
Date: 09/07/2024
.EXAMPLE
$AppConfigButton.Add_Click({
# Code to handle click event
})
#>

$AppConfigButton.Add_Click({
Write-IntuneToolkitLog "AppConfigButton clicked" -component "AppConfig-Button" -file "AppConfigButton.ps1"

try {
$global:CurrentPolicyType = "mobileAppConfigurations"
Write-IntuneToolkitLog "Set CurrentPolicyType to mobileAppConfigurations" -component "AppConfig-Button" -file "AppConfigButton.ps1"

Load-PolicyData -policyType "mobileAppConfigurations" -loadingMessage "Loading application configurations..." -loadedMessage "Application configurations loaded."
Write-IntuneToolkitLog "Called Load-PolicyData for mobileAppConfigurations" -component "AppConfig-Button" -file "AppConfigButton.ps1"
} catch {
$errorMessage = "Failed to load application configurations. Error: $($_.Exception.Message)"
Write-Error $errorMessage
Write-IntuneToolkitLog $errorMessage -component "AppConfig-Button" -file "AppConfigButton.ps1"
}
})
4 changes: 3 additions & 1 deletion Scripts/BackupButton.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ $BackupButton.Add_Click({
# Determine the policy type from the global variable
if ($global:CurrentPolicyType -eq "mobileApps") {
$url = "https://graph.microsoft.com/beta/deviceAppManagement/$($global:CurrentPolicyType)?`$filter=(microsoft.graph.managedApp/appAvailability%20eq%20null%20or%20microsoft.graph.managedApp/appAvailability%20eq%20%27lineOfBusiness%27%20or%20isAssigned%20eq%20true)&`$orderby=displayName&`$expand=assignments"
} else {
} elseif ($global:CurrentPolicyType -eq "mobileAppConfigurations") {
$url = "https://graph.microsoft.com/beta/deviceAppManagement/$($global:CurrentPolicyType)?`$expand=assignments"
}else {
$url = "https://graph.microsoft.com/beta/deviceManagement/$($global:CurrentPolicyType)?`$expand=assignments"
}
Write-IntuneToolkitLog "Determined policy type: $($global:CurrentPolicyType)" -component "Backup-Button" -file "BackupButton.ps1"
Expand Down
36 changes: 36 additions & 0 deletions Scripts/CheckVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<#
.SYNOPSIS
Checks the current running version against the latest release version on GitHub.
.DESCRIPTION
This script retrieves the latest release version from GitHub and compares it with the current running version. If a newer version is available, it notifies the user.
.NOTES
Author: Maxime Guillemin | CloudFlow
Date: 09/07/2024
#>

function Check-LatestVersion {
param (
[string]$currentVersion,
[string]$repoUrl = "https://api.github.com/repos/MG-Cloudflow/Intune-Toolkit/releases/latest"
)

try {
Write-IntuneToolkitLog "Checking for latest version at $repoUrl" -component "Check-LatestVersion" -file "CheckVersion.ps1"
$response = Invoke-RestMethod -Uri $repoUrl -Method Get
$latestVersion = $response.tag_name

if ($latestVersion -ne $currentVersion) {
$message = "A new version ($latestVersion) is available. You are currently running version $currentVersion. Download the latest Version from github https://github.com/MG-Cloudflow/Intune-Toolkit"
[System.Windows.Forms.MessageBox]::Show($message, "Update Available", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information) | Out-Null
Write-IntuneToolkitLog $message -component "Check-LatestVersion" -file "CheckVersion.ps1"
} else {
Write-IntuneToolkitLog "You are running the latest version ($currentVersion)" -component "Check-LatestVersion" -file "CheckVersion.ps1"
}
} catch {
$errorMessage = "Failed to check for the latest version. Error: $($_.Exception.Message)"
Write-Error $errorMessage
Write-IntuneToolkitLog $errorMessage -component "Check-LatestVersion" -file "CheckVersion.ps1"
}
}
3 changes: 3 additions & 0 deletions Scripts/ConnectButton.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ $ConnectButton.Add_Click({
$ComplianceButton.IsEnabled = $true
$AdminTemplatesButton.IsEnabled = $true
$ApplicationsButton.IsEnabled = $true
$AppConfigButton.IsEnabled = $true
$MacosScriptsButton.IsEnabled = $true
#$RemediationScriptsButton.IsEnabled = $true
$PlatformScriptsButton.IsEnabled = $true
$ConnectButton.IsEnabled = $false
Expand All @@ -53,6 +55,7 @@ $ConnectButton.Add_Click({
$SearchBox.IsEnabled = $true
$SearchButton.IsEnabled = $true
$ExportToCSVButton.IsEnabled = $true
$ExportToMDButton.IsEnabled = $true

Write-IntuneToolkitLog "UI elements updated successfully" -component "Connect-Button" -file "ConnectButton.ps1"

Expand Down
20 changes: 11 additions & 9 deletions Scripts/DeleteAssignmentButton.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ It retrieves the current assignments, filters out the selected assignment, and u
.NOTES
Author: Maxime Guillemin | CloudFlow
Date: 21/06/2024
Date: 09/07/2024
.EXAMPLE
$DeleteAssignmentButton.Add_Click({
# Code to handle click event
Expand All @@ -27,13 +28,14 @@ $DeleteAssignmentButton.Add_Click({
Write-IntuneToolkitLog "Processing selected policy: $($selectedPolicy.PolicyId)" -component "DeleteAssignment-Button" -file "DeleteAssignmentButton.ps1"

# Get current assignments
if ($global:CurrentPolicyType -eq "mobileApps") {
$urlGetAssignments = "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$($selectedPolicy.PolicyId)/assignments"
if ($global:CurrentPolicyType -eq "mobileApps" -or $global:CurrentPolicyType -eq "mobileAppConfigurations") {
$urlGetAssignments = "https://graph.microsoft.com/beta/deviceAppManagement/$($global:CurrentPolicyType)('$($selectedPolicy.PolicyId)')/assignments"
$assignments = (Invoke-MgGraphRequest -Uri $urlGetAssignments -Method GET).value
} else {
$urlGetAssignments = "https://graph.microsoft.com/beta/deviceManagement/$($global:CurrentPolicyType)/$($selectedPolicy.PolicyId)/assignments"
$urlGetAssignments = "https://graph.microsoft.com/beta/deviceManagement/$($global:CurrentPolicyType)('$($selectedPolicy.PolicyId)')?`$expand=assignments"
$assignments = (Invoke-MgGraphRequest -Uri $urlGetAssignments -Method GET).assignments
}
Write-IntuneToolkitLog "Fetching current assignments from: $urlGetAssignments" -component "DeleteAssignment-Button" -file "DeleteAssignmentButton.ps1"
$assignments = (Invoke-MgGraphRequest -Uri $urlGetAssignments -Method GET).value
Write-IntuneToolkitLog "Fetched assignments: $($assignments.Count)" -component "DeleteAssignment-Button" -file "DeleteAssignmentButton.ps1"

# Filter out the selected group
Expand Down Expand Up @@ -63,7 +65,7 @@ $DeleteAssignmentButton.Add_Click({
$bodyObject = @{
mobileAppAssignments = $updatedAssignments
}
}elseif($global:CurrentPolicyType -eq "deviceManagementScripts") {
}elseif($global:CurrentPolicyType -eq "deviceManagementScripts" -or $global:CurrentPolicyType -eq "deviceShellScripts") {
$bodyObject = @{
deviceManagementScriptAssignments = $updatedAssignments
}
Expand All @@ -78,10 +80,10 @@ $DeleteAssignmentButton.Add_Click({
Write-IntuneToolkitLog "Body for update: $body" -component "DeleteAssignment-Button" -file "DeleteAssignmentButton.ps1"

# Update the assignments
if ($global:CurrentPolicyType -eq "mobileApps") {
$urlUpdateAssignments = "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$($selectedPolicy.PolicyId)/assign"
if ($global:CurrentPolicyType -eq "mobileApps" -or $global:CurrentPolicyType -eq "mobileAppConfigurations") {
$urlUpdateAssignments = "https://graph.microsoft.com/beta/deviceAppManagement/$($global:CurrentPolicyType)('$($selectedPolicy.PolicyId)')/assign"
} else {
$urlUpdateAssignments = "https://graph.microsoft.com/beta/deviceManagement/$($global:CurrentPolicyType)/$($selectedPolicy.PolicyId)/assign"
$urlUpdateAssignments = "https://graph.microsoft.com/beta/deviceManagement/$($global:CurrentPolicyType)('$($selectedPolicy.PolicyId)')/assign"
}
Write-IntuneToolkitLog "Updating assignments at: $urlUpdateAssignments" -component "DeleteAssignment-Button" -file "DeleteAssignmentButton.ps1"
Invoke-MgGraphRequest -Uri $urlUpdateAssignments -Method POST -Body $body -ContentType "application/json"
Expand Down
Loading

0 comments on commit aa95fc1

Please sign in to comment.