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

上一篇:Vue 3D轮播 带缩略图 版本 (+动画 翻卡)


下一篇:JavaScript中设置元素class,添加/删除元素class的方法