PowerShell SystemInfo +



### CLEAR SCREEN
Clear-Host

### TITLE
$Host.UI.RawUI.WindowTitle = "SystemInfo+ v 21.07 - Developed by RoboticScript (roboticscript.com)"
$Host.UI.RawUI.BackgroundColor = "Black"
#$Host.UI.RawUI.ForegroundColor = "White"
Clear-Host
$winsize = $Host.UI.RawUI.WindowSize 
$winsize.Width = 120
$winsize.Height = 40
$Host.UI.RawUI.WindowSize = $winsize

$buffer = $Host.UI.RawUI.BufferSize
$buffer.width = 120
$buffer.height = 2000
$host.UI.RawUI.Set_BufferSize($buffer)

$position = $host.UI.RawUI.WindowPosition
$position.X = 0
$position.Y = 0
$host.UI.RawUI.Windowposition = $position


### DATE AND TIME VARIABLES

# $date1 = Get-Date -UFormat "%d-%m-%Y"
# $date2 = Get-Date -UFormat "%d-%m-%Y_%H"
# $date3 = Get-Date -UFormat "Date: %d-%m-%Y, Time: %H-%M-%S"
$date4 = Get-Date -UFormat "Date: %d-%m-%Y, Time: %H-%M-%S IST"

### LOG FILE NAME AND PATH
$hostname002 = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object Name | ForEach-Object{$_.Name}
$date_log_transcript = Get-Date -UFormat $hostname002"_%d-%m-%Y_%H-%M-%S"
$log_location1 = $date_log_transcript+".txt"

$date_log_transcript2 = Get-Date -UFormat $hostname002"_%d-%m-%Y_%H-%M-%S"
$log_location2 = $date_log_transcript2+".html"

### MENU DISPLAY ON SCREEN
function menu_display_on_screen {

    Write-Host "+---------------------------------------------------------------------------------------------------------------------+" -ForegroundColor DarkGray -BackgroundColor DarkGray
    Write-Host "                             || S Y S T E M    I N F O R M A T I O N   -   R E P O R T S ||                            " -ForegroundColor DarkBlue -BackgroundColor DarkGray
    Write-Host "+---------------------------------------------------------------------------------------------------------------------+" -ForegroundColor DarkGray -BackgroundColor DarkGray
    Write-Host "                                     Developed by RoboticScript (roboticscript.com)                                    " -ForegroundColor DarkRed -BackgroundColor Gray
    Write-Host "                                                                                                                       " -ForegroundColor Cyan
    Write-Host "> > >  TABLE OF CONTENTS                                                                                               " -ForegroundColor Green
    Write-Host ""
    Write-Host "| 01 - VIEW BASIC INFORMATION ABOUT SYSTEM                                                                             "
    Write-Host "| 02 - GET BASIC HARDWARE DETAILS                                                                                      "
    Write-Host "| 03 - GET PROCESSOR DETAILS                                                                                           "
    Write-Host "| 04 - GET RAM DETAILS                                                                                                 "
    Write-Host "| 05 - GET DISK SPACE DETAILS                                                                                          "
    Write-Host "| 06 - GET USER DETAILS                                                                                                "
    Write-Host ""
    Write-Host "+---------------------------------------------------------------------------------------------------------------------+" -ForegroundColor DarkGray -BackgroundColor DarkGray
}

