在 32 位模式下运行 Powershell 脚本 [英] Run Powershell Script in 32 bit mode

查看:75
本文介绍了在 32 位模式下运行 Powershell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试编写一个 PowerShell 脚本,其中我必须导入一个 32 位模块.该脚本应由 Windows 任务计划程序自动启动.我编写了以下批处理文件,它启动了 powershell 脚本:

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

我的问题是,ps 文件现在在 64 位版本中运行,因为我在 64 位环境中执行它.我可以将脚本安全"为 64 位版本或类似版本吗?

My problem is, that the ps file now runs in the 64bit version, because I am executing it in a 64 bit enviroment. Can I "safe" the script as 64 bit version or something like that?

更新:

我已经尝试过 %windir%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPo[...].这对我不起作用.在我的错误日志中,它编写了脚本的典型错误:

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:

术语New-RDBaseItem"未被识别为 cmdlet、函数、脚本文件或可运行程序的名称."

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

感谢您的帮助!

推荐答案

尝试将其作为这样的作业运行:

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

这篇关于在 32 位模式下运行 Powershell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