系统相关
首页 > 系统相关> > Troubleshooting Windows Server with PowerShell

Troubleshooting Windows Server with PowerShell

作者:互联网

Obtaining a List of Installed Applications:
Get-CimInstance -ClassName Win32_Product |fl

 

Get-EventLog –LogName System | Where-Object {$_.Eventid –eq 1074}

Get-EventLog -LogName System -Newest 10

Get-EventLog | Get-Member

Get-EventLog -LogName System -Newest 10 | Select-Object -Property Index,TimeGenerated, TimeWritten, EventType, Source, CategoryNumber, Message

Get-EventLog –ComputerName Server01 –LogName System

$systemlog = Get-EventLog –LogName System –Oldest 10

$systemlog | Select-Object -Property InstanceId, Message, Source,TimeGenerated

$systemlog | Select-Object -Property InstanceId, Message, Source,TimeGenerated | Export-Csv -Path "c:\reports\systemlog.csv"

$systemlog | Select-Object -Property InstanceId, Message, Source,TimeGenerated | Export-Csv -Path "c:\reports\systemlog.csv" -NoTypeInformation

 

$htmlformat = @"
<style>
Table {border-width: 1px; border-style: solid; border-color: black;}
TH {border-width: 1px; padding: 3px; border-style: solid;}
TR:nth-child(even) {background: #CCC}
TR:nth-child(odd) {background: #FFF}
</style>
"@

$HTMLformatted = $systemlog | ConvertTo-Html –fragment | Out-String

 

Write-EventLog -LogName Application -Source "My Application" –EventID 1000 –Message "This is the message being logged"

New-EventLog -LogName Application -Source "My Application"

Get-PhysicalDisk | ConvertTo-Html -Title 'Get-PhysicalDisk Information' |Set-Content C:\Reports\GetPhysicalDisk.htm
Get-PhysicalDisk | Export-Csv -NoTypeInformation -Path C:\Reports\GetPhysicalDisk.csv
Get-Disk | ConvertTo-Html -Title 'Get-Disk Information' |Set-Content C:\Reports\GetDisk.htm
Get-Disk | Export-Csv -NoTypeInformation -Path C:\Reports\GetDisk.csv

 

Get-WmiObject -List -Namespace ROOT\CIMV2 | Sort-Object Name

Get-WmiObject -List -Namespace ROOT\CIMV2 | Where-Object Name -Match 'disk' | Sort-Object Name

Get-WmiObject -Class Win32_LogicalDisk

Get-WmiObject -List -Namespace ROOT\CIMV2 | Where-Object Name -Match 'share' | Sort-Object Name

Get-CimInstance -ClassName Win32_BIOS | Export-Csv -NoTypeInformation -Path C:\Reports\Win32_Bios.csv

Get-CimInstance -ClassName Win32_BIOS | Get-Member

 

Get-CimInstance -ClassName Win32_BIOS |
Select-Object -Property Manufacturer,
SerialNumber,
ReleaseDate,
SMBIOSBIOSVersion,
SMBIOSMajorVersion,
SMBIOSMinorVersion,
@{
Name = 'FormattedBIOSVersion';
Expression = {$_.BIOSVersion -join ";"}
}

 

Get-CimClass -Namespace Root\CimV2 -ClassName win32*processor*

Get-CimInstance -ClassName Win32_Processor | Format-List  -Property *

Get-CimInstance -ClassName Win32_Processor |
Select-Object -Property DeviceID,
Status,
AddressWidth,
MaxClockSpeed,
Caption,
Description,
Name,
CurrentClockSpeed

 

Get-CimInstance -ClassName Win32_Processor |
Select-Object -Property DeviceID,
Status,
AddressWidth,
MaxClockSpeed,
Caption,
Description,
Name,
CurrentClockSpeed |
Export-Csv -NoTypeInformation -Path C:\Reports\Win32_Processor.csv

标签:ClassName,EventLog,Get,Windows,Object,Win32,Troubleshooting,Property,PowerShell
来源: https://blog.51cto.com/ganzy/2464516