Created
October 5, 2020 16:01
-
-
Save robm82/8946aa0460a1feb00c434768b4ed1329 to your computer and use it in GitHub Desktop.
Script to run Intune Win32 PowerShell scripts in 64-bit context
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Many thanks to Z-NERD for this, and this script is a copy of the one provided on his website | |
# Here is a link to the original script: https://z-nerd.com/blog/2020/03/31-intune-win32-apps-powershell-script-installer/ | |
# This is here just in case the post gets removed/lost :) | |
$argsString = "" | |
If ($ENV:PROCESSOR_ARCHITEW6432 -eq "AMD64") { | |
Try { | |
foreach($k in $MyInvocation.BoundParameters.keys) | |
{ | |
switch($MyInvocation.BoundParameters[$k].GetType().Name) | |
{ | |
"SwitchParameter" {if($MyInvocation.BoundParameters[$k].IsPresent) { $argsString += "-$k " } } | |
"String" { $argsString += "-$k `"$($MyInvocation.BoundParameters[$k])`" " } | |
"Int32" { $argsString += "-$k $($MyInvocation.BoundParameters[$k]) " } | |
"Boolean" { $argsString += "-$k `$$($MyInvocation.BoundParameters[$k]) " } | |
} | |
} | |
Start-Process -FilePath "$ENV:WINDIR\SysNative\WindowsPowershell\v1.0\PowerShell.exe" -ArgumentList "-File `"$($PSScriptRoot)\Install.ps1`" $($argsString)" -Wait -NoNewWindow | |
} | |
Catch { | |
Throw "Failed to start 64-bit PowerShell" | |
} | |
Exit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment