PowerShell: Skriptide käivitamine Task Scheduleriga: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Roparn (talk | contribs)
No edit summary
Roparn (talk | contribs)
No edit summary
Line 1: Line 1:
<Source lang="powershell">
<#
.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
$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
Get-WmiObject win32_logicaldisk| select-object volumename, deviceid, {$_.freespace/1gb} |format-table -autosize|out-file $location\currentspace.txt
Line 10: Line 32:
remove-item $location\disklog\buffer.txt
remove-item $location\disklog\buffer.txt
echo "Kõikide ketaste vaba ruum on kirjutatud faili $location\disklog\freespace.txt"
echo "Kõikide ketaste vaba ruum on kirjutatud faili $location\disklog\freespace.txt"
</source>

Revision as of 18:57, 22 April 2012

<#
 
.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"