16 July 2026

Intune - documentation and backup. Part 5

 Automation Account


Next step is to create an Automation Account.
I will use the following in the creation:

Configuration

Value

Resource group

RG-BBJ-IntuneMgmt

Automation account name

AA-BBJ-IntuneMgmt

Region

West Europe

System assigned

Selected

Connectivity configuration

Public access

Go to Process Automation, select Runbooks and click “Create a runbook”.





When created, we land in “Edit PowerShell Runbook”.

Now copy this script into Runbook:

# IntuneManagement 
# Intune Backup and Documentation
# Version 1.0
# Customer settings
$RGname = "RG-BBJ-IntuneMgmt"
$AutoAcc = "AA-BBJ-IntuneMgmt"
$StorAcc = "sabbjintunemgmt"

$TenantId = "94801ede-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$AppId = "61b18e96-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$TheSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$DocJson = "BulkDocumentation.json"
$BUJson = "BulkExport.json"

# Don't change below this point....
# Share names
$shareIntune    = "IntuneManagement"   # I:
$shareDocs      = "documentation"      # D:
$shareBackup    = "backup"             # B:

# Drive letters
$driveIntune = "I:"
$driveDocs   = "D:"
$driveBackup = "B:"

# Local paths (no date subfolders locally as requested)
$localRoot        = "C:\Intune\IntuneManagement"
$localToolDir     = Join-Path $localRoot "IntuneManagement"
$localDocFolder   = Join-Path $localRoot "Documentation"
$localBackupDir   = Join-Path $localRoot "Backup"

# ===== Helper functions =====
function Log([string]$msg) {
    $t = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    Write-Output "$t  $msg"
}