### MENU - WRITE ON FILE
function menu_write_on_file { 
    ## HEADER (WRITE TO FILE) | (= count is 72)
    "" | Out-File $log_location1 -Append
    "<span style=background-color:powderblue>========================================================================</span>" | Out-File $log_location1 -Append
    "<span style=background-color:powderblue>| | | | |             SYSTEM INFORMATION - REPORTS               | | | |</span>" | Out-File $log_location1 -Append
    "<span style=background-color:powderblue>========================================================================</span>" | Out-File $log_location1 -Append
    "<span style=background-color:powderblue>|           Developed by RoboticScript (roboticscript.com)             |</span>" | Out-File $log_location1 -Append
    "<span style=background-color:powderblue>========================================================================</span>" | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append
    ">> START TIME: " | Out-File $log_location1 -Append -NoNewline
    $date4 | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append 
    "+----------------------------------------------------------------------+" | Out-File $log_location1 -Append
    "|                         TABLE OF CONTENTS                            |" | Out-File $log_location1 -Append
    "+----------------------------------------------------------------------+" | Out-File $log_location1 -Append
    "| 01 - VIEW BASIC INFORMATION ABOUT SYSTEM                             |" | Out-File $log_location1 -Append
    "| 02 - GET BASIC HARDWARE DETAILS                                      |" | Out-File $log_location1 -Append
    "| 03 - GET PROCESSOR DETAILS                                           |" | Out-File $log_location1 -Append
    "| 04 - GET RAM DETAILS                                                 |" | Out-File $log_location1 -Append
    "| 05 - GET DISK SPACE DETAILS                                          |" | Out-File $log_location1 -Append
    "| 06 - GET USER DETAILS                                                |" | Out-File $log_location1 -Append
    "+----------------------------------------------------------------------+" | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append
}

### 01 - VIEW BASIC INFORMATION ABOUT SYSTEM
function basic_information {

    ### CMDLET
    # Windows edition, Version, Build, and Windows Install Date
    $windows_editions1 = Get-CimInstance Win32_OperatingSystem | Select-Object Caption | ForEach-Object{$_.Caption}
    $version1 = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId
    # (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").ReleaseId
    $build1 = Get-CimInstance Win32_OperatingSystem | Select-Object BuildNumber | ForEach-Object{$_.BuildNumber}
    $windows_install1 = Get-CimInstance Win32_OperatingSystem | Select-Object InstallDate | ForEach-Object{$_.InstallDate}
    $windows_install1 = ($windows_install1).ToString()
    # Processor:
    $processor1 = Get-CimInstance -ClassName Win32_Processor | Select-Object Name | ForEach-Object{$_.Name}
    # Installed memory (RAM):
    $ram1 = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb
    # Hard disk:
    $hard_disk1 = (Get-PhysicalDisk | Select-Object @{n="Size";e={[math]::Round($_.Size/1GB,2)}}).Size
    # System type:
    $system_type1 = Get-CimInstance Win32_OperatingSystem | Select-Object OSArchitecture | ForEach-Object{$_.OSArchitecture}
    $system_type2 = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object SystemType | ForEach-Object{$_.SystemType}
    # Computer name:
    $computer_name1 = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object Name | ForEach-Object{$_.Name}
    # Domain:
    $domain1 = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object Domain | ForEach-Object{$_.Domain}
    # Login user:
    $login_user1 = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object UserName | ForEach-Object{$_.UserName}
    # Serial Number
    $serial_number1 = Get-CimInstance -ClassName Win32_BIOS | Select-Object SerialNumber | ForEach-Object{$_.SerialNumber}
    # Windows Last Boot Time:
    $last_boot1 = Get-CimInstance Win32_OperatingSystem | Select-Object LastBootUpTime | ForEach-Object{$_.LastBootUpTime}
    $last_boot1= ($last_boot1).ToString()

    ### WRITE TO FILE

    "<p><span>| VIEW BASIC INFORMATION ABOUT SYSTEM                                  |</span></p>" | Out-File $log_location1 -Append

    # Windows edition, Version, Windows Install Date
    "<span style=background-color:LightGrey> Windows edition         :  $windows_editions1 </span>" | Out-File $log_location1 -Append
    "<span style=background-color:LightGrey> Version                 :  $version1, (Build: $build1) </span>" | Out-File $log_location1 -Append
    "<span style=background-color:LightGrey> Windows Install Date    :  $windows_install1 </span>" | Out-File $log_location1 -Append
    # Processor:
    "" | Out-File $log_location1 -Append
    "<span style=background-color:LightGrey> Processor               :  $processor1 </span>" | Out-File $log_location1 -Append 
    # Installed memory (RAM):
    "<span style=background-color:LightGrey> Installed memory (RAM)  :  $ram1 GB </span>" | Out-File $log_location1 -Append
    # Hard disk:
    "<span style=background-color:LightGrey> Hard disk               :  $hard_disk1 GB </span>" | Out-File $log_location1 -Append
    # System type:
    "<span style=background-color:LightGrey> System type             :  $system_type1 Operating System, $system_type2 </span>" | Out-File $log_location1 -Append
    # Computer name:
    "" | Out-File $log_location1 -Append
    "<span style=background-color:LightGrey> Computer name           :  $computer_name1 </span>" | Out-File $log_location1 -Append
    # Domain:
    "<span style=background-color:LightGrey> Domain                  :  $domain1 </span>" | Out-File $log_location1 -Append
    # Login user:
    "<span style=background-color:LightGrey> Login user              :  $login_user1 </span>" | Out-File $log_location1 -Append
    # Serial Number
    "" | Out-File $log_location1 -Append
    "<span style=background-color:LightGrey> Serial Number           :  $serial_number1 </span>" | Out-File $log_location1 -Append
    # Windows Last Boot Time:
    "" | Out-File $log_location1 -Append
    "<span style=background-color:LightGrey> Windows Last Boot Time  :  $last_boot1 </span>" | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append
}

