<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.itcollege.ee/index.php?action=history&amp;feed=atom&amp;title=PowerShell%3A_SQLi_baasi_kirjutamise_skript</id>
	<title>PowerShell: SQLi baasi kirjutamise skript - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.itcollege.ee/index.php?action=history&amp;feed=atom&amp;title=PowerShell%3A_SQLi_baasi_kirjutamise_skript"/>
	<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=PowerShell:_SQLi_baasi_kirjutamise_skript&amp;action=history"/>
	<updated>2026-05-07T08:18:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=PowerShell:_SQLi_baasi_kirjutamise_skript&amp;diff=45830&amp;oldid=prev</id>
		<title>Taliiv at 21:23, 1 February 2012</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=PowerShell:_SQLi_baasi_kirjutamise_skript&amp;diff=45830&amp;oldid=prev"/>
		<updated>2012-02-01T21:23:18Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:23, 2 February 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l14&quot;&gt;Line 14:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	.NOTES&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	.NOTES&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Autor: &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;TambetLiiv &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Autor: &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Tambet Liiv &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Versioon: 0.1  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Versioon: 0.1  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Muutmise kuup2ev: 02.02.2012&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Muutmise kuup2ev: 02.02.2012&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Taliiv</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=PowerShell:_SQLi_baasi_kirjutamise_skript&amp;diff=45829&amp;oldid=prev</id>
		<title>Taliiv at 21:22, 1 February 2012</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=PowerShell:_SQLi_baasi_kirjutamise_skript&amp;diff=45829&amp;oldid=prev"/>
		<updated>2012-02-01T21:22:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:22, 2 February 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l19&quot;&gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	.LINK&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	.LINK&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;http&lt;/del&gt;://wiki.itcollege.ee&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;https&lt;/ins&gt;://wiki.itcollege.ee&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/index.php/PowerShell:_SQLi_baasi_kirjutamise_skript&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Taliiv</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=PowerShell:_SQLi_baasi_kirjutamise_skript&amp;diff=45828&amp;oldid=prev</id>
		<title>Taliiv: Created page with &#039;&lt;Source lang=&quot;powershell&quot;&gt; &lt;# 	 	.Synopsis 	Kirjutab arvutinime, loogiliste k6vaketaste arvu, nende suuruse ja vaba ruumi andmebaasi. 	 	.DESCRIPTION 	V6imalik on anda andmebaasi…&#039;</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=PowerShell:_SQLi_baasi_kirjutamise_skript&amp;diff=45828&amp;oldid=prev"/>
		<updated>2012-02-01T21:22:23Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;Source lang=&amp;quot;powershell&amp;quot;&amp;gt; &amp;lt;# 	 	.Synopsis 	Kirjutab arvutinime, loogiliste k6vaketaste arvu, nende suuruse ja vaba ruumi andmebaasi. 	 	.DESCRIPTION 	V6imalik on anda andmebaasi…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;Source lang=&amp;quot;powershell&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;#&lt;br /&gt;
	&lt;br /&gt;
	.Synopsis&lt;br /&gt;
	Kirjutab arvutinime, loogiliste k6vaketaste arvu, nende suuruse ja vaba ruumi andmebaasi.&lt;br /&gt;
	&lt;br /&gt;
	.DESCRIPTION&lt;br /&gt;
	V6imalik on anda andmebaasi serveri parameetrid (serveri nimi, baasi nimi, kasutajanimi, parool ja tabeli nimi)&lt;br /&gt;
	Tabelis endas peavad olema v2ljad Masin, Ketas, Suurus, Aeg (sinna andmeid ei saadeta, tavaliselt TIMESTAMP formaadis ja t2idetakse automaatselt) ja Vaba.&lt;br /&gt;
	Et skript t66taks peab olema installeeritud MySQL .NET Connector v6i annad v6tmega -MySql ette MySql.Data.dll asukoha (v6ib olla ka teise nimega).&lt;br /&gt;
	&lt;br /&gt;
	.EXAMPLE&lt;br /&gt;
	C:\PS&amp;gt;.\skript.ps1 -Tabel test -Kasutaja test -Parool test&lt;br /&gt;
	&lt;br /&gt;
	.NOTES&lt;br /&gt;
	Autor: TambetLiiv &lt;br /&gt;
	Versioon: 0.1 &lt;br /&gt;
	Muutmise kuup2ev: 02.02.2012&lt;br /&gt;
	&lt;br /&gt;
	.LINK&lt;br /&gt;
	http://wiki.itcollege.ee&lt;br /&gt;
	&lt;br /&gt;
