ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Troubleshooting Windows Server with PowerShell

2020-01-05 21:56:06  阅读:310  来源: 互联网

标签:ClassName EventLog Get Windows Object Win32 Troubleshooting Property 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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有