PowerShell: Kaido Loonurm, PCinfo.ps1: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Kloonurm (talk | contribs)
Created page with '#Skript väljastab infot arvuti seadmete ja konfiguratsiooni kohta #Autor: Kaido Loonurm #Versioon: 0.3 $Aeg = get-Date -Format "yyyy-MM-dd HH:mm" #Näitame kes skripti käivitas…'
 
Kloonurm (talk | contribs)
No edit summary
Line 1: Line 1:
==Kirjeldus==
==Skript==
<source lang="powershell">
#Skript väljastab infot arvuti seadmete ja konfiguratsiooni kohta
#Skript väljastab infot arvuti seadmete ja konfiguratsiooni kohta
#Autor: Kaido Loonurm
#Autor: Kaido Loonurm
Line 103: Line 107:
Write-Host
Write-Host
}
}
</source>

Revision as of 15:36, 15 May 2011

Kirjeldus

Skript

#Skript väljastab infot arvuti seadmete ja konfiguratsiooni kohta
#Autor: Kaido Loonurm
#Versioon: 0.3
$Aeg = get-Date -Format "yyyy-MM-dd HH:mm"
#Näitame kes skripti käivitas ja mis ajal
Write-Host "Skript käivitati kaustaja:" $env:USERNAME "poolt," $Aeg 
Write-host
#Muudame pealkirja kõigile loetavaks olenematta mis on käivitaja shelli värvilahendus
Write-Host "PC andmed: " -BackgroundColor Green -ForegroundColor Black
#Loeme Win32_ComputerSystem klassi andmed muutujasse
$PCinfo = Get-WmiObject -Class Win32_ComputerSystem 
#Käime muutuja andmed läbi ja prindime kästud andmed
foreach ($ArvutiInf in $PCinfo){
	Write-Host "Arvuti tootja: " $ArvutiInf.Manufacturer
	Write-Host "Arvuti mudel: " $ArvutiInf.Model
	Write-Host "Arvuti nimi: " $ArvutiInf.Name
	Write-Host "Arvuti süsteemi tüüp: " $ArvutiInf.SystemType
	Write-Host "Omanik: " $ArvutiInf.PrimaryOwnerName
	#konverteerime suuruse loetavale kujule, hetkel MB-ks
	$mem = [math]::truncate($ArvutiInf.TotalPhysicalMemory/1MB)
	Write-Host "Kogu füüsilise mälu hulk: " $mem "MB"
	Write-Host
}
#Kirjutame separaatori et oleks arusaadavam kus algab uus lõik
Write-Host "***********************************************"
#Loeme seekord Win32_ComputerSystem klassist vaid etteantud andmed muutujasse
$OPinfo = Get-WmiObject Win32_OperatingSystem | select LastBootUpTime,Name,NumberOfUsers,OSArchitecture,SerialNumber,WindowsDirectory,InstallDate
Write-Host "OS andmed: " -BackgroundColor Green -ForegroundColor Black
#Jällegi käime muutuja andmed läbi ja prindime järgnevalt täpsustatud andmed 
foreach ($ArvutiInf in $OPinfo){
	Write-Host "  OPsüsteem: " $ArvutiInf.Name
	Write-Host "  OPsüsteemi arhidektuur: " $ArvutiInf.OSArchitecture
	Write-Host "  Windowsi kaust: " $ArvutiInf.WindowsDirectory
	Write-Host "  Windows seerianumber: " $ArvutiInf.SerialNumber
	Write-Host "  Kasutajate arv: " $ArvutiInf.NumberOfUsers
	#konverteerime kuupäeva loetavale kujule
	$Installed = [System.Management.ManagementDateTimeConverter]::ToDateTime($ArvutiInf.InstallDate)
	Write-Host "  Installitud: " $Installed
	#konverteerime kuupäeva loetavale kujule
	$bootup = [System.Management.ManagementDateTimeConverter]::ToDateTime($ArvutiInf.LastBootUpTime)
	Write-Host "  Viimati käivitatud: " $bootup 
	Write-Host
}
Write-Host "***********************************************"
$CPUinfo = Get-WmiObject -Class CIM_Processor
Write-Host "CPU andmed: " -BackgroundColor Green -ForegroundColor Black
foreach ($CPUandmed in $CPUinfo ){
	Write-Host "  CPU nimi: " $CPUandmed.Name
	Write-Host "  CPU hetke kiirus: " $CPUandmed.CurrentClockSpeed "Mhz"
	Write-Host "  CPU max kiirus: " $CPUandmed.MaxClockSpeed "Mhz"
	Write-Host "  CPU tuumade arv: " $CPUandmed.NumberOfCores
	Write-Host "  CPU kirjeldus: " $CPUandmed.Description
	Write-Host
}