### 02 - GET BASIC HARDWARE DETAILS
function get_basic_hardware_details {
    
    "<p><span>| GET BASIC HARDWARE DETAILS                                           |</span></p>" | Out-File $log_location1 -Append
    "Manufacturer       :  " | Out-File $log_location1 -Append -NoNewline
    Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object Manufacturer | ForEach-Object{$_.Manufacturer} | Out-File $log_location1 -Append
    "Model              :  " | Out-File $log_location1 -Append -NoNewline
    Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object Model | ForEach-Object{$_.Model} | Out-File $log_location1 -Append
    "Serial Number      :  " | Out-File $log_location1 -Append -NoNewline
    Get-CimInstance -ClassName Win32_BIOS | Select-Object SerialNumber | ForEach-Object{$_.SerialNumber} | Out-File $log_location1 -Append
    #"BIOS Date         :  "
    #Get-CimInstance -ClassName Win32_BIOS | Select-Object Name | ForEach-Object{$_.Name} | Out-File $log_location1 -Append
    "Release Date       :  " | Out-File $log_location1 -Append -NoNewline
    #Get-CimInstance -ClassName Win32_BIOS | Select-Object ReleaseDate | ForEach-Object{$_.ReleaseDate} | Out-File $log_location1 -Append
    (Get-CimInstance -ClassName Win32_BIOS | Select-Object ReleaseDate | ForEach-Object{$_.ReleaseDate}).ToString() | Out-File $log_location1 -Append
    "BIOS Version       :  " | Out-File $log_location1 -Append -NoNewline
    Get-CimInstance -ClassName Win32_BIOS | Select-Object SMBIOSBIOSVersion | ForEach-Object{$_.SMBIOSBIOSVersion} | Out-File $log_location1 -Append
    

    "" | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append
    ### CMDLET
    <#
    Get-PnpDevice -Class Media | Where-Object {$_.Status -eq "OK"} | Select-Object @{Name="Audio Driver  "; Expression={$_.FriendlyName}} | Out-File $log_location1 -Append
    Get-PnpDevice -Class AudioEndpoint | Where-Object {$_.Status -eq "OK"} | Select-Object @{Name="Audio Driver  "; Expression={$_.FriendlyName}} | Out-File $log_location1 -Append
    Get-PnpDevice -Class Camera | Where-Object {$_.Status -eq "OK"} | Select-Object @{Name="Camera  "; Expression={$_.FriendlyName}} | Out-File $log_location1 -Append
    Get-PnpDevice -Class Monitor | Where-Object {$_.Status -eq "OK"} | Select-Object @{Name="Monitor  "; Expression={$_.FriendlyName}} | Out-File $log_location1 -Append
    Get-PnpDevice -Class Display | Where-Object {$_.Status -eq "OK"} | Select-Object @{Name="Display  "; Expression={$_.FriendlyName}} | Out-File $log_location1 -Append
    Get-CimInstance Win32_VideoController | Select-Object CurrentHorizontalResolution, CurrentVerticalResolution | Out-File $log_location1 -Append
    Get-PnpDevice -Class Bluetooth | Where-Object {$_.Status -eq "OK"} | Select-Object @{Name="Bluetooth  "; Expression={$_.FriendlyName}} | Out-File $log_location1 -Append
    Get-PnpDevice -Class Mouse | Where-Object {$_.Status -eq "OK"} | Select-Object @{Name="Mouse "; Expression={$_.FriendlyName}} | Out-File $log_location1 -Append
    Get-PnpDevice -Class Net | Where-Object {$_.Status -eq "OK"} | Select-Object @{Name="Network "; Expression={$_.FriendlyName}} | Out-File $log_location1 -Append
    #>

    "<mark> Sound Cards </mark>" | Out-File $log_location1 -Append
    (Get-PnpDevice -Class Media | Where-Object {$_.Status -eq "OK"}).FriendlyName | Out-File $log_location1 -Append
    "<mark> Playback & Recording Device </mark>" | Out-File $log_location1 -Append
    (Get-PnpDevice -Class AudioEndpoint | Where-Object {$_.Status -eq "OK"}).FriendlyName | Out-File $log_location1 -Append
    "<mark> Camera </mark>" | Out-File $log_location1 -Append
    (Get-PnpDevice -Class Camera | Where-Object {$_.Status -eq "OK"}).FriendlyName | Out-File $log_location1 -Append
    "<mark> Monitor </mark>" | Out-File $log_location1 -Append
    (Get-PnpDevice -Class Monitor | Where-Object {$_.Status -eq "OK"}).FriendlyName | Out-File $log_location1 -Append
    "<mark> Graphics </mark>" | Out-File $log_location1 -Append
    (Get-PnpDevice -Class Display | Where-Object {$_.Status -eq "OK"}).FriendlyName | Out-File $log_location1 -Append
    "<mark> Display (Resolution) </mark>" | Out-File $log_location1 -Append
    $CurrentHorizontalResolution = (Get-CimInstance Win32_VideoController).CurrentHorizontalResolution
    $CurrentVerticalResolution = (Get-CimInstance Win32_VideoController).CurrentVerticalResolution
    "$CurrentHorizontalResolution x $CurrentVerticalResolution" | Out-File $log_location1 -Append
    "<mark> Bluetooth </mark>" | Out-File $log_location1 -Append
    (Get-PnpDevice -Class Bluetooth | Where-Object {$_.Status -eq "OK"}).FriendlyName | Out-File $log_location1 -Append
    "<mark> Mouse </mark>" | Out-File $log_location1 -Append
    (Get-PnpDevice -Class Mouse | Where-Object {$_.Status -eq "OK"}).FriendlyName | Out-File $log_location1 -Append
    "<mark> Network </mark>" | Out-File $log_location1 -Append
    (Get-PnpDevice -Class Net | Where-Object {$_.Status -eq "OK"}).FriendlyName | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append
    
}

