Skip to content

Commit ad2d56f

Browse files
committed
Remove unnecessary comments and revamp admin check
1 parent e9f3d44 commit ad2d56f

File tree

1 file changed

+12
-36
lines changed

1 file changed

+12
-36
lines changed

functions/microwin/Microwin-NewReportingTool.ps1

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ function Microwin-NewReportingTool {
33
# embedding reporting tool with here string
44
$reportingTool = @'
55
#requires -version 5.0
6-
#requires -runasadministrator
76
87
function Get-ComputerInventory {
98
<#
@@ -25,12 +24,7 @@ function Microwin-NewReportingTool {
2524
2625
$hinv += "`n`n-- Computer System:`n"
2726
28-
# Computer System information reported:
29-
# - Manufacturer
30-
# - Model
31-
# - System Family
32-
# - System SKU Number
33-
# - Hypervisor Present
27+
# Computer System information
3428
$hinv += "`n - Manufacturer: $($computerSystemInformation.Manufacturer)"
3529
$hinv += "`n - Model: $($computerSystemInformation.Model)"
3630
$hinv += "`n - System Family: $($computerSystemInformation.SystemFamily)"
@@ -39,13 +33,7 @@ function Microwin-NewReportingTool {
3933
4034
$hinv += "`n`n-- Processor:`n"
4135
42-
# Processor information reported, for each processor:
43-
# - Device ID
44-
# - Name
45-
# - Manufacturer
46-
# - Caption
47-
# - Number of Cores (of which Number of Enabled Cores)
48-
# - Number of Total Logical processors
36+
# Processor information reported, for each processor
4937
$processorInformation | Foreach-Object {
5038
$hinv += "`nFor device ID $($_.DeviceID):"
5139
$hinv += "`n - Name: $($_.Name)"
@@ -57,13 +45,7 @@ function Microwin-NewReportingTool {
5745
5846
$hinv += "`n`n-- Memory information:`n"
5947
60-
# Memory information reported, for each module:
61-
# - Module number
62-
# - Bank Label
63-
# - Tag
64-
# - Manufacturer -- this is the reference provided by manufacturer. For example, HMCG88AGBSA092N returns a SK Hynix module
65-
# - Part Number
66-
# - Clock Speed
48+
# Memory information reported, for each module
6749
$moduleNumber = 0
6850
$memoryInformation | Foreach-Object {
6951
$hinv += "`nModule number $($moduleNumber):"
@@ -77,15 +59,7 @@ function Microwin-NewReportingTool {
7759
7860
$hinv += "`n`n-- Available Volumes as of reporting tool run time:`n"
7961
80-
# Disk Volume information reported, for each volume:
81-
# - Drive UniqueID
82-
# - Drive Letter
83-
# - Drive Label
84-
# - Drive Type
85-
# - File System type
86-
# - Health Status
87-
# - Total Size
88-
# - Remaining Size (Size Percentage)
62+
# Disk Volume information reported, for each volume
8963
$volumeInformation | Foreach-Object {
9064
$hinv += "`nFor volume with UniqueID $($_.UniqueId):"
9165
$hinv += "`n - Drive Letter: $($_.DriveLetter)"
@@ -99,12 +73,7 @@ function Microwin-NewReportingTool {
9973
10074
$hinv += "`n`n-- BIOS information:`n"
10175
102-
# BIOS information:
103-
# - Manufacturer
104-
# - Name
105-
# - Caption
106-
# - BIOS version
107-
# - Serial Number
76+
# BIOS information
10877
$hinv += "`n - Manufacturer: $($biosInformation.Manufacturer)"
10978
$hinv += "`n - Name: $($biosInformation.Name)"
11079
$hinv += "`n - Caption: $($biosInformation.Caption)"
@@ -354,6 +323,13 @@ function Microwin-NewReportingTool {
354323
}
355324
}
356325
326+
if (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -eq $false)
327+
{
328+
Write-Host "You need to run this script as an administrator."
329+
Read-Host | Out-Null
330+
exit 1
331+
}
332+
357333
$version = "1.0"
358334
Clear-Host
359335
Write-Host "MicroWin reporting tool -- version $version"

0 commit comments

Comments
 (0)