在 32 位模式下运行 Powershell 脚本

编程入门 行业动态 更新时间:2024-10-15 14:15:06
本文介绍了在 32 位模式下运行 Powershell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我目前正在尝试编写一个 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 "myFilePathmyScript.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%SysWOW64WindowsPowerShellv1.0powershell.exe -ExecutionPo[...].这对我不起作用.在我的错误日志中,它编写了脚本的典型错误:

I already tried %windir%SysWOW64WindowsPowerShellv1.0powershell.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 "myFilePathmyScript.ps1"
} -RunAs32
$script | Wait-Job | Receive-Job

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

更多推荐

[db:关键词]

本文发布于:2023-04-14 06:06:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/836699.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   模式下   Powershell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!