PowerShell: Arvuti info kuvamine

From ICO wiki
Revision as of 22:10, 4 November 2012 by Dkeler (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
 
.DESCRIPTION
    Valida numbrit, mis vastab vajaliku informatsioonile, ning skript kuvab infot uues aknas
 
.NOTES
    Autor: Dmitri Keler
    Versioon: 1 
    Muutmise kuup2ev: 30.05.2012
 
.LINK
    https://wiki.itcollege.ee/index.php?title=PowerShell:_Arvuti_info_kuvamine 


#Skripti ülesanne seletamine
Write-Host " " 
Write-Host "See skript valjastab ekraanile arvuti informatsiooni" -BackgroundColor green -ForegroundColor red
Write-Host " " 
 
# Valikud
Write-Host "Info valimine" -BackgroundColor yellow
Write-Host "1. CPU" -BackgroundColor yellow
Write-Host "2. GPU" -BackgroundColor yellow
Write-Host "3. BIOS" -BackgroundColor yellow
Write-Host "4. HDD" -BackgroundColor yellow
Write-Host "5. Memory" -BackgroundColor yellow
Write-Host "6. Uptime" -BackgroundColor yellow
Write-Host "7. OS" -BackgroundColor yellow
Write-Host " "
$a = Read-Host "Valige 1-7: "
 
Write-Host " "
 
switch ($a) 
    { 
        1 {
           "CPU Information";
           get-wmiobject win32_processor | Select Name, CurrentClockSpeed, L2CacheSize, L3CacheSize, NumberOfCores, NumberOfLogicalProcessors | Out-GridView
           break;
          } 
        2 {
           "GPU Information";
           get-wmiobject win32_VideoController | Select Name, VideoModeDescription, DriverVersion | Out-GridView
           break;
          } 
        3 {
           "BIOS Information";
           get-wmiobject Win32_Bios | Out-GridView
           break;
          } 
        4 {
           "HDD Information";
           get-wmiobject Win32_LogicalDisk | Select SystemName, DeviceID, VolumeName, @{Name=size(GB);Expression={{0:N1} -f($_.size/1gb)}},@{Name=freespace(GB);Expression={{0:N1} -f($_.freespace/1gb)}} | Out-GridView
           break;
          } 
        5 {
           "Memory Information";
           get-wmiobject Win32_PhysicalMemory | Select DeviceLocator, DataWidth, @{Name=size(MB);Expression={{0:N1} -f($_.Capacity/1mb)}} | Out-GridView
           break;
         }
        6 {
           "Uptime";
           Write-Host Susteemi uptime on ((Get-Date)  ([WMI]“”).ConverttoDateTime((Get-WmiObject -Class Win32_OperatingSystem).LastBootUpTime)).Days Days ((Get-Date)  ([WMI]“”).ConverttoDateTime((Get-WmiObject -Class Win32_OperatingSystem).LastBootUpTime)).Hours Hrs ((Get-Date)  ([WMI]“”).ConverttoDateTime((Get-WmiObject -Class Win32_OperatingSystem).LastBootUpTime)).minutes Min
           break;
         }
        7 {
           "OS Information";
           Get-WmiObject Win32_OperatingSystem | Select Name, OSArchitecture, CSName | Out-GridView
           break;
        }
        default {
          "Valige 6iget numbrit";
          break;
          }
    }