forked from rhi-ko/Single-PC-Audit.ps1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPCAudit
107 lines (83 loc) · 5.89 KB
/
PCAudit
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
<#
.SYNOPSIS
Windows Machine Inventory Using PowerShell.
.DESCRIPTION
This script is to document the Windows machine. This script will work only for Local Machine.
.EXAMPLE
PS C:\> .\System_Inventory.PS1
.OUTPUTS
HTML File OutPut ReportDate , General Information , BIOS Information etc.
#>
#Set-ExecutionPolicy RemoteSigned -ErrorAction SilentlyContinue
$UserName = (Get-Item env:\username).Value
$ComputerName = (Get-Item env:\Computername).Value
$filepath = (Get-ChildItem env:\userprofile).value
Add-Content "$Filepath\style.CSS" -Value " body {
font-family:Calibri;
font-size:10pt;
}
th {
background-color:black;
color:white;
}
td {
background-color:#19fff0;
color:black;
}"
Write-Host "CSS File Created Successfully... Executing Inventory Report!!! Please Wait !!!" -ForegroundColor Yellow
#ReportDate
$ReportDate = Get-Date | Select -Property DateTime | ConvertTo-Html -Fragment
#General Information
$ComputerSystem = Get-WmiObject -Class Win32_ComputerSystem |
Select -Property Model , Manufacturer , Description , @{Name='Owner Name';Expression={($_.PrimaryOwnerName)}} , @{Name='System Type';Expression={($_.SystemType)}} |ConvertTo-Html -Fragment
#Last Logged on User
$LastLoggedonUser = Get-WmiObject -Class Win32_ComputerSystem -Property UserName -ComputerName . |
Select Username | ConvertTo-Html -Fragment
#BIOS Information
#May need to use a different variable other than "serialnumber" for warranty information.
#Running on a desktop will require modification to generate the correct information in the report.
#Run the following command to see a listing of the options you can enter AFTER the "Select -Property" section in the actual command.
#Get-WmiObject -Class Win32_BIOS | select -property *
$BIOS = Get-WmiObject -Class Win32_BIOS | Select -Property @{Name='Computer Name';Expression={($_.PSComputerName)}} , Manufacturer , Version, @{Name='Serial Number';Expression={($_.serialnumber)}}, @{Name='Description';Expression={($_.description)}} | ConvertTo-Html -Fragment
#Operating System Information
$oslang = get-culture | select-object name
$OS = Get-WmiObject -Class Win32_OperatingSystem | Select -Property Caption , @{Name='Service Packs';Expression={($_.CSDVersion)}} , @{Name='OS Architecture';Expression={($_.osarchitecture)}} , @{Name='OS Language';Expression={($oslang).name}} | ConvertTo-Html -Fragment
#Time Zone Information
$TimeZone = Get-WmiObject -Class Win32_TimeZone | Select Caption , @{Name='Time Zone';Expression={($_.StandardName)}} |
ConvertTo-Html -Fragment
#Logical Disk Information
#Will report on ALL attached Hard Disks
$Disk = Get-WmiObject -Class Win32_LogicalDisk -Filter DriveType=3 |
Select @{Name='Drive Letter';Expression={($_.DeviceID)}} , @{Name=”Size (GB)”;Expression={“{0:N1}” -f($_.size/1gb)}}, @{Name=”Free Space (GB)”;Expression={“{0:N1}” -f($_.freespace/1gb)}}, @{Name='Free (%)';Expression={[int]($_.Freespace*100/$_.Size)} } |
ConvertTo-Html -Fragment
#CPU Information
$SystemProcessor = Get-WmiObject -Class Win32_Processor |
Select @{Name='System Name';Expression={($_.SystemName)}} , @{Name='CPU Model';Expression={($_.Name)}} , @{Name='Max Clock Speed (GHz)';Expression={"{0:N2}" -f ($_.maxclockspeed/1000)}} , Manufacturer , @{Name='Status';Expression={($_.status)}} | ConvertTo-Html -Fragment
#Memory Information
$PhysicalMemory = Get-WmiObject -Class Win32_PhysicalMemory |
Select -Property Tag , @{Name='Serial Number';Expression={($_.serialNumber)}} , @{Name='Part Number';Expression={($_.PartNumber)}} , Manufacturer , @{Name='RAM Bank';Expression={($_.devicelocator)}} , @{Name="Capacity (GB)";Expression={"{0:N1}" -f ($_.Capacity/1GB)}} | ConvertTo-Html -Fragment
#Network Information
$Networkinfo = get-netadapter |
select @{Name='Network Connection Name';Expression={($_.name)}}, @{Name='Network Interface';Expression={($_.interfacedescription)}},status,@{Name='Mac Address';Expression={($_.macaddress)}},@{Name='Link Speed';Expression={($_.linkspeed)}},@{Name="Full Duplex?";Expression={($_.fullduplex)}}| sort status -descending | ConvertTo-Html -fragment
#Software Inventory
$Software = Get-WmiObject -Class Win32_Product |
#Where-Object name -like "Microsoft*2013" |
sort name |
Select @{Name='Installed Software';Expression={($_.name)}} , Vendor , Version , @{Name='Description';Expression={($_.Caption)}} |ConvertTo-Html -Fragment
#If you want to list ONLY "Microsoft 2013" products in the Software Inventory section, uncomment the above "Where-Object" line.
#Change the filter in the quotes to fill your specific need.
#If the "Where-Object" line IS commented out, the Software Inventory section will display ALL software shown on the Add/Remove Programs section inside of Windows.
ConvertTo-Html -Body "<font color = red><H4><B>Report Created On</B></H4></font>$ReportDate
<font color = red><H4><B>General Information</B></H4></font>$ComputerSystem
<font color = red><H4><B>Last Logged on User</B></H4></font>$Lastloggedonuser
<font color = red><H4><B>BIOS Information</B></H4></font>$BIOS
<font color = red><H4><B>Operating System Information</B></H4></font>$OS
<font color = red><H4><B>Time Zone Information</B></H4></font>$TimeZone
<font color = red><H4><B>Disk Information</B></H4></font>$Disk
<font color = red><H4><B>Processor Information</B></H4></font>$SystemProcessor
<font color = red><H4><B>Memory Information</B></H4></font>$PhysicalMemory
<font color = red><H4><B>Network Information</B></H4></font>$Networkinfo
<font color = red><H4><B>Software Inventory</B></H4></font>$Software" -CssUri "$filepath\style.CSS" -Title "Server Inventory" | Out-File "$FilePath\$ComputerName.htm"
Write-Host "Script Execution Completed" -ForegroundColor Yellow
#forces report to be displayed in Internet Explorer. Displaying in Chrome doesn't view properly.
(new-object -ComObject InternetExplorer.Application).navigate("$FilePath\$ComputerName.htm")