PowerShell: Skriptide käivitamine Task Scheduleriga

From ICO wiki
Revision as of 18:57, 22 April 2012 by Roparn (talk | contribs)
Jump to navigationJump to search
<#
 
.SYNOPSIS
 Skript kirjutab .txt faili, kuhu salvestatakse ketaste nimed ja vaba ruum. Selle faili sisu kirjutatakse omakorda suurema faili algusse.
 
.DESCRIPTION
  Parameetrid puuduvad
 
.Example
  C:\PS> .\skript.ps1
 
.NOTES
  Autor: Robert Pärn
  Versioon: 0.1
  Muutmise kuup2ev 22.04.2012
 
.LINK
  https://wiki.itcollege.ee/index.php/PowerShell:_Skriptide_käivitamine_Task_Scheduleriga
 
 
#>
$location=Split-Path -parent $MyInvocation.MyCommand.Definition
Get-WmiObject win32_logicaldisk| select-object volumename, deviceid, {$_.freespace/1gb} |format-table -autosize|out-file $location\currentspace.txt
new-item $location\disklog -type directory -force|out-null
new-item $location\disklog\buffer.txt -type file|out-null
copy-item $location\disklog\freespace.txt $location\disklog\buffer.txt -ea 0
$aeg=get-date
echo $aeg|out-file $location\disklog\freespace.txt
get-content $location\currentspace.txt|out-file $location\disklog\freespace.txt -append
get-content $location\disklog\buffer.txt|out-file $location\disklog\freespace.txt -append
remove-item $location\disklog\buffer.txt
echo "Kõikide ketaste vaba ruum on kirjutatud faili $location\disklog\freespace.txt"