Functions/Validations/Test-BitProcess.ps1
<#
.SYNOPSIS Tests if the PowerShell session is started as a x64 bit process. .DESCRIPTION Returns $true if the session is started as 64-bit process and $false when the session is 32-bit. .EXAMPLE Test-BitProcess .EXAMPLE # Returns either $true or $false but supresses the warning when the session is 32-bit. Test-BitProcess -WarningAction SilentlyContinue .EXAMPLE # Log a warning when the session is not a 64-bit process but ignore the $false output. Test-BitProcess | Out-Null .EXAMPLE Test-BitProcess -Verbose | Out-Null #> function Test-BitProcess { [CmdletBinding()] [OutputType([bool])] param() if(-not [Environment]::Is64BitProcess){ Write-Warning 'This script needs to be executed as a 64-bit process. Current process is 32-bit(x86). Start the script in a 64-bit PowerShell session.' return $false } Write-Verbose 'PowerShell session is a x64 process.' return $true } Export-ModuleMember -Function Test-BitProcess |