0

I currently try to write a PowerShell Script, in which a I have to import a 32bit module. The script should be automatically started by the Windows Task Scheduler. I wrote the following batch file, which starts the PowerShell script:

powershell.exe -ExecutionPolicy RemoteSigned -file "\myFilePath\myScript.ps1"
exit 0

My problem is that the PS file now runs in the 64-bit version, because I am executing it in a 64 bit environment.

Can I "save" the script as 64-bit version or something like that?

Update:

I already tried %windir%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPo[...] . This did not work for me. In my Error Log, which writes the script the typical error:

The term 'New-RDBaseItem' is not recognized as the name of a cmdlet, function, script file, or operable program.

3
  • @ Adam Luniewski Thank you for your help so far! Sorry for not informing you about this. I just updated my qustion. The missing backspace was just a typing error. It is correct in my code. Commented Feb 10, 2020 at 13:46
  • 1
    That error message just says that for whatever reason that cmdlet does not get imported. Run the script manually (with something like $VerbosePreference = "Continue") to see what's actually going wrong. If this error appears with both 64-bit and 32-bit PowerShell, then bitness is obviously not the issue. Commented Feb 10, 2020 at 13:48
  • There may not be a 32 bit version of that module. Commented Feb 10, 2020 at 13:49

1 Answer 1

2

Try to run it as a job like this:

$script = Start-Job -ScriptBlock {
  powershell.exe -ExecutionPolicy RemoteSigned -file "\myFilePath\myScript.ps1"
} -RunAs32
$script | Wait-Job | Receive-Job
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.