- 날짜 및 시간을 확인하는 cmdlet는 Get-Date이다. Get-Date에서 다양한 Property를 이용하여 정보를 추출할 수 있다. 아래의 예를 한 번 살펴보자.
- Get-Date
- Get-Date | Format-List *
- Get-Date | Get-Member
- (Get-Date).AddDays(-1) –이것은 오늘 기준으로 하루 전의 Get-Date를 확인한다
(Get-Date).AddDays(-2)
(Get-Date).AddDays(10) — 오늘 기준으로 10일 후의 Get-Date 정보 확인 - (Get-Date).ToString(‘yyyy-MM-dd’) –간단하게 오늘 날짜를 표현하기
(get-date).AddDays(-1).ToString(‘yyyy-MM-dd’)
- Get-Date
- 2일전부터 오늘까지만 발생한 이벤트 정보 중에서 Error만을 확인해보자.
- Get-EventLog -LogName Application -EntryType Error -After (Get-Date).AddDays(-2)
- Get-EventLog -LogName System -EntryType Error -After (Get-Date).AddDays(-2)
- Get-EventLog -LogName Application -EntryType Error -After (Get-Date).AddDays(-2)
- 이렇게 하면 특정한 날짜 기간에만 오류를 발생한 정보를 확인할 수 있다. 특히 (Get-Date).AddDays(-2) 형식을 잘 알아두어야 한다.
'powershell' 카테고리의 다른 글
명령 프롬프트 유틸리티 확인하여 사용하기 (0) | 2014.09.26 |
---|---|
원하는 문자열만 찾기 : Select-String (0) | 2014.09.26 |
네트워크 어댑터(NIC)에 대한 정보 확인하기(Get-WmiObject 이용) (0) | 2014.09.26 |
디스크에 대한 정보 확인하기(Get-WmiObject 사용하기) (0) | 2014.09.26 |
Disk Controller에 오류가 있는지 확인하기 (0) | 2014.09.26 |
- NIC의 정보를 쉽게 확인하는 방법은 다음과 같다.
Get-WmiObject -Class Win32_*network* -List - 여기서 IP 구성 정보를 확인하는 Win32_NetworkAdapterConfiguration을 이용하면 편리하다
Get-WmiObject -Class Win32_NetworkAdapterConfiguration
Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Format-List *
(여기서 IPEnabled가 True인 것을 참고한다.)
Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where {$_.IPEnabled -eq ‘True’}
(이렇게 하면 로컬 컴퓨터 IP 구성 상황을 모두 알 수 있다.)Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName Server1 | Where {$_.IPEnabled -eq ‘True’}
(이렇게 하면 원격 컴퓨터 IP 구성 상황을 모두 알 수 있다.)
- 네트워크 어댑터 종류들을 확인해보자.
Get-WmiObject -Class Win32_NetworkAdapter
Get-WmiObject -Class Win32_NetworkAdapter | FT name
Get-WmiObject -Class Win32_NetworkAdapter
-ComputerName Server1 | FT name출처 : http://cloudsns.wordpress.com/category/microsoft/powershell/page/7/
'powershell' 카테고리의 다른 글
원하는 문자열만 찾기 : Select-String (0) | 2014.09.26 |
---|---|
특정한 시간 이후에 발생한 이벤트만 확인하기 (0) | 2014.09.26 |
디스크에 대한 정보 확인하기(Get-WmiObject 사용하기) (0) | 2014.09.26 |
Disk Controller에 오류가 있는지 확인하기 (0) | 2014.09.26 |
내 시스템에서 사용한 USB Storage 종류 알아보기 (0) | 2014.09.24 |
- 컬 컴퓨터 및 원격 컴퓨터의 디스크와 관련된 정보를 확인하기 위해서는 Get-WmiObject를 이용하면 된다.
- 먼저 disk와 관련된 Get-WmiObject를 확인하기 위해서 다음과 같이 하면 사용 가능한 목록을 확인할 수 있다.
Get-WmiObject -Class Win32_*Disk* -List - 이제 각각의 정보를 한 번 살펴보자.
Get-WmiObject -Class Win32_LogicalDisk
Get-WmiObject -Class Win32_LogicalDisk -ComputerName Server1
(원격지에 위치한 컴퓨터의 디스크 정보도 알 수 있다.)
Get-WmiObject -Class Win32_MappedLogicalDisk
Get-WmiObject -Class Win32_MappedLogicalDisk -ComputerName Server1
(원격 컴퓨터가 어느 fileserver에 연결되어 있는지 알 수 있다.)
Get-WmiObject -Class Win32_MappedLogicalDisk -ComputerName Server1 | ft name, providername, freespace -autosize
(이렇게 하면 원격 컴퓨터 Server1이 어느 File server에 어떤 드라이브로 연결되어 있는지 간략하게 알 수 있다.)Get-WmiObject -Class Win32_DiskPartition
Get-WmiObject -Class Win32_DiskPartition -ComputerName Server1Get-WmiObject -Class Win32_DiskDrive
Get-WmiObject -Class Win32_DiskPartition -ComputerName Server1Get-WmiObject -Class Win32_DiskQuota
Get-WmiObject -Class Win32_DiskQuota -ComputerName Server1
(각 사용자 단위로 디스크 할당량 정도를 확인할 수 있다. 원격 컴퓨터도 마찬가지.)출처 : http://cloudsns.wordpress.com/category/microsoft/powershell/page/8/
'powershell' 카테고리의 다른 글
특정한 시간 이후에 발생한 이벤트만 확인하기 (0) | 2014.09.26 |
---|---|
네트워크 어댑터(NIC)에 대한 정보 확인하기(Get-WmiObject 이용) (0) | 2014.09.26 |
Disk Controller에 오류가 있는지 확인하기 (0) | 2014.09.26 |
내 시스템에서 사용한 USB Storage 종류 알아보기 (0) | 2014.09.24 |
script에서 Param 사용하여 컴퓨터 정보 확인하기 (0) | 2014.09.24 |
- 로컬 컴퓨터의 Disk Controller에 문제가 있는지 확인하여 본다.
- Get-EventLog -LogName System -InstanceId 3221487627 -ErrorAction 0
- Get-EventLog -LogName System -InstanceId 3221487627 -ErrorAction 0 | ForEach-Object {$_.ReplacementStrings[0] } | Group-Object -NoElement | Sort-Object Count -Descending
- Get-EventLog -LogName System -InstanceId 3221487627 -ErrorAction 0
- 이렇게 하여 나온 것 중에 대부분은 USB drive를 강제로 빼서 생기는 것이 많다.
'powershell' 카테고리의 다른 글
네트워크 어댑터(NIC)에 대한 정보 확인하기(Get-WmiObject 이용) (0) | 2014.09.26 |
---|---|
디스크에 대한 정보 확인하기(Get-WmiObject 사용하기) (0) | 2014.09.26 |
내 시스템에서 사용한 USB Storage 종류 알아보기 (0) | 2014.09.24 |
script에서 Param 사용하여 컴퓨터 정보 확인하기 (0) | 2014.09.24 |
Write-Host와 Write-Output의 차이점 (0) | 2014.09.24 |
- 다음과 같이 실행하면 로컬 컴퓨터에서 사용한 USB 스토리지 정보를 Registry에 추출하여 확인할 수 있다.
$key = ‘Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*’
Get-ItemProperty $key | Select-Object -ExpandProperty FriendlyName | Sort-Object - 이것을 한 줄로 해결할 수 있다.(semicolon 사용)
$key = ‘Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*’;
Get-ItemProperty $key | Select-Object -ExpandProperty FriendlyName | Sort-Object - 이것을 스크립트로 만들어 사용하여 원격 컴퓨터에서 사용한 USB 종류를 알 수도 있다. 즉, PickupUSBtype.ps1 파일로 만들어서 다음과 같이 하면 원격 컴퓨터에서 사용한 USB 종류들을 확인할 수 있다.
Invoke-Command -FilePath c:\myscripts\PickupUSBtype.ps1 -ComputerName pc1, pc2, pc3
'powershell' 카테고리의 다른 글
디스크에 대한 정보 확인하기(Get-WmiObject 사용하기) (0) | 2014.09.26 |
---|---|
Disk Controller에 오류가 있는지 확인하기 (0) | 2014.09.26 |
script에서 Param 사용하여 컴퓨터 정보 확인하기 (0) | 2014.09.24 |
Write-Host와 Write-Output의 차이점 (0) | 2014.09.24 |
시스템에서 제공하는 Variable(변수)을 확인하기 활용하기 (0) | 2014.09.24 |