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 / gist:5012025
Last active December 14, 2015 02:09
Tage bis Nikolaus
# Tage bis Nikolaus
cls
$nikolaus=New-Object System.DateTime(2013,12,6)
$today = Get-Date
$nikolausTag=$nikolaus.get_DayOfYear()
$todayTag=$today.get_DayOfYear()
Write-Host ("Es sind noch "+($nikolausTag-$todayTag)+" Tage bis Nikolaus")
@jtuttas
jtuttas / DatumInHTML.ps1
Created February 25, 2013 08:40
aktuelles Datum in eine HTML-Datei schreiben
cls
$d=Get-Content ("datum.html")
$i=1
$t=Get-Date
foreach ($line in $d) {
if ($line -match "<h1>Heute ist der:") {
$line="<h1>Heute ist der: $t</h1>"
}
if ($i-eq 1) {
$line | Set-Content("datum.html")
@jtuttas
jtuttas / process.ps1
Created March 13, 2013 11:05
Laufenden Prozesse in ein datei schreiben
$services = Get-Service
Get-Date | Set-Content info.txt
"Running Services" | Add-Content info.txt
foreach ($service in $services) {
if ($service.Status -like "Running") {
" "+$service.Name | add-Content info.txt
}
}
@jtuttas
jtuttas / biggest1.ps1
Created March 13, 2013 11:06
Die x größten Files finden
param (
[int]$num=5
)
cls
$a = Get-ChildItem -Recurse
$max = New-Object int[] $num
$maxNames = new-object String[] $num
foreach ($datei in $a) {
for ($i=0;$i -lt $num;$i++) {
if ($datei.Length -ge $max[$i]) {
@jtuttas
jtuttas / biggest2.ps1
Created March 13, 2013 11:07
Die x größten Files Finden mittels Pipe
param (
$max=5
)
cls
Get-ChildItem -Recurse | Sort-Object Length -Descending | Select-Object -First $max
@jtuttas
jtuttas / geburtstage.ps1
Last active December 15, 2015 02:19
Geburtstage als ics Datei aus einer CSV Datei
cls
$d = Get-Content .\Geburtstage.csv
$filename = "geburtstage.ics"
"" | Set-Content $filename
$idcount=1;
foreach ($zeile in $d) {
$daten = $zeile.Split(";")
"BEGIN:VCALENDAR" | Add-Content $filename
"VERSION:2.0" | Add-Content $filename
"PRODID:http://www.mmbbs.de" | Add-Content $filename
@jtuttas
jtuttas / wernoch.ps1
Last active December 15, 2015 02:29
wernoch
cls
$gebtag=Read-Host "Dein Geburtstag (in der Form 11.April.1968)"
$geb = $gebtag.Split(".")
$webClient = new-object System.Net.WebClient
#$proxy = new-object System.Net.WebProxy "10.20.30.55:3128"
#$cred = New-Object System.Net.NetworkCredential 'veranstaltung', 'qwertz'
#$proxy.Credentials = $cred #(Get-Credential).GetNetworkCredential()
#$proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
#$webclient.proxy=$proxy
@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")
@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 / 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";
}