我知道这是一个奇怪的问题,但我被锁定在第三方供应商,它在目标64位Windows Server 2008 R2集群服务器上启动32位cmd.exe.从这里开始,我想启动一个64位的PowerShell窗口并运行一个脚本.
这是我的测试:
powershell.exe "Get-Module -ListAvailable| Where-Object {$_.name -eq 'FailoverClusters'}"
如果我从32位cmd.exe运行它,我什么都没有返回.如果我从64位cmd.exe运行,我得到:
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest FailoverClusters {}
Run Code Online (Sandbox Code Playgroud)
关于如何从32位cmd shell调用64位PowerShell脚本的任何想法?
Jas*_*irk 80
syswow64允许您从64位代码运行32位系统可执行文件.sysnative允许您从32位代码运行64位系统可执行文件.
所以,你需要运行:
%SYSTEMROOT%\ sysnative\WindowsPowerShell\V1.0\powershell.exe
Pro*_*eur 13
此脚本将检查您正在运行的powershell版本,如果您在32位运行,将重新启动到64位.当重新启动时,它还将传入原始调用中使用的任何参数.
#############################################################################
#If Powershell is running the 32-bit version on a 64-bit machine, we
#need to force powershell to run in 64-bit mode .
#############################################################################
if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
write-warning "Y'arg Matey, we're off to 64-bit land....."
if ($myInvocation.Line) {
&"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile $myInvocation.Line
}else{
&"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile -file "$($myInvocation.InvocationName)" $args
}
exit $lastexitcode
}
write-host "Main script body"
#############################################################################
#End
#############################################################################
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
53072 次 |
最近记录: |