Write-Host "***********************************************"
Write-Host "HDD andmed: " -BackgroundColor Green -ForegroundColor Black
$HDDinfo = Get-WmiObject Win32_DiskDrive
foreach($HDDandmed in $HDDinfo) {
	Write-Host "  Ketta nimi:" $HDDandmed.DeviceID
	#konverteerime suuruse loetavale kujule, hetkel GB-ks
	$hdd = [math]::truncate($HDDandmed.Size/1GB)
	Write-Host "  Suurus:" $hdd GB
	Write-Host "  Ühenduse tüüp:" $HDDandmed.InterfaceType
	Write-Host "  Ketta tüüp: " $HDDandmed.MediaType
	Write-Host
}
Write-Host "***********************************************"
Write-Host "Graafikakaardi andmed: " -BackgroundColor Green -ForegroundColor Black
$Graphinfo = Get-WmiObject CIM_VideoController
foreach ( $GraphAndmed in $Graphinfo ){
	Write-Host "  Adaprti nimetus: " $GraphAndmed.Name
	Write-Host "  Adaprti kirjeldus: " $GraphAndmed.Description
	Write-Host "  Hetkel kasutusel olev resolutsioon: " $GraphAndmed.CurrentHorizontalResolution "x" $GraphAndmed.CurrentVerticalResolution
	Write-Host "  Refresh rate: " $GraphAndmed.CurrentRefreshRate "Hz"
	#konverteerime suuruse loetavale kujule, hetkel MB-ks
	$gram = [math]::truncate($GraphAndmed.AdapterRAM/1MB)
	Write-Host "  Kasutada olev mälu hulk: " $gram "MB"
	Write-Host
}
Write-Host "***********************************************"
Write-Host "Mälu andmed: " -BackgroundColor Green -ForegroundColor Black
$Meminfo = Get-WmiObject -Class CIM_PhysicalMemory 
foreach ($MemAndmed in $Meminfo){
	Write-Host "  Nimi: " $MemAndmed.Name
	Write-Host "  Kirjeldus: " $MemAndmed.Description
	Write-Host "  Mälupesa: " $MemAndmed.DeviceLocator
	#konverteerime suuruse loetavale kujule, hetkel MB-ks
	$mram = [math]::truncate($MemAndmed.Capacity/1MB)
	Write-Host "  Suurus: " $mram "MB"
	Write-Host "  Kiirus: " $MemAndmed.Speed
	Write-Host
}
Write-Host "***********************************************"
Write-Host "Võrgu andmed: " -BackgroundColor Green -ForegroundColor Black
$NetworkInfo = Get-WmiObject Win32_NetworkAdapterConfiguration | where{$_.IPEnabled -eq True}
foreach($NetworkAndmed in $NetworkInfo) {
	Write-Host "  Võrgu adaptri nimi:" $NetworkAndmed.Description
	Write-Host "  DHCP Enabled:" $NetworkAndmed.DHCPEnabled
	Write-Host "  IP Aadress:" $NetworkAndmed.IPAddress
	Write-Host "  Subnet Mask:" $NetworkAndmed.IPSubnet
	Write-Host "  Gateway:" $NetworkAndmed.DefaultIPGateway
	Write-Host
}