function MapDrive($drive$unc) {
    Log "Mapping $drive -> $unc"
    $cmd = "net use $drive `"$unc`" /user:Azure\$storAcc `"$SAKey`""
    cmd.exe /c $cmd > $null 2>&1
    Start-Sleep -Seconds 1
    if (-not (Test-Path "$drive\")) { throw "Failed to map $drive to $unc" }
    Log "Mapped $drive"
}

function UnmapDrive($drive) {
    Log "Unmapping $drive"
    cmd.exe /c "net use $drive /delete /y" > $null 2>&1
    Start-Sleep -Seconds 1
    Log "Unmapped $drive"
}

function EnsureDir($path) {
    if (-not (Test-Path $path)) {
        New-Item -Path $path -ItemType Directory -Force | Out-Null
        Log "Created folder: $path"
    }
}

# Ensures you do not inherit an AzContext in your runbook
Disable-AzContextAutosave -Scope Process

# Connect to Azure with system-assigned managed identity
$AzureContext = (Connect-AzAccount -identity).context

# set and store context
$AzureContext = Set-AzContext -SubscriptionName $AzureContext.Subscription -DefaultProfile $AzureContext

# access file share
$SAkey = (Get-AzStorageAccountKey -resourcegroupname $RGname -name $StorAcc)[0].value
$context = New-AzStorageContext -StorageAccountName $StorAcc -StorageAccountKey $SAkey

# ===== Start =====
Log "Run start - creating local structure and dummy files"

try {
    # Build UNC paths
    $uncIntune = "\\$StorAcc.file.core.windows.net\$shareIntune"
    $uncDocs   = "\\$StorAcc.file.core.windows.net\$shareDocs"
    $uncBackup = "\\$StorAcc.file.core.windows.net\$shareBackup"

    # Map drives
    MapDrive $driveIntune $uncIntune
    MapDrive $driveDocs $uncDocs
    MapDrive $driveBackup $uncBackup

    # Ensure local directories exist
    EnsureDir $localRoot
    EnsureDir $localToolDir
    EnsureDir $localDocFolder
    EnsureDir $localBackupDir

    # Copy IntuneManagement to local folder
    Log "Copying content from $driveIntune to $localToolDir"
    Copy-Item -Path "$driveIntune\*" -Destination $localToolDir -Recurse -Force -ErrorAction SilentlyContinue
    Log "Copy from I: completed"

    cd $localToolDir
    Log "Starting Documentation..." 
    Start-Process powershell -ArgumentList ".\Start-IntuneManagement.ps1 -silent -tenantId $TenantId -appid $AppId -secret $TheSecret -SilentBatchFile $DocJson" -wait    
    Log "End of Documentation..." 

    Log "Starting BackUp..." 
    Start-Process powershell -ArgumentList ".\Start-IntuneManagement.ps1 -silent -tenantId $TenantId -appid $AppId -secret $TheSecret -SilentBatchFile $BUJson" -wait
    Log "End of Backup..." 

    # Copy documentation file back to D:
    Log "Copying documentation file to $driveDocs"
    Copy-Item -Path (Join-Path $localDocFolder "*") -Destination $driveDocs -Force -ErrorAction Stop
    Log "Documentation file copied to share D:"

    # Copy entire local Backup folder to B:
    Log "Copying local backup folder to $driveBackup"
    Copy-Item -Path (Join-Path $localBackupDir "*") -Destination $driveBackup -Recurse -Force -ErrorAction Stop
    Log "Backup folder copied to share B:"

    # Local cleanup: remove local Tool, Documentation and Backup contents
    Log "Cleaning up local folders"
    try {
        Remove-Item -Path $localToolDir -Recurse -Force -ErrorAction SilentlyContinue
        Remove-Item -Path $localDocFolder -Recurse -Force -ErrorAction SilentlyContinue
        Remove-Item -Path $localBackupDir -Recurse -Force -ErrorAction SilentlyContinue
        Log "Local cleanup completed"
    } catch {
        Log "Local cleanup error: $($_.Exception.Message)"
    }

catch {
    Log ("ERROR: " + $_.Exception.Message)
finally {
    # Unmap drives
    try { UnmapDrive $driveDocs } catch { Log ("Unmap D: failed: " + $_.Exception.Message) }
    try { UnmapDrive $driveBackup } catch { Log ("Unmap B: failed: " + $_.Exception.Message) }
    try { UnmapDrive $driveIntune } catch { Log ("Unmap I: failed: " + $_.Exception.Message) }
    Log "Run completed"
}

In the script, there is a customer settings part (line 4 to 13). Settings here, should be changed according to you environment:

Variable

Description

My Values

$Rgname

Resource group

RG-BBJ-IntuneMgmt

$AutoAcc

Automation Account

AA-BBJ-IntuneMgmt

$StorAcc

Storage Accunt

sabbjintunemgmt

$TenantId

Tenant ID


$AppId    

Application (client) ID


$Secret

Client secret


$DocJson

File for running documentation (located on IntuneManagement share)

BulkDocumentation.json

$BUJson

Json file for running backup (located on IntuneManagement share)

BulkExport.json

You can do a test-run by choosing “Test pane”.

When the script runs without any errors, press “Publish”.

Now we will create a schedule to run this job automatically. Go to “Shared Resources”  > “Schedules” and hit “+ Add a schedule”.



Fill out with schedule name, time and recurrence, then hit create.


Now we have automized our backup and documentation of Intune.

As it is now, we will fill up space with backups and documentation files. We could do some clean-up....
In next part I will take the script and put in some house-cleaning.

14 July 2026

Intune - documentation and backup. Part 4

IntuneManagement

Now, download "Intune Management" from "https://github.com/Micke-K/IntuneManagement", and copy all files to the "intunemanagement" file share.

Because we want "IntuneManagement" to run unattended, we will have to create 2 json files:

  • BulkDocumentation.json
  • BulkExport.json
and put them in the intunemanagement share.


BulkDocumentation.json


{
    "BulkDocumentation":  [
                              {
                                  "Name":  "cbDocumentationType",
                                  "Value":  "html"
                              },
                              {
                                  "Name":  "cbDocumentationLanguage",
                                  "Value":  "en"
                              },
                              {
                                  "Name":  "cbDocumentationPropertySeparator",
                                  "Value":  ";"
                              },
                              {
                                  "Name":  "cbDocumentationObjectSeparator",
                                  "Value":  "\r\n"
                              },
                              {
                                  "Name":  "txtDocumentFilter",
                                  "Value":  ""
                              },
                              {
                                  "Name":  "txtDocumentFromFolder",
                                  "Value":  ""
                              },
                              {
                                  "Name":  "cbNotConifugredText",
                                  "Value":  null
                              },
                              {
                                  "Name":  "chkSkipNotConfigured",
                                  "Value":  false
                              },
                              {
                                  "Name":  "chkSkipDefaultValues",
                                  "Value":  false
                              },
                              {
                                  "Name":  "chkSkipDisabled",
                                  "Value":  true
                              },
                              {
                                  "Name":  "cbDocumentationValueOutputProperty",
                                  "Value":  "value"
                              },
                              {
                                  "Name":  "chkSetUnconfiguredValue",
                                  "Value":  true
                              },
                              {
                                  "Name":  "chkSetDefaultValue",
                                  "Value":  false
                              },
                              {
                                  "Name":  "chkIncludeScripts",
                                  "Value":  true
                              },
                              {
                                  "Name":  "chkExcludeScriptSignature",
                                  "Value":  false
                              },
                              {
                                  "Name":  "chkExcludeAssignments",
                                  "Value":  false
                              },
                              {
                                  "Name":  "txtHTMLDocumentName",
                                  "Value":  "C:\\Intune\\IntuneManagement\\Documentation\\%Date%-Doc.html"
                              },
                              {
                                  "Name":  "txtHTMLCSSFile",
                                  "Value":  ""
                              },
                              {
                                  "Name":  "chkHTMLOpenDocument",
                                  "Value":  false
                              },
                              {
                                  "Name":  "cbHTMLDocumentOutputFile",
                                  "Value":  "Full"
                              },
                              {
                                  "Name":  "txtDocumentationRawData",
                                  "Value":  ""
                              },
                              {
                                  "Name":  "ObjectTypes",
                                  "Type":  "Custom",
                                  "ObjectTypes":  [
                                                      "AppConfiguration",
                                                      "AppProtection",
                                                      "AppleEnrollment",
                                                      "Azure",
                                                      "Apps",
                                                      "ConditionalAccess",
                                                      "CustomAttributes",
                                                      "CompliancePolicies",
                                                      "DeviceConfiguration",
                                                      "WinDriverUpdatePolicies",
                                                      "EndpointAnalytics",
                                                      "EndpointSecurity",
                                                      "EnrollmentRestrictions",
                                                      "WinFeatureUpdates",
                                                      "PolicySets",
                                                      "WinQualityUpdates",
                                                      "Scripts",
                                                      "TenantAdmin",
                                                      "WinUpdatePolicies",
                                                      "WinEnrollment"
                                                  ]
                              }
                          ]
}

BulkExport.json

{

    "BulkExport":  [

                       {

                           "Name":  "txtExportPath",

                           "Value":  "C:\\Intune\\IntuneManagement\\Backup\\%Date%"

                       },

                       {

                           "Name":  "txtExportNameFilter",

                           "Value":  ""

                       },

                       {

                           "Name":  "chkAddObjectType",

                           "Value":  true

                       },

                       {

                           "Name":  "chkExportAssignments",

                           "Value":  true

                       },

                       {

                           "Name":  "chkAddCompanyName",

                           "Value":  true

                       },

                       {

                           "Name":  "chkExportScript",

                           "Value":  true

                       },

                       {

                           "Name":  "chkExportApplicationFile",

                           "Value":  true

                       },

                       {

                           "Name":  "chkExportPolicyFile",

                           "Value":  true

                       },

                       {

                           "Name":  "ObjectTypes",

                           "Type":  "Custom",

                           "ObjectTypes":  [

                                               "AdministrativeTemplates",

                                               "ADMXFiles",

                                               "AndroidOEMConfig",

                                               "AppConfigurationManagedApp",

                                               "AppConfigurationManagedDevice",

                                               "AppProtection",

                                               "AppleEnrollmentTypes",

                                               "Applications",

                                               "AuthenticationContext",

                                               "AuthenticationStrengths",

                                               "AutoPilot",

                                               "AzureBranding",

                                               "HardwareConfigurations",

                                               "CoManagementSettings",

                                               "CompliancePolicies",

                                               "CompliancePoliciesV2",

                                               "ComplianceScripts",

                                               "ConditionalAccess",

                                               "MacCustomAttributes",

                                               "DeviceCategories",

                                               "DeviceConfiguration",

                                               "DriverUpdateProfiles",

                                               "EndpointSecurity",

                                               "EnrollmentRestrictions",

                                               "EnrollmentStatusPage",

                                               "FeatureUpdates",

                                               "AssignmentFilters",

                                               "DeviceHealthScripts",

                                               "IntuneBranding",

                                               "InventoryPolicies",

                                               "NamedLocations",

                                               "Notifications",

                                               "PolicySets",

                                               "QualityUpdates",

                                               "ReusableSettings",

                                               "RoleDefinitions",

                                               "ScopeTags",

                                               "PowerShellScripts",

                                               "MacScripts",

                                               "SettingsCatalog",

                                               "TermsAndConditions",

                                               "TermsOfUse",

                                               "UpdatePolicies",

                                               "W365ProvisioningPolicies",

                                               "W365UserSettings"

                                           ]

                       }

                   ]

}


Create these two json files and put them in the intunemanagement share.

Then we are ready for the Automation Account.


13 July 2026

Intune - documentation and backup. Part 3

Storage Account

In part 3 of the "Intune - documentation and backup" series, I will first create a Resource group to hold all resources, and to track cost.
After that, I will go on to create the Storage account that will hold all files.

Resource Group


Create a Resource group.
Select your Subscription. Fill in with a Resource group name, and then select your Region.
I will create a Resource Group "RG-BBJ-IntuneMgmt" in West Europe.

Storage Account


I will create a Storage Account with the following configuration:

Configuration

Value

Basics

 

Storage account name

sabbjintunemgmt

Resource group

RG-BBJ-IntuneMgmt

Region

(Europe) West Europe

Primary service

Azure Blob Storage or Azure Data Lake Storage

Performance

Standard (general-purpose v2)

Redundancy

LRS

 

 

Advanced

 

Access tier

Cool

 

 

Networking

 

Public network access

Enable

Public network access scope

Enable from all networks

Routing preference

Microsoft network routing

 

 

Security

 

Require secure transfer for REST API operaions

Enabled

Enable storage account key access

Enabled

Minimum TLS version

Version 1.2

Permitted scope for copy operations

From any storage account

 

 

Encryption

 

Encryption type

Microsoft-managed keys (MMK)

 

 

























In Access Control (IAM) add  a role assignment.

Select “Reader” and assign access to Managed identity, and select the Automation Account as member.

 


 

 

 







Also add the Automation Account to role assignment “Storage Account Key Operator Service Role”.


In this Storage Account, I will create 3 Classic File Shares:


Share name

Value

backup

This will contain Backup data from Intune

documentation

This share will contain versions of the Intune Documentation created at runtime.

intunemanagement

This share contains the tool IntuneManagement and it must be copied to this share.












Next step is to get "IntuneManagement" and prepare it.


09 July 2026

Comming soon - Cloud Rebuild

 

  • Cloud rebuild is now introduced to Windows Insiders.
  • Cloud rebuild is a new recovery option that restores a Windows 11 PC to a clean, known-good state by performing a full OS reinstall, even when Windows won’t boot. Unlike Reset this PC, Cloud rebuild downloads both the target Windows image and the device’s drivers from Windows Update, so the device comes back fully functional without USB media, without a custom image, and without depending on the health of the currently installed OS.



The new Cloud rebuild option in Windows Recovery Environment (WinRE), enabling a full Windows reinstall using files downloaded from Windows Update.
More about it here:

08 July 2026

Intune - documentation and backup. Part 2

 App Registration

First, we create an App registration in Entra ID.

Navigate to Entra ID > Manage > App registrations.
Click on "New registration" and fill in Name and Supported account types.


On the page for the App (IntuneManagement) go to “API permissions” blade.
Add a permission > Microsoft Graph > Application permissions.

Add the following API permissions as shown in the following example.
Then do “Grant admin consent for ….”.



Permissions

Agreement.ReadWrite.All

Application.Read.All

CloudPC.ReadWrite.All

DeviceManagementApps.ReadWrite.All

DeviceManagementConfiguration.ReadWrite.All

DeviceManagementManagedDevices.ReadWrite.All

DeviceManagementRBAC.ReadWrite.All

DeviceManagementScripts.ReadWrite.All

DeviceManagementServiceConfig.ReadWrite.All

Group.ReadWrite.All

Organization.ReadWrite.All

Policy.Read.All

Policy.ReadWrite.ConditionalAccess

User.ReadWrite.All


Next, we will create a Client secret.
On “Certificates & secrets” blade, choose “Client secrets" and then “+ New client secret”.


Take note of the “Value” when creating the secret, we will need this. After creation the Value is hidden.

Now, we have prepared the App registration.
In the next step, I will create a Resource group for the tool to manage cost and resources.
Also, I will create a Storage Account to hold tool files and backup/documentation.

Intune - documentation and backup. Part 1

Working for customers, I had a need to make documentation to my work in Intune.
Using Word and Snipping Tool did the job, but it was time consuming, and the document had to be updated every time some changes was made in Intune.

Then I discovered "Intune Management" by Micke-K
Micke-K/IntuneManagement: Copy, export, import, delete, document and compare policies and profiles in Intune and Azure with PowerShell script and WPF UI. Import ADMX files and registry settings with ADMX ingestion. View and edit PowerShell script.

With his tool I could easily create documentation, and even export settings to JSON files as backup.

When starting the app and logging in, some permissions are required and must be approved.


Then the GUI is ready. From here, you can export, import and do documentation.


This is a great tool.
But there is more.... you can automate it, and run it on a schedule.

I will like to schedule, run and store backup and documentation in Azure. Without any use of onprem.
But this setup can easily be modified to run on an onprem server and storage.

During this serie of blogs, I will walk you through the Azure setup, like App Registration, Resource Group, Storage Account, Automation Account and script.

How this can give some inspiration.