Skip to content

Instantly share code, notes, and snippets.

View jtuttas's full-sized avatar

jtuttas jtuttas

  • http://www.mmbbs.de
View GitHub Profile
@jtuttas
jtuttas / mmbbswetter.ps1
Created May 13, 2013 13:01
Wetter an der MMBBS mittels yahoo weather webservice
cls
$webClient = new-object System.Net.WebClient
$mmbbs = Read-Host ("Sind sie in der Schule hinter dem Proxy? j/n")
if ($mmbbs -eq "j") {
$proxy = new-object System.Net.WebProxy "10.20.30.55:3128"
$login = Read-Host ("Benutzername")
$pw = Read-Host ("Kennwort")
$cred = New-Object System.Net.NetworkCredential $login, $pw
$proxy.Credentials = $cred #(Get-Credential).GetNetworkCredential()
@jtuttas
jtuttas / xml-zeugnis-durchschnitt.ps1
Created May 11, 2013 11:17
Zeugnisnoten Durchschnitt
cls
[xml]$a = Get-Content ("schulklasse_zeugnis.xml")
$n = $a.SelectNodes("//pupil")
foreach ($p in $n) {
$sum=0
$z=$p.zeugnis.FirstChild
do {
if ($z.Name -ne "fehlzeiten") {
$sum=$sum+$z.InnerText
@jtuttas
jtuttas / updatenodes.ps1
Created May 10, 2013 15:21
update Nodes
cls
[xml]$a = Get-Content ("D:\Dropbox\temp\rechnernetz.xml")
$n = $a.SelectNodes("//pc")
foreach ($p in $n) {
if ($p.name -eq "Franks Notebook") {
$p.ip="192.168.178.10"
}
}
$a.Save("D:\Dropbox\Temp\rechnernetz_neu.xml")
[xml]$a = Get-Content ("D:\Dropbox\temp\rechnernetz.xml")
$pc=$a.CreateElement("pc")
$pc.SetAttribute("mac","12:33:ef:ff:a2:7a")
$ip=$a.CreateElement("ip")
$ip.innerText="192.168.178.7"
$pc.AppendChild($ip)
$name=$a.CreateElement("name")
$name.innerText="Franks Tablet"
$pc.AppendChild($name)
$a.rechnernetz.AppendChild($pc)
@jtuttas
jtuttas / rechnernetz.xml
Created May 10, 2013 14:49
Delete XML Node
<rechnernetz subnet="255.255.255.0" >
<pc mac="23:cd:11:f1:2a:22">
<ip>192.168.178.2</ip>
<name>Franks Desktop</name>
</pc>
<pc mac="23:cd:11:f1:2a:23">
<ip>192.168.178.3</ip>
<name>Franks Notebook</name>
</pc>
<router mac="23:cd:11:f1:2a:24">
@jtuttas
jtuttas / gebTageSonntag.ps1
Created April 26, 2013 09:32
Geburtstage die auf einen Sonntag liegen
cls
$gebTag = New-Object System.DateTime(1968,4,11)
$today = Get-Date
$gebTag=$gebTag.AddYears($today.Year-$gebTag.Year)
for ($i=0;$i -lt 50;$i++) {
$gebTag=$gebTag.AddYears(1);
if ($gebTag.DayOfWeek -eq "Sunday") {
Write-Host ("Du hast im Jahr "+$gebTag.Year+" wieder auf einen Sonntag Geburtstag")
}
@jtuttas
jtuttas / ipklasseGUI.ps1
Last active December 16, 2015 16:49
IP Netzklasse bestimmen mit GUI
function ipclass ([string]$ip) {
[array]$x = $ip.Split(".")
if($x[0] -le 127)
{
return "A";
}
if($x[0] -gt 127 -and $x[0] -le 191)
{
return "B";
}
@jtuttas
jtuttas / ipclass.ps1
Created April 26, 2013 07:46
ipclass
function ipclass ([string]$ip) {
[array]$x = $ip.Split(".")
if($x[0] -le 127)
{
return "A";
}
if($x[0] -gt 127 -and $x[0] -le 191)
{
return "B";
}
@jtuttas
jtuttas / clickCounter.ps1
Created April 23, 2013 16:19
Powershell Klick Counter
$global:klicks=0
$myF = New-Object System.Windows.Forms.Form
$b = New-Object System.Windows.Forms.Button
$l = New-Object System.Windows.Forms.Label
$l.Text = "Klicks 0"
$l.Location="10,50"
$b.Text="Klick mich"
$b.Location="10,20"
$l.Add_MouseHover({
$global:klicks=0
@jtuttas
jtuttas / drehFuntion.ps1
Created April 10, 2013 14:08
Zeichenkette drehen als Funktion
cls
function dreh([String]$a) {
$out=""
for ($i=$a.Length-1;$i -ge 0;$i--) {
$out=$out+$a.Chars($i)
}
return $out
}
$a=dreh ("Hallo")