/build/static/layout/Breadcrumb_cap_w.png

64 Bit powershell

I was trying to run a native powershell script and no matter what I did it wouldnt run. Apparently it was accessing part of the registry which required the 64bit powershell. I dont even fully understand what the hell happened but I worked on it for hours and hours and it ran fine for my in powershell unelevated but I could not get it to run via kace.   It would always say it couldnt find the path in the registry and looked like it was referencing c/windows/system32/ and then the registry path.  


In an effort to provide information as well as take from here, this was the fix after opening a ticket:

Set-Alias Start-PowerShell64 "$env:windir\sysnative\WindowsPowerShell\v1.0\powershell.exe"

Start-PowerShell64 get-childitem -Path etc etc (powershell command)

So apparently kace uses a 32 bit vers of PS? I dont know, dont care, just annoying.

Good luck.




0 Comments   [ + ] Show comments

Answers (1)

Posted by: Unsullied 2 years ago
Senior White Belt
0

As the KACE agent is x86, this would be the workaround. You can prepend your powershell script with the following code block to execute it in x64:


# To execute in x64 powershell #

if ($PSHOME -like "*syswow64*") { 

    Write-Output 'Relaunching as x64' 

    & (Join-Path ($PSHOME -replace 'syswow64', 'sysnative') powershell.exe) ` 

        -File $Script:MyInvocation.MyCommand.Path ` 

        @args 

    Exit 

######################

# Rest of script goes in here #


Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