Get-runmode.ps1

In een 64bit installatie kan powershell in 32bit of in 64bit mode opgestart. Afhankelijk van deze mode zal de default registry key waar powershell naar toeschrijft of van leest verschillen. Om een script geschikt te maken voor beide runmodes kun je in het script bepalen welke versie is opgestart, de 32bit of de 64bit versie. Afhankelijk hiervan kun je dan b.v. de default key instellen.

#***************************************************************************
#** Script: Get-Runmode.ps1
#** Version: 1.0
#** Created: 02/12/2018 09:09AM
#** Author: Adriaan Westra
#**
#**
#** Purpose / Comments:
#** Display the runmode for the Powershell session. It can be either
#** 32bit or 64bit. Depending on the runmode decisions on which registry
#** key to use can be made.
#**
#** Changelog :
#** 02/12/2018 09:09AM : Initial version
#**
#***************************************************************************
#***************************************************************************
#** Function: Get-RunMode
#** Version: 1.0
#** Created: 02/12/2018 09:09AM
#** Author: Adriaan Westra
#**
#** Purpose / Comments:
#** Get runmode for the current proces. Depending on the runmode decisions
#** on which registry key to use can be made. In 32bit mode powershell will
#** write to Wow6432Node by default
#**
#** Arguments :
#** None
#**
#**
#** Returns :
#** 32bit or 64bit
#**
#**
#** Changelog :
#** 8:34 4-09-2018 : Initial version
#**
#***************************************************************************
Function Get-RunMode {
#***************************************************************************
#** Get process information for current powershell session
$PS=[diagnostics.process]::GetCurrentProcess()
#***************************************************************************
#** If the path contains syswow64 32bit version of powershell is started
if ($PS.path -match ‘\\syswow64\\’) {
Return “32bit”
} else {
Return “64bit”
}
}
#***************************************************************************
#** Clear screen
Clear-host
#***************************************************************************
#** Call function Get-runmode
Get-RunMode