
PowerShell을 통해 여러 Windows 호스트에서 원격으로 OS 아키텍처를 가져오는 방법을 아는 사람이 있습니까?
답변1
get-wmiobject win32_operatingsystem -computer $_ | select-object OSArchitecture
$_가 목록의 각 컴퓨터로 해석되도록 컴퓨터 이름 목록을 이 명령으로 파이프라인합니다.
편집: 몇 가지 조사를 해보니 2003년과 2008년 모두에서 작동하는 것으로 보입니다.
get-wmiobject win32_computersystem -computer $_ | select-object systemtype
답변2
Windows XP/2003 이상의 경우 Win32_Processor에는 적절하게 32 또는 64인 AddressWidth 속성이 있습니다.
Windows 장치 관리자에 알려진 각 CPU에 대해 Win32_Processor 클래스의 WMI 개체 인스턴스가 1개 있으므로 과거에는 일반적으로 이런 종류의 작업을 수행했습니다. VBScript입니다. 제 PowerShell은 형편없지만 이해가 되실 겁니다...
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor WHERE AddressWidth='64'")
If colItems.Count = 0 Then
strArch = "x86"
Else
strArch = "x64"
End If
업데이트: PowerShell로 번역됨:
If ($(Get-WmiObject -Query "SELECT * FROM Win32_Processor WHERE AddressWidth='64'")) {
Write-Host "I'm x64"
} Else {
Write-Host "I'm x86"
}
답변3
조금 덜 화려할 수도 있지만 원격 WMI를 활성화하지 않은 사용자의 경우 약간 구식 방법은 다음과 같습니다.
$compList = #<whatever you use to source your list of machines>
ForEach($comp in $compList){
$testPath64 = '\\' + $comp + '\c$\Program Files (x86)'
$testPath = '\\' + $comp + '\c$\Program Files'
$arch = Test-Path $testPath64
If($arch){Write-Host "$comp is x64"}
Else{
$arch = Test-Path $testPath
If($arch){Write-Host "$comp is x86"}
Else{Write-Host "No idea..."}
}
}
아니면 그런 것. 요점은 64비트 시스템에만 존재하는 프로그램 파일(x86)에 대한 테스트 경로입니다.