#&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Param(	[String]$Server = &amp;quot;localhost&amp;quot;,&lt;br /&gt;
		[String]$Baas = &amp;quot;kettad&amp;quot;,&lt;br /&gt;
		[String]$Kasutaja = &amp;quot;root&amp;quot;,&lt;br /&gt;
		[String]$Parool = &amp;quot;baas&amp;quot;,&lt;br /&gt;
		[String]$Tabel = &amp;quot;kettad&amp;quot;,&lt;br /&gt;
		[String]$MySql)&lt;br /&gt;
if ($MySql) {[void][system.reflection.Assembly]::LoadFrom(&amp;quot;$MySql&amp;quot;)}&lt;br /&gt;
[void][system.reflection.assembly]::LoadWithPartialName(&amp;quot;MySql.Data&amp;quot;)&lt;br /&gt;
$cn = New-Object -TypeName MySql.Data.MySqlClient.MySqlConnection&lt;br /&gt;
$cn.ConnectionString = &amp;quot;SERVER=$Server;DATABASE=$Baas;UID=$Kasutaja;PWD=$Parool&amp;quot;&lt;br /&gt;
try{$cn.Open()}&lt;br /&gt;
catch [Exception]&lt;br /&gt;
	{&lt;br /&gt;
	Write-Output &amp;quot;`nEi saa baasiga yhendust`n&amp;quot;&lt;br /&gt;
	Exit&lt;br /&gt;
	}&lt;br /&gt;
$cm = New-Object -TypeName MySql.Data.MySqlClient.MySqlCommand&lt;br /&gt;
$cm.Connection = $cn&lt;br /&gt;
$kettad = Get-WmiObject Win32_LogicalDisk | Select-Object SystemName, DeviceID, Size, FreeSpace&lt;br /&gt;
$kettad | ForEach-Object {&lt;br /&gt;
			$kettad = Get-WmiObject Win32_LogicalDisk | Select-Object SystemName, DeviceID, Size, FreeSpace&lt;br /&gt;
			$mnimi = $_.SystemName&lt;br /&gt;
			$knimi = $_.DeviceId&lt;br /&gt;
			if($_.Size) {$ksuurus = $_.Size} else {$ksuurus = 0}&lt;br /&gt;
			if($_.FreeSpace) {$kvaba = $_.FreeSpace} else {$kvaba = 0}&lt;br /&gt;
			$sql = &amp;quot;INSERT INTO $Tabel (Masin, Ketas, Suurus, Vaba) VALUES (&amp;#039;$mnimi&amp;#039;,&amp;#039;$knimi&amp;#039;,$ksuurus,$kvaba)&amp;quot;&lt;br /&gt;
			$cm.CommandText = $sql&lt;br /&gt;
			$dr = $cm.ExecuteNonQuery()&lt;br /&gt;
			$v = &amp;quot;`nMidagi l2ks valesti`n&amp;quot;&lt;br /&gt;
			if ($dr -eq 1)&lt;br /&gt;
				{&lt;br /&gt;
				$v = $null&lt;br /&gt;
				}&lt;br /&gt;
			else&lt;br /&gt;
				{&lt;br /&gt;
				Write-Output &amp;quot;`nViga: $dr`n&amp;quot;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
if($v) {Write-Output $v} else { Write-Output &amp;quot;`nKorras, asjad baasis`n&amp;quot;}&lt;br /&gt;
$cn.Close()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Taliiv</name></author>
	</entry>
</feed>