Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Windows temp files
Thumbs.db
Desktop.ini
*.tmp
*.temp

# PowerShell
*.ps1~
*.psm1~

# Log files
*.log

# Build artifacts
*.intunewin
*.zip

# IDE and editor files
.vscode/
.vs/
*.suo
*.user
.idea/

# Mac files
.DS_Store

# Installer files (should be downloaded separately)
*.msi
*.exe
*.cab

# Backup files
*.bak
*~
32 changes: 32 additions & 0 deletions Intune/Examples/Detection-7Zip.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<#
.SYNOPSIS
Detect 7-Zip installation via Intune

.DESCRIPTION
Detects whether 7-Zip is installed on the system.

.EXAMPLE
.\Detection-7Zip.ps1

.NOTES
Author: KD7DGF
Version: 1.0
Date: 2025-10-11
#>

try {
# Check if 7-Zip is installed
$7zipPath = "C:\Program Files\7-Zip\7z.exe"

if (Test-Path $7zipPath) {
$version = (Get-Item $7zipPath).VersionInfo.FileVersion
Write-Host "7-Zip detected (Version: $version)"
exit 0
} else {
# Not detected - exit with 0 but no output
exit 0
}
} catch {
Write-Error "Detection failed: $($_.Exception.Message)"
exit 1
}
38 changes: 38 additions & 0 deletions Intune/Examples/Detection-GoogleChrome.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<#
.SYNOPSIS
Detect Google Chrome installation via Intune

.DESCRIPTION
Detects whether Google Chrome is installed on the system.

.EXAMPLE
.\Detection-GoogleChrome.ps1

.NOTES
Author: KD7DGF
Version: 1.0
Date: 2025-10-11
#>

try {
# Check common installation paths for Chrome
$chromePaths = @(
"C:\Program Files\Google\Chrome\Application\chrome.exe",
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
)

foreach ($path in $chromePaths) {
if (Test-Path $path) {
$version = (Get-Item $path).VersionInfo.FileVersion
Write-Host "Google Chrome detected (Version: $version)"
exit 0
}
}

# Not detected - exit with 0 but no output
exit 0

} catch {
Write-Error "Detection failed: $($_.Exception.Message)"
exit 1
}
100 changes: 100 additions & 0 deletions Intune/Examples/Install-7Zip.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<#
.SYNOPSIS
Install 7-Zip via Intune

.DESCRIPTION
Installs 7-Zip MSI package for Windows devices managed by Intune.

.EXAMPLE
.\Install-7Zip.ps1

.NOTES
Author: KD7DGF
Version: 1.0
Date: 2025-10-11

Download the latest 7-Zip MSI from: https://www.7-zip.org/download.html
Place the MSI file in the same directory as this script.
#>

[CmdletBinding()]
param()

# Set error action preference
$ErrorActionPreference = "Stop"

# Configuration
$AppName = "7-Zip"
$InstallerName = "7z*-x64.msi" # Adjust based on actual MSI filename

# Get script directory
$ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition

# Logging function
function Write-Log {
param(
[Parameter(Mandatory=$true)]
[string]$Message,

[Parameter(Mandatory=$false)]
[ValidateSet('Info','Warning','Error')]
[string]$Level = 'Info'
)

$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logMessage = "[$timestamp] [$Level] $Message"

switch ($Level) {
'Info' { Write-Host $logMessage -ForegroundColor Green }
'Warning' { Write-Host $logMessage -ForegroundColor Yellow }
'Error' { Write-Host $logMessage -ForegroundColor Red }
}

$logPath = "$env:ProgramData\Intune\Logs"
if (-not (Test-Path $logPath)) {
New-Item -Path $logPath -ItemType Directory -Force | Out-Null
}

$logFile = Join-Path $logPath "Install-7Zip.log"
Add-Content -Path $logFile -Value $logMessage
}

try {
Write-Log -Message "Starting installation of $AppName" -Level Info

# Check if running as administrator
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Log -Message "Script must be run as administrator" -Level Error
exit 1
}

