|
| 1 | + |
| 2 | +<# |
| 3 | +************** Overview ************** |
| 4 | +
|
| 5 | +This one's just a bit of fun. Same as it's counterparts but speaks what it's doing.This script |
| 6 | +creates a HTML specsheet for the computer it is run on, and saves it on the current user's |
| 7 | +desktop. As part of this script PowerCfg will save a Battery Report on the desktop also. |
| 8 | +
|
| 9 | +************** Formatting Information ****************** |
| 10 | +
|
| 11 | +HTML File Naming format: "Spec Report from User-PC (21st of May).htm" Vars used for that are $env:computername $date |
| 12 | +Battery Report naming format: "Battery Report from User-PC.html" Uses $env:computername only |
| 13 | +Text size: H2 for main header, H3 for sub-headings, H4 for normal test and H5 for the note |
| 14 | +Other Formatting: Font: Segoe UI Light, Spacing: 0.02em, Margin: 5.5em, line-height: 1.7em |
| 15 | +The battery report HTML file also introduces it's own formatting, though this is mostly fine now |
| 16 | +Colors: rgb(35, 73, 116) for background, white for normal text, and #11EEF4 for headings |
| 17 | +#> |
| 18 | + |
| 19 | +#*************** Intial Speech ****************** |
| 20 | + |
| 21 | +add-type -assemblyname system.speech |
| 22 | +$Speak = New-Object System.Speech.Synthesis.SpeechSynthesizer |
| 23 | +$speak.Speak("Windows Install completed on $env:computername. Now generating specsheet") |
| 24 | + |
| 25 | +#*************** Setting up Filename ****************** |
| 26 | + |
| 27 | +$Date = get-date |
| 28 | +$date = $date.ToLongDateString() |
| 29 | +$FileName = "Spec Report from $env:computername `($date`)" |
| 30 | + |
| 31 | +#*************** Getting WMI Objects ****************** |
| 32 | + |
| 33 | +$1 = Get-WmiObject Win32_ComputerSystem | Select-Object -property Manufacturer,Model,NumberOfProcessors,PCSystemType,SystemType,@{Label="RAMSizeInBytes"; Expression={ForEach-Object {$_.TotalPhysicalMemory}}},@{Label="RAMSizeinGB"; Expression={ForEach-Object {$_ = $_.TotalPhysicalMemory / 1gb; if (($_ -like "*.4*") -or ($_ -like "*.5*") -or ($_ -like "*.6*")) {$_} else {$_ = [math]::round($_); $_}}}} |
| 34 | +$2 = get-disk | Select-Object Manufacturer,Model,BusType,HealthStatus,@{Label="HDDSizeInBytes"; Expression={ForEach-Object {$_.size}}},@{Label="Size in Gigabytes"; Expression={ForEach-Object {$_ = $_.size / 1000000000; [math]::round($_)}}} |
| 35 | +$3 = get-wmiobject Cim_PCvideoController | Select-Object -Property name -Unique |
| 36 | +$4 = Get-WmiObject Win32_Processor | Select-Object Name,NumberOfCores,@{Label="Threads"; Expression={$_.NumberOfLogicalProcessors}},@{Label="Clock Speed in ghz"; Expression={ForEach-Object {$_.MaxClockSpeed / 1000}}} |
| 37 | +$5 = Get-WmiObject Win32_PhysicalMemory | Select-Object BankLabel,DeviceLocator,@{Label="Speed in Mhz"; Expression={$_.Speed}},@{Label="Capacity in Bytes"; Expression={ForEach-Object {$_.Capacity}}},@{Label="Capacity in GB"; Expression={ForEach-Object {$_ = $_.Capacity / 1000000000; [math]::Truncate($_)}}} |
| 38 | +$6 = Get-WmiObject Win32_ComputerSystemproduct | Select-Object -property IdentifyingNumber,SKUNumber,UUID |
| 39 | +$7 = Get-WmiObject cim_battery |
| 40 | + |
| 41 | +#*************** Adding Style Sheet and Header to HTML file ****************** |
| 42 | + |
| 43 | +"<!DOCTYPE html> |
| 44 | +`<html xmlns`=`"http://www.w3.org/1999/xhtml`" xmlns`:ms`=`"urn:schemas-microsoft-com:xslt`" xmlns`:bat`=`"http://schemas.microsoft.com/battery/2012`" xmlns:js=`"http://microsoft.com/kernel`"`>`<head`>`<meta http-equiv`=`"X-UA-Compatible`" content`=`"IE=edge`"`/`>`<meta name`=`"ReportUtcOffset`" content=`"+1:00`"`/`> |
| 45 | +`<title`>$FileName`<`/title`>`<style type`=`"text/css`"`> |
| 46 | +
|
| 47 | + body `{ |
| 48 | +
|
| 49 | + font`-family`: Segoe UI Light`; |
| 50 | +
|
| 51 | + letter`-spacing`: 0.02em`; |
| 52 | +
|
| 53 | + background`-color`: rgb`(35, 73, 116`)`; |
| 54 | +
|
| 55 | + color`: white`; |
| 56 | +
|
| 57 | + margin`-left`: 5.5em`; |
| 58 | +
|
| 59 | + line-height`: 1.7em`; |
| 60 | +
|
| 61 | + `} |
| 62 | +`<`/style`> `<body`>" > "$env:userprofile\desktop\$FileName.htm" |
| 63 | + |
| 64 | +#*************** Writing general overveiw info to HTML file ****************** |
| 65 | +$1 | convertto-html -as list -fragment -precontent "`<h1 style`=`"text-align:center`"`>Specifications` |
| 66 | +of $env:computername`</h1`>`<h3 style`=`"font-style:bold;Color:`#11EEF4`"`>General Overview`</h3`>`</p`>` |
| 67 | +`<h4>" -postcontent '</h4>' >>"$env:userprofile\desktop\$FileName.htm" |
| 68 | +"<h5>Note: If the second digit of the bytes number is 4 or 5,<br>double check the memory size, |
| 69 | +as the GB figure may<br>have been rounded incorrectly</h5>" >>"$env:userprofile\desktop\$FileName.htm" |
| 70 | + |
| 71 | +#*************** Writing disk info to HTML file ****************** |
| 72 | +$2 | convertto-html -as list -fragment -precontent '<p><h3 style="font-style:bold;Color:#11EEF4">Disk ` |
| 73 | +Information</h3></p><h4>' -postcontent '</h4>' >>"$env:userprofile\desktop\$FileName.htm" |
| 74 | + |
| 75 | +#*************** Writing Video controller info to HTML file ****************** |
| 76 | +$3 | convertto-html -as list -fragment -precontent '<p><h3 style="font-style:bold;Color:#11EEF4">Video |
| 77 | +Chipset Information</h3></p><h4>' -postcontent '</h4>' >>"$env:userprofile\desktop\$FileName.htm" |
| 78 | + |
| 79 | +#*************** Writing CPU info to HTML file ****************** |
| 80 | +$4 | convertto-html -as list -fragment -precontent '<p><h3 style="font-style:bold;Color:#11EEF4">CPU |
| 81 | +Information</h3></p><h4>' -postcontent '</h4>' >>"$env:userprofile\desktop\$FileName.htm" |
| 82 | + |
| 83 | +#*************** Writing Memory Configuration info to HTML file ****************** |
| 84 | +$5 | convertto-html -as list -fragment -precontent '<p><h3 style="font-style:bold;Color:#11EEF4">Memory |
| 85 | +Configuration</h3></p><h4>' -postcontent '</h4>' >>"$env:userprofile\desktop\$FileName.htm" |
| 86 | + |
| 87 | +#*************** Writing Unique IDs info to HTML file ****************** |
| 88 | +$6 | convertto-html -as list -fragment -precontent '<p><h3 style="font-style:bold;Color:#11EEF4">Unique |
| 89 | +Ids</h3></p><h4>' -postcontent '</h4>' >>"$env:userprofile\desktop\$FileName.htm" |
| 90 | + |
| 91 | +#*************** Testing whether the computer has a battery installed ****************** |
| 92 | +if ( $7 -ne $null ) { |
| 93 | + #**** Reducing the properties to the ones we want ****** |
| 94 | + $7 = $7 | Select-Object -property BatteryStatus,Caption,Chemistry,status |
| 95 | + |
| 96 | + #**** Invoking PowerCfg to get battery report ****** |
| 97 | + Powercfg /batteryreport /output "$env:userprofile\desktop\Battery Report from $env:computername.html" |
| 98 | + |
| 99 | + #**** Getting the content of the HTML file that created ****** |
| 100 | + $Battery = get-content "$env:userprofile\desktop\Battery Report from $env:computername.html" |
| 101 | + |
| 102 | + #**** Replaces some lines from the file for styling ***** |
| 103 | + $Battery[10] = 'background-color:rgb(35, 73, 116);' |
| 104 | + #$Battery[12] = 'color:rgb(25, 131, 158);' |
| 105 | + $Battery[25] = 'text-align:center;' |
| 106 | + $Battery[112] = 'background-color:rgb(35, 73, 116);' |
| 107 | + $Battery[114] = 'color:white;' |
| 108 | + |
| 109 | + #*****Writing Battery info to HTML file ****** |
| 110 | + $7 | convertto-html -as list -Fragment -precontent '<p><h3 style="font-style:bold;Color:#11EEF4">Battery Info</h3></p><h4>' -postcontent '</h4>' >>"$env:userprofile\desktop\$FileName.htm" |
| 111 | + |
| 112 | +} else {$battery = '<p> <h4>No battery Present </h4></p>' } |
| 113 | + |
| 114 | +#*************** Finishing the html file ****************** |
| 115 | +$Battery >> "$env:userprofile\desktop\$FileName.htm" |
| 116 | +'</body> </html>' >> "$env:userprofile\desktop\$FileName.htm" |
| 117 | + |
| 118 | +#*************** Setting the vars up for speech ****************** |
| 119 | +$Manufacturer = $1.Manufacturer |
| 120 | +$Model = $1.Model |
| 121 | +$CPU = $4 | Select-Object -ExpandProperty name |
| 122 | +$RAM = $1.RAMSizeinGB |
| 123 | +if ($CPU -like "*i3*") {$CPU = "an i3"} |
| 124 | +if ($CPU -like "*i5*") {$CPU = "an i5"; $value = "I'm worth quite a lot of money aren't I?"} |
| 125 | +if ($CPU -like "*i7*") {$CPU = "an i7"; $value = "I'm worth lots and lots of money!" } |
| 126 | +if ($CPU -like "*Pentium*") {$CPU = "a Pentium"} |
| 127 | +if ($CPU -like "*Celeron*") {$CPU = "a Celeron"} |
| 128 | +if ($CPU -like "*xeon*") {$CPU = "a Xeon"; $value = "I'm a Workstation but I'd like to be a server."} |
| 129 | +if ($CPU -like "*Intel*") {$CPU = "an Intel"} |
| 130 | +if ($CPU -like "*AMD*") {$CPU = "an AMD"} |
| 131 | + |
| 132 | +#****************** Second Speech **************** |
| 133 | +$speak.Speak("I, a $Manufacturer $Model have successfully generated a spec sheet. By the way, I have $CPU CPU and $RAM gigabytes of RAM. $value") |
| 134 | + |
| 135 | +# Could use to copy to server never worked |
| 136 | +#****************** Tries to copy to server **************** |
| 137 | +#copy-item "$env:userprofile\desktop\$FileName.htm" "\\WDS-Server\specs\$FileName.htm" |
0 commit comments