반응형
32비트 cmd.exe에서 64비트 파워셸을 시작하는 방법은?
이상한 질문인 것은 알지만 대상 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 {}
32비트 cmd 셸에서 64비트 파워셸 스크립트를 호출하는 방법에 대한 아이디어가 있습니까?
syswow64를 사용하면 64비트 코드에서 32비트 시스템 실행 파일을 실행할 수 있습니다.synastic을 사용하면 32비트 코드에서 64비트 시스템 실행 파일을 실행할 수 있습니다.
그래서 실행해야 합니다.
%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe
이 스크립트는 실행 중인 파워셸의 버전을 확인하고 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
#############################################################################
언급URL : https://stackoverflow.com/questions/19055924/how-to-launch-64-bit-powershell-from-32-bit-cmd-exe
반응형
'programing' 카테고리의 다른 글
| Galera 노드가 떨어지면 커밋에서 '잠금을 시도할 때 데드락 발견 (0) | 2023.09.28 |
|---|---|
| Excel VBA: 배열 변수의 변형 (0) | 2023.09.28 |
| 동적 매개변수를 사용한 Oracle Lag 함수 (0) | 2023.09.28 |
| jQuery를 사용하여 원소의 위쪽에서 px로 수직 거리를 찾는 방법 (0) | 2023.09.28 |
| Sequelize User M2M Group - 그룹에 속한 사용자 찾기 (0) | 2023.09.28 |