# Find the installer
$installer = Get-ChildItem -Path $ScriptPath -Filter $InstallerName | Select-Object -First 1

if (-not $installer) {
Write-Log -Message "7-Zip installer not found in script directory" -Level Error
Write-Log -Message "Expected pattern: $InstallerName" -Level Error
exit 1
}

$installerPath = $installer.FullName
Write-Log -Message "Found installer: $installerPath" -Level Info

# Install 7-Zip
Write-Log -Message "Installing 7-Zip..." -Level Info
$msiArgs = "/i `"$installerPath`" /qn /norestart"
$process = Start-Process -FilePath "msiexec.exe" -ArgumentList $msiArgs -Wait -PassThru

if ($process.ExitCode -eq 0) {
Write-Log -Message "7-Zip installation completed successfully" -Level Info
exit 0
} else {
Write-Log -Message "7-Zip installation failed with exit code: $($process.ExitCode)" -Level Error
exit $process.ExitCode
}

} catch {
Write-Log -Message "Installation failed: $($_.Exception.Message)" -Level Error
exit 1
}
98 changes: 98 additions & 0 deletions Intune/Examples/Install-GoogleChrome.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<#
.SYNOPSIS
Install Google Chrome via Intune

.DESCRIPTION
Installs Google Chrome MSI package for Windows devices managed by Intune.

.EXAMPLE
.\Install-GoogleChrome.ps1

.NOTES
Author: KD7DGF
Version: 1.0
Date: 2025-10-11

Download the Chrome MSI from: https://cloud.google.com/chrome-enterprise/browser/download/
Place the MSI file in the same directory as this script.
#>

[CmdletBinding()]
param()

# Set error action preference
$ErrorActionPreference = "Stop"

# Configuration
$AppName = "Google Chrome"
$InstallerName = "googlechromestandaloneenterprise64.msi"

# Get script directory
$ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition

# Logging function
function Write-Log {
param(
[Parameter(Mandatory=$true)]
[string]$Message,

[Parameter(Mandatory=$false)]
[ValidateSet('Info','Warning','Error')]
[string]$Level = 'Info'
)

$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logMessage = "[$timestamp] [$Level] $Message"

switch ($Level) {
'Info' { Write-Host $logMessage -ForegroundColor Green }
'Warning' { Write-Host $logMessage -ForegroundColor Yellow }
'Error' { Write-Host $logMessage -ForegroundColor Red }
}

$logPath = "$env:ProgramData\Intune\Logs"
if (-not (Test-Path $logPath)) {
New-Item -Path $logPath -ItemType Directory -Force | Out-Null
}

$logFile = Join-Path $logPath "Install-GoogleChrome.log"
Add-Content -Path $logFile -Value $logMessage
}

try {
Write-Log -Message "Starting installation of $AppName" -Level Info

# Check if running as administrator
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Log -Message "Script must be run as administrator" -Level Error
exit 1
}

# Find the installer
$installerPath = Join-Path $ScriptPath $InstallerName

if (-not (Test-Path $installerPath)) {
Write-Log -Message "Chrome installer not found at: $installerPath" -Level Error
exit 1
}

Write-Log -Message "Found installer: $installerPath" -Level Info

# Install Google Chrome with silent parameters
Write-Log -Message "Installing Google Chrome..." -Level Info
$msiArgs = "/i `"$installerPath`" /qn /norestart"
$process = Start-Process -FilePath "msiexec.exe" -ArgumentList $msiArgs -Wait -PassThru

if ($process.ExitCode -eq 0) {
Write-Log -Message "Google Chrome installation completed successfully" -Level Info
exit 0
} else {
Write-Log -Message "Google Chrome installation failed with exit code: $($process.ExitCode)" -Level Error
exit $process.ExitCode
}

} catch {
Write-Log -Message "Installation failed: $($_.Exception.Message)" -Level Error
exit 1
}
Loading