powershell - 在 32 位模式下运行 Powershell 脚本
问题描述
我目前尝试编写一个 PowerShell 脚本,我必须在其中导入一个 32 位模块。该脚本应由 Windows 任务计划程序自动启动。我编写了以下批处理文件,它启动了 powershell 脚本:
powershell.exe -ExecutionPolicy RemoteSigned -file "\myFilePath\myScript.ps1"
exit 0
我的问题是,ps 文件现在在 64 位版本中运行,因为我在 64 位环境中执行它。我可以将脚本“安全”为 64 位版本或类似的版本吗?
更新:
我已经试过了%windir%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPo[...]
。这对我不起作用。在我的错误日志中,它写入脚本的典型错误是:
“‘New-RDBaseItem’一词未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。”
谢谢您的帮助!
解决方案
尝试像这样运行它:
$script = Start-Job -ScriptBlock {
powershell.exe -ExecutionPolicy RemoteSigned -file "\myFilePath\myScript.ps1"
} -RunAs32
$script | Wait-Job | Receive-Job
推荐阅读
- java - iot-service-client azure-iot-sdk java 的企业代理
- javascript - React 组件中状态的更新时间问题(需要单击 2 次而不是 1 次)
- reactjs - gatsby remark 图片不显示图片
- r - 根据 2 列中的值重新排序 ggplot 中的标签
- c# - c# 从继承的类对象构造一个类
- pyspark - Pyspark - 更新 udf 中的列表
- jquery - 如何从另一个动态创建的按钮触发动态创建的按钮
- reactjs - 如何在 React 中解决这个加载程序问题?
- php - 想在 name.php 中使用 index.php 的输入
- android - 多个用户是否可以在 FCM 中的列表中同时订阅一个主题