Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9e3910a
Fix Office channel scripts and make -WhatIf honest
NullSpace-BitCradle Nov 18, 2026
5902f00
Make the smart card scripts fail honestly and add a lockout guard
NullSpace-BitCradle Nov 18, 2026
8a56878
Fix enrollment test, MDM sync and log collection scripts
NullSpace-BitCradle Nov 18, 2026
6ad2c3d
Fix Test-IntuneConnectivity so it tests the Intune endpoints
NullSpace-BitCradle Nov 18, 2026
fe90770
Give IntuneCommon a manifest, a credential helper and correct OData e…
NullSpace-BitCradle Nov 18, 2026
35b11a3
Fix Get-IntunePolicyAssignments: show unassigned policies, stop insta…
NullSpace-BitCradle Nov 18, 2026
e131989
Fix Get-IntuneDeviceCompliance: per-device policy states, no silent gaps
NullSpace-BitCradle Nov 18, 2026
3c78f58
Fix Get-IntuneDeviceDetails: paging, quote escaping, no Graph install
NullSpace-BitCradle Nov 18, 2026
f361e45
Fix Get-IntuneDeviceHealth false "unsupported" and never-synced scoring
NullSpace-BitCradle Nov 18, 2026
1c3fcf7
Fix Get-IntuneWin32AppDetails: no fake zeros, real device install state
NullSpace-BitCradle Nov 18, 2026
43ab94e
Fix Export-IntuneDeviceReport: report state failures instead of hidin…
NullSpace-BitCradle Nov 18, 2026
21123ac
Fix Get-IntuneAllAppsAssignmentDetails: exclusions, paging, README pa…
NullSpace-BitCradle Nov 18, 2026
b67abac
Tidy the Print Spooler scripts
NullSpace-BitCradle Nov 18, 2026
c481561
Make the code PSScriptAnalyzer-clean and the tests pass on Windows Po…
NullSpace-BitCradle Nov 18, 2026
b54bfa0
Add CI, changelog, and bring the README in line with the code
NullSpace-BitCradle Nov 18, 2026
19cfd60
Use the beta endpoint for Win32 deviceStatuses and pin the test to it
NullSpace-BitCradle Nov 18, 2026
94903f0
Enable smart card: write scforceoption last and roll it back on failure
NullSpace-BitCradle Nov 18, 2026
a52f32d
Set-OfficeUpdateChannel: read registry values without the H1 crash; r…
NullSpace-BitCradle Nov 18, 2026
392b341
Correct docs: new function, ConvertTo-Array change, detection fail-open
NullSpace-BitCradle Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
analyze:
name: PSScriptAnalyzer
runs-on: windows-latest
timeout-minutes: 15
steps:
# Every action is pinned to a full commit SHA. The comment names the tag it was taken from.
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name PSScriptAnalyzer -RequiredVersion 1.25.0 -Scope CurrentUser -Force

# Per file, because a whole-tree run printed an internal NullReference in the audit.
# Tests\ is skipped: Pester mock bodies cannot see $script: variables, so the tests use one $global: table on purpose.
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
Import-Module PSScriptAnalyzer -RequiredVersion 1.25.0
$files = Get-ChildItem -Recurse -File -Include *.ps1, *.psm1, *.psd1 |
Where-Object { $_.FullName -notlike '*\Tests\*' -and $_.FullName -notlike '*\.git\*' }
$results = foreach ($file in $files) {
Invoke-ScriptAnalyzer -Path $file.FullName -Settings ./PSScriptAnalyzerSettings.psd1
}
Write-Host "Analyzed $($files.Count) file(s)."
if ($results) {
$results | Format-Table -AutoSize ScriptName, Line, RuleName, Severity, Message | Out-String -Width 250 | Write-Host
throw "PSScriptAnalyzer reported $(@($results).Count) finding(s)."
}