### 03 - GET PROCESSOR DETAILS
function get_processor_details {
    "<p><span>| GET PROCESSOR DETAILS                                                |</span></p>" | Out-File $log_location1 -Append
    Get-CimInstance -ClassName Win32_Processor | Select-Object Status,Manufacturer,Name,NumberOfCores,NumberOfLogicalProcessors,ThreadCount,Caption,SocketDesignation | Format-List | Out-File $log_location1 -Append
}

### 04 - GET RAM DETAILS
function get_ram_details {
    "<p><span>| GET RAM DETAILS                                                      |</span></p>" | Out-File $log_location1 -Append
    $ram1 = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb
    "Total RAM: $ram1 GB" | Out-File $log_location1 -Append


    # Get-CimInstance win32_physicalmemory | Format-Table Manufacturer,Banklabel,Configuredclockspeed,Devicelocator,Capacity,Serialnumber -AutoSize
    Get-CimInstance win32_physicalmemory | Select-Object Manufacturer,Banklabel,Configuredclockspeed,Devicelocator,@{Name="Capacity, GB";Expression={$_.Capacity / 1GB}},Serialnumber | Format-Table -AutoSize | Out-File $log_location1 -Append
}

### 05 - GET DISK SPACE
function get_disk_space {
    "" | Out-File $log_location1 -Append
    "<p><span>| GET DISK SPACE                                                       |</span></p>" | Out-File $log_location1 -Append

    Get-PhysicalDisk  | Format-Table -AutoSize | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append
    Get-Disk | Format-Table -AutoSize | Out-File $log_location1 -Append

    ## 00 - GET VOLUME
    "<p><span>| --- GET VOLUME                                                       |</span></p>" | Out-File $log_location1 -Append

    Get-Volume | Sort-Object DriveLetter | Format-Table -AutoSize | Out-File $log_location1 -Append

}

