Skip to content

Commit

Permalink
+ Added logging to file
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartenbach committed Jun 7, 2016
1 parent f86a3bd commit 2bfa529
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Get-PC-Information.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function Main {
}

Display-Result
Output-To-File

Write-Host "Press any key to exit..." -ForegroundColor "Green"
$Pause = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Expand Down Expand Up @@ -143,4 +144,37 @@ function Display-Result {
Write-Host ""
}

function Output-To-File {
$file = "$HOME\AppData\Local\Temp\PC-Information.log"

if (!(Test-Path $file)) {
New-Item -Path $file -Type File -Force
}
"----------------------------------------------------------" >> $file
"Computer" >> $file
" System Name " + $system >> $file
" Manufacturer " + $manufacturer >> $file
" Model " + $model >> $file
" Serial Number " + $serialnumber >> $file
" BIOS Version " + $biosversion >> $file
"" >> $file
"Specifications" >> $file
" CPU " + $processor >> $file
" Total RAM " + $memoryString >> $file
" Operating System " + $osname >> $file
" Uptime " + (Get-Uptime) >> $file
"" >> $file
"Printers" >> $file
" $printers" >> $file
"" >> $file
"User" >> $file
" Domain\Username " + $username >> $file
"" >> $file
"Network" >> $file
" IP " + $ip.ipaddress[0] >> $file
#" Mac " $macaddress >> $file
"---------------------------------------------------------" >> $file
"" >> $file
}

Main

0 comments on commit 2bfa529

Please sign in to comment.