test:
name: Pester (${{ matrix.shell }})
runs-on: windows-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# pwsh is PowerShell 7. powershell is Windows PowerShell 5.1, which is what Intune runs.
shell: [pwsh, powershell]
defaults:
run:
shell: ${{ matrix.shell }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Pester
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
# -SkipPublisherCheck: Windows PowerShell 5.1 ships Pester 3.4 signed by Microsoft
Install-Module -Name Pester -RequiredVersion 5.9.1 -Scope CurrentUser -Force -SkipPublisherCheck

- name: Parse every script
run: |
$errors = foreach ($file in Get-ChildItem -Recurse -File -Include *.ps1, *.psm1, *.psd1 | Where-Object { $_.FullName -notlike '*\.git\*' }) {
$tokens = $null; $parseErrors = $null
[System.Management.Automation.Language.Parser]::ParseFile($file.FullName, [ref]$tokens, [ref]$parseErrors) | Out-Null
foreach ($e in $parseErrors) { "$($file.Name):$($e.Extent.StartLineNumber) $($e.Message)" }
}
if ($errors) { $errors | ForEach-Object { Write-Host $_ }; throw "Parse errors found." }

- name: Run Pester
run: |
Import-Module Pester -RequiredVersion 5.9.1
$config = New-PesterConfiguration
$config.Run.Path = './Tests'
$config.Run.Exit = $true
$config.Output.Verbosity = 'Normal'
Invoke-Pester -Configuration $config
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ desktop.ini
.vscode/
.idea/
*.code-workspace

# Test fixtures are allowed even though the patterns above ignore data files
!Tests/**/*.json
!Tests/**/*.csv
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

## Unreleased (fix/audit-2026-11-18)

Fixes from the 2026-11-18 audit. See the commit messages for the reasoning behind each change.

### Fixed

- `Set-OfficeUpdateChannel.ps1`: wrote an array of 15 URLs to `CDNBaseUrl` and always exited 1. It now writes one URL, uses the real Click-to-Run updater and fails if the updater is missing.
- `Enable-` and `Disable-SmartCardLogonEnforcement.ps1`: report real success or failure, verify each write, keep the log, forward `-WhatIf` on the 64-bit relaunch. Enable refuses to run without a working smart card reader unless `-Force` is given.
- `Test-IntuneEnrollment.ps1`: no longer crashes on registry subkeys without a ProviderID.
- `Test-IntuneConnectivity.ps1`: the Intune endpoints are tested; failure to retrieve an endpoint list fails the run.
- `Start-MDMSync.ps1`: requires Windows PowerShell 5.1, reads `ExtendedError`, and returns the documented timeout code.
- Reporting scripts: unassigned policies are listed, failed requests show as errors and exit 1, results are paged, device compliance is per device, exclusions are labelled, and the scripts no longer install the Microsoft.Graph module.
- `Repair-MultipleIntuneMDMCert.ps1` and `Set-OfficeUpdateChannel.ps1`: `-WhatIf` exits 0.
- `Detect-OfficeUpdateChannel.ps1`: separates compliant, not applicable, cannot determine and non-compliant.
- `Get-IntuneDeviceLogs.ps1`: exit code reflects failures.
- `Get-IntuneDeviceHealth.ps1`: no false "unsupported" management agents.

### Added

- `-ClientSecretSecure` on the Graph scripts, `Get-IntuneCredential` and related helpers in `IntuneCommon`, and `IntuneCommon.psd1` (version 1.1.0).
- Formula-safe CSV output.
- Pester tests in `Tests\` and a GitHub Actions workflow (PSScriptAnalyzer and Pester, actions pinned to commit SHAs).
- `Get-IntuneAllAppsAssignmentDetails.ps1`: `-ExportCSVpath` and a `TargetType` column.
- `Test-IntuneConnectivity.ps1`: `-IncludeUnlistedEndpoints`.

### Changed

- `Remove-ODataInjectionChars` and `Test-ODataFilterInput` double single quotes instead of deleting them.
- `ConvertTo-Array` now has a process block, so it handles each item of a pipeline instead of only the last. Callers that piped several items and relied on that now get all of them.
- `Get-IntuneGraphHeaders` is new on this branch and takes `-AppRegistration`; it is not a change to an existing signature.
- Graph reports use the beta endpoint for `mobileApps/{id}/deviceStatuses` (Win32 per-device install state), because Microsoft documents it only there.
- `Enable-SmartCardLogonEnforcement.ps1` writes `scforceoption` last, only if every other step succeeded, and puts the old value back if its own write or read-back fails.
37 changes: 37 additions & 0 deletions Common/IntuneCommon.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@{
RootModule = 'IntuneCommon.psm1'
ModuleVersion = '1.1.0'
GUID = '6e874e85-9805-4993-9a39-f0a5ec6151d8'
Author = 'NullSpace-BitCradle'
CompanyName = 'NullSpace-BitCradle'
Copyright = '(c) NullSpace-BitCradle. MIT License.'
Description = 'Shared helpers for the Intune PowerShell scripts: Microsoft Graph token request, retry and paging, credential handling, OData escaping and CSV formula safety.'
PowerShellVersion = '5.1'
FunctionsToExport = @(
'ConvertTo-Array',
'ConvertTo-ODataStringLiteral',
'ConvertTo-SafeCsvRecord',
'Get-GraphAccessToken',
'Get-GraphApiAllPages',
'Get-IntuneCredential',
'Get-IntuneGraphHeaders',
'Get-IntuneLogPath',
'Invoke-GraphApiWithRetry',
'Protect-CsvValue',
'Remove-ODataInjectionChars',
'Test-EmailFormat',
'Test-GuidFormat',
'Test-ODataFilterInput',
'Write-StandardError'
)
CmdletsToExport = @()
VariablesToExport = @()
AliasesToExport = @()
PrivateData = @{
PSData = @{
Tags = @('Intune', 'Graph', 'Endpoint')
LicenseUri = 'https://github.com/NullSpace-BitCradle/Intune_PowerShell_Scripts/blob/main/LICENSE'
ProjectUri = 'https://github.com/NullSpace-BitCradle/Intune_PowerShell_Scripts'
}
}
}
Loading
Loading