## 06 - GET USER DETAILS
function get_user_details {
    "<p><span>| GET USER DETAILS                                                     |</span></p>" | Out-File $log_location1 -Append

    Get-LocalUser | Select-Object Name,Enabled,LastLogon,Description | Out-File $log_location1 -Append

}

### END - WRITE ON FILE
function end_write_on_file {
    "" | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append
    $date5 = Get-Date -UFormat "Date: %d-%m-%Y, Time: %H-%M-%S IST"
    ">> END TIME: " | Out-File $log_location1 -Append -NoNewline
    $date5 | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append
    "<span style=background-color:powderblue>========================================================================</span>" | Out-File $log_location1 -Append
    "<span style=background-color:powderblue>| | | | |                        E  N  D                       | | | | |</span>" | Out-File $log_location1 -Append
    "<span style=background-color:powderblue>========================================================================</span>" | Out-File $log_location1 -Append
    "" | Out-File $log_location1 -Append
}

### CONVERT TXT 2 HTML
function convert_txt_2_html {
$content = Get-Content $log_location1 -Raw
$title = 'RoboticScript (roboticscript.com)'
$html = @"
<html>
    <head>
    <title>$title</title>
    <style>
    span {
    background-color: GreenYellow;
    }
    mark { 
    background-color: LightGray;
    color: black;
    }
    </style>
    
    </head>
<body>
    <pre>$content</pre>
</body>
</html>
"@
$html | Out-File $log_location2
}


menu_display_on_screen
menu_write_on_file
Write-Host ""
Write-Host "01 - COLLECTING BASIC INFORMATION ABOUT SYSTEM . . . " -ForegroundColor DarkGreen
basic_information
Write-Host "02 - COLLECTING BASIC HARDWARE DETAILS . . . " -ForegroundColor DarkGreen
get_basic_hardware_details
Write-Host "03 - COLLECTING PROCESSOR DETAILS . . . " -ForegroundColor DarkGreen
get_processor_details
Write-Host "04 - COLLECTING RAM DETAILS . . . " -ForegroundColor DarkGreen
get_ram_details
Write-Host "05 - COLLECTING DISK SPACE DETAILS . . . " -ForegroundColor DarkGreen
get_disk_space
Write-Host "06 - COLLECTING USER DETAILS . . . " -ForegroundColor DarkGreen
get_user_details

end_write_on_file

convert_txt_2_html

### REMOVE TXT LOG FILE 
Remove-Item .\$log_location1

### END OF DISPLAY SCREEN
Write-Host ""
Write-Host "SYSTEM DATA COLLECTED SUCCESSFULLY ! ! !" -BackgroundColor Green -ForegroundColor Black
Write-Host ""


Write-Host "Result will display in Browser  |  Console will close in 5 sec . . . " -ForegroundColor Green

Invoke-Item ".\$log_location2"

Start-Sleep -Seconds 5

### END


Previous Post Next Post