Public/Test-MacRosettaRuntime.ps1
|
function Test-MacRosettaRuntime { <# .SYNOPSIS Returns only the processes that are currently running under Rosetta 2 translation. .DESCRIPTION Test-MacRosettaRuntime is a focused wrapper around Get-MacRosettaAudit that returns only entries where a process is actively running under Rosetta 2 (x86_64 architecture detected via ps, or the binary is Intel-only and currently in the running process list). Use this for quick detection of active Rosetta usage, e.g. in Intune detection scripts. .PARAMETER IncludeSystemPaths Also scans system-level application and launch item directories. .OUTPUTS [pscustomobject] subset of Get-MacRosettaAudit output, filtered to CurrentlyUsingRosetta = $true. .EXAMPLE Test-MacRosettaRuntime Returns all processes currently running under Rosetta 2. .EXAMPLE if (Test-MacRosettaRuntime) { Write-Host "Rosetta is actively in use." exit 1 } Intune detection pattern: exits with code 1 if any process is running under Rosetta. .EXAMPLE Test-MacRosettaRuntime | Select-Object DisplayName, ProcessId, ProcessUser, ProcessArchitecture Shows a concise list of active Rosetta processes. .NOTES Requires macOS with PowerShell 7+. Performs a full scan (apps + running processes). To scan only running processes, use: Get-MacRosettaAudit -IncludeLaunchItems $false | Where-Object CurrentlyUsingRosetta #> [CmdletBinding()] [OutputType([pscustomobject])] param( [switch]$IncludeSystemPaths ) Get-MacRosettaAudit -IncludeSystemPaths:$IncludeSystemPaths | Where-Object { $_.CurrentlyUsingRosetta -eq $true } } |