-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystemCheck.ps1
125 lines (100 loc) · 4.1 KB
/
systemCheck.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
$etConfig=Get-Content -Path config.json | ConvertFrom-Json
$etSettings=Get-Content -Path settings.json | ConvertFrom-Json
Write-Host "Checking for elevated permissions..."
if (!([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "Insufficient permissions. This PowerShell doesn't run as Administrator! Some Function will not deliver results while systemCheck.ps1 is running. Open the PowerShell console as an administrator and run this script again."
Write-Host("If you want to continue press [ENTER], if not type 'exit'")
$stopScript = Read-Host
if($stopScript) #checks if variable null or empty, if not scripts exit here
{
Write-Host("---Stop script here (Exit)---")
exit
}
}
else {
Write-Host "Code is running as administrator — go on executing the script..." -ForegroundColor Green
}
Write-Host "`n################################################"
Write-Host "file: systemCheck.ps1"
$date = Get-Date
Write-Host ("start at: {0}" -f $date)
Write-Host "################################################`n"
Write-Host("Input directory path or press [ENTER] to use etSettings.defaultSavePath")
$savePath = Read-Host
if(!$savePath)
{
Write-Host("No path was given")
Write-Host("using etSettings.defaultSavePath instead")
if((Test-Path -Path $etSettings.defaultSavePath))
{
$savePath = $etSettings.defaultSavePath
}
else
{
Write-Host("Err: Path doesn't exist {0}" -f $etSettings.defaultSavePath)
Write-Host("---Stop script here (Exit)---")
exit
}
}
elseif(!(Test-Path -Path $savePath))
{
Write-Host("Err: Path doesn't exist {0}" -f $savePath)
Write-Host("---Stop script here (Exit)---")
exit
}
Write-Host "`n`nCheck..."
Write-Host " ExecutionPolicy"
$currPath = Join-Path -path $savePath -childpath "ExecutionPolicy.txt"
Get-ExecutionPolicy |
Out-File $currPath
Write-Host " ComputerInfo"
$currPath = Join-Path -path $savePath -childpath "\ComputerInfo.txt"
Get-ComputerInfo |
Out-File $currPath
Write-Host " Get-Command"
$currPath = Join-Path -path $savePath -childpath "\Get-Command.txt"
Get-Command |
Out-File $currPath
Write-Host " Get InstalledSoftware"
$currPath = Join-Path -path $savePath -childpath "\InstalledSoftware.txt"
$pathsToInstalledSoftware=@(
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\',
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'
)
Out-File $currPath # removes old file and add new empty one
foreach($path in $pathsToInstalledSoftware){
Get-ChildItem -Path $path |
Get-ItemProperty |
Select-Object DisplayName, Publisher, InstallDate, DisplayVersion, InstallLocation |
Format-Table -AutoSize |
Out-File $currPath -Append
}
Write-Host " Get InstalledSoftware avaliable over winget"
$currPath = Join-Path -path $savePath -childpath "\InstalledSoftware-winget.txt"
winget list |
Sort-Object |
Out-File winget-packages-installed.txt
Write-Host " powercfg get energyreport {`n"
$currPath = Join-Path -path $savePath -childpath "\Powercfg-Energyreport.html"
powercfg.exe -energy -output $currPath
#powercfg.exe -energy -output $currPath -verb runAs
Write-Host "`n}`n"
Write-Host " powercfg get batteryreport {`n"
$currPath = Join-Path -path $savePath -childpath "\Powercfg-Batteryreport.html"
powercfg.exe -batteryreport -output $currPath
Write-Host "`n}`n"
Write-Host " Get-PSDrive -PSProvider 'FileSystem'"
$currPath = Join-Path -path $savePath -childpath "\PSProvider-FileSystem.txt"
Get-PSDrive -PSProvider 'FileSystem' |
Out-File $currPath
Write-Host " Collecting Information about Volumes (Harddrives, SSDs, ...)"
$currPath = Join-Path -path $savePath -childpath "\Volumes-Information.txt"
Get-PhysicalDisk |
Out-File $currPath
Get-Disk |
Out-File $currPath -Append
Get-Partition |
Out-File $currPath -Append
Get-Volume |
Out-File $currPath -Append
Write-Host ("`n`n finished.`n See results at {0}" -f $savePath)