forked from officecigar/windows_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
troubleshot.ps1
100 lines (61 loc) · 3.33 KB
/
troubleshot.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<#
.SYNOPSIS
get server info to trouble shoot it Updates & Logs !!! FUN STUFF
.EXAMPLE
'one', 'two', 'three' TroubleShootLogs.ps1
.EXAMPLE
TroubleShootLogs.ps1 -computername localhost
.EXAMPLE
TroubleShootLogs.ps1 -computeername one, two, three
.EXAMPLE
get-content <ServerList.txt> or <ServerList.csv> | TroubleShootLogs.ps1
.PARAMETER computername
one or more computername, or IP address... peace to America!
#>
[cmdletbinding()]
Param(
[Parameter (Mandatory=$true,ValuefromPipeline=$true)]
[string []]$computername,
[string]$errorlogpath ='c:\temp\Trouble_Shoot_.log'
)
begin{
$host.UI.RawUI.WindowTitle = "Trouble Shooting "
$day = Read-Host "how many days do you want to go back for patches"
}
process{
foreach ($computer in $computername) {
Write-Verbose "about to query $computer"
try {
$who = Get-WMIObject Win32_ComputerSystem -computername $computer| Select-Object -ExpandProperty name
} catch {
$computer | Out-File $errorlogpath -append
}
$starttime =Get-Date
$configs= Get-WindowsFeature | ? { $_.Installed } | ft -AutoSize
$mem=[math]::Round((Get-WmiObject -Class Win32_ComputerSystem -computer $computer ).TotalPhysicalMemory/1GB)
Write-Host ""
Get-HotFix -ComputerName $computer |?{$_.InstalledOn -gt ((Get-Date).AddDays(-$day))} | ft -AutoSize
$patchUpdates = (get-hotfix -ComputerName $computer -Description update* | sort installedon)[-1] | ft -AutoSize
$processesors = Get-WmiObject –class Win32_processor -ComputerName $computer | select Name, NumberOfCores,NumberOfEnabledCore,NumberOfLogicalProcessors | ft -AutoSize
$logviewError = Get-EventLog -ComputerName $computer -LogName System -after ([datetime]::Today) | Where-Object {$_.EntryType -like 'Error' } | ft -AutoSize
$logviewCritical = Get-EventLog -ComputerName $computer -LogName System -after ([datetime]::Today) | Where-Object{$_.EntryTypentryType -like 'Critical'} | ft -AutoSize
$logviewWarning = Get-EventLog -ComputerName $computer -LogName System -after ([datetime]::Today) | Where-Object {$_.EntryType -like 'Warning' } | ft -AutoSize
Write-Host ""
Write-Host "#######################" -ForegroundColor DarkGreen
write-output $computer
Write-Host "#######################" -ForegroundColor DarkGreen
Write-Output $processesors
Write-Output "$mem GB of Ram on $computer"
write-output $configs
write-output $computer $patchSecurity
write-output $patchUpdates
write-output $logviewCritical
write-output $logviewWarning
write-output $logviewError
}
}
End{
$endtime =Get-Date
$total= $endtime -$starttime
Write-host "Total Script time to run $total" -ForegroundColor Yellow |ft -AutoSize
}