PowerShell WMI 개체의 모든 속성을 나열하는 방법
Win32_ComputerSystem 클래스를 보면 다음과 같은 속성이 많이 표시됩니다.Status,PowerManagementCapabilities, 등. 단, PowerShell에서 다음 작업을 수행하면 몇 개만 반환됩니다.
PS C:\Windows\System32\drivers> Get-WmiObject -Class "Win32_computersystem"
Domain : YYY.com
Manufacturer : VMware, Inc.
Model : VMware Virtual Platform
Name : LONINEGFQEF58
PrimaryOwnerName : Authorised User
TotalPhysicalMemory : 2147016704
모든 숙박업소를 보려면 어떻게 해야 하나요?
이것을 시험해 보세요.
Get-WmiObject -Class "Win32_computersystem" | Format-List *
Get-WmiObject -Class "Win32_computersystem" | Format-List -Property *
특정 객체에 대해 PowerShell은 테이블 형식 또는 목록 형식에 영향을 줄 수 있는 일련의 포맷 명령을 제공합니다.이는 보통 속성 수량의 표시를 필수 속성으로 제한하기 위한 것입니다.하지만 정말 모든 것을 보고 싶을 때가 있다.이 경우Format-List *모든 속성이 표시됩니다.PowerShell 오류 레코드를 보려면 "Format-List * -Force"를 사용하여 모든 오류 정보를 확인해야 합니다. 예를 들어 다음과 같습니다.
$error[0] | Format-List * -force
와일드카드는 기존의 will 카드와 같이 사용할 수 있습니다.
Get-WmiObject -Class "Win32_computersystem" | Format-List M*
속성(및 메서드)을 알고 싶은 경우:
Get-WmiObject -Class "Win32_computersystem" | Get-Member
다음 항목도 사용할 수 있습니다.
Get-WmiObject -Class "Win32_computersystem" | Select *
다른 답변에서 사용된 Format-List *와 같은 결과가 나타납니다.
좋아해요
Get-WmiObject Win32_computersystem | format-custom *
그것은 모든 것을 확장하는 것처럼 보인다.
PowerShell Cookbook 모듈에는 GUI에서 이를 실행하는 show-object 명령도 있습니다.PowerShell의 크리에이터인 Jeffrey Snover는 이를 플러그형 비디오에서 사용합니다(권장).
내가 가장 자주 사용하는 것은
Get-WmiObject Win32_computersystem | fl *
오브젝트 타입의 테이블 또는 리스트뷰를 정의하는 .format.ps1xml 파일이 있는 경우 이를 회피합니다.형식 파일은 속성 이름과 일치하지 않는 열 헤더를 정의할 수도 있습니다.
가장 간단한 방법은 다음과 같습니다.
Get-WmiObject -Class win32_computersystem -Property *
네 가지 방법을 사용하여 개체의 모든 속성을 나열할 수 있습니다.
방법 1: 형식 테이블
Get-Process | Format-Table -Property * -Wrap | Out-File abc.txt -Width 5000
OR
Get-Process | Format-Table * -Wrap | Out-File abc.txt -Width 5000
OR
Get-Process | FT * -Wrap | Out-File abc.txt -Width 5000
방법 2: 형식 목록
Get-Process | Format-List -Property *
OR
Get-Process | Format-List *
OR
Get-Process | FL *
방법 3: ConvertTo-Html
Get-Process | ConvertTo-Html | Out-File services1.html ; invoke-item services1.html
방법 4: Out-Grid View
Get-Process | Select * | Out-GridView
파라미터 사용을 나타내는 결과 비교:
Format-Table/Format-List모든 열을 포함하려면 항상 다음을 사용하십시오.-Property *파라미터Format-Table항상 파일을 사용하여 출력을 캡처합니다.Out-File화면에 결과를 표시하면 일부 열이 포함되지 않을 수 있습니다.FormatTable항상 적절한 폭을 지정하다-Width그렇지 않으면 결과에서 열 값이 잘립니다.
Format-Table텍스트가 큰 열이 잘리지 않고 긴 열에 여러 줄로 표시되도록 항상 -rap을 사용합니다.
CovertTo-Html에는 "Collections"만 됩니다.Type Name컬렉션 항목의 쉼표로 구분된 값으로 구성된 컬렉션입니다.는 Format-Table,및 과 함께 .
언급URL : https://stackoverflow.com/questions/7259142/how-to-list-all-properties-of-a-powershell-wmi-object
'codememo' 카테고리의 다른 글
| CSS를 사용하여 체크박스를 스타일링하는 방법 (0) | 2023.04.08 |
|---|---|
| PowerShell에서 "백업" 컨텍스트를 사용하여 섀도 복사본 생성 (0) | 2023.04.08 |
| PowerShell에서 SQL Server 쿼리를 실행하려면 어떻게 해야 합니까? (0) | 2023.04.08 |
| SQL Server에서의 DateTime2와 DateTime (0) | 2023.04.08 |
| 테이블의 열 이름을 반환하려면 어떻게 해야 합니까? (0) | 2023.04.08 |


