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 / energie.ps1
Last active December 23, 2015 12:19
Energieverbrauch bestimmen
Param(
[String]$file
)
function check ([String]$ipadress) {
#param ($ipadress)
$ipadress -match "(\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)"
}
if ($file -ne "") {
$dir = Get-Location
@jtuttas
jtuttas / Netzip.ps1
Created September 27, 2013 15:42
Netz-IP's aus zweidimensionalen Array
$rechnerliste = (("NAS",192,168,178,1),("Desktop PC1",192,168,178,19),("Desktop PC2",192,168,178,22),("Drucker",192,168,118,22),("WebServer",192,168,118,9),("Fileserver",192,168,118,56))
$sub1= Read-Host ("1. Oktett Subnetzmaske")
$sub2=Read-Host ("2. Oktett Subnetzmaske")
$sub3=Read-Host ("3. Oktett Subnetzmaske")
$sub4=Read-Host ("4. Oktett Subnetzmaske")
$n1=$rechnerliste[0][1] -band $sub1
$n2=$rechnerliste[0][2] -band $sub2
$n3=$rechnerliste[0][3] -band $sub3
$n4=$rechnerliste[0][4] -band $sub4
Write-Host ("Netz Adresse von "+$rechnerliste[0][0]+" ist $n1.$n2.$n3.$n4")
@jtuttas
jtuttas / udpClient.ps1
Created January 22, 2014 13:50
UDP Client / Server
$port=2021
$endpoint = new-object System.Net.IPEndPoint ([IPAddress]"10.13.6.100",$port)
$udpclient=new-Object System.Net.Sockets.UdpClient
$b=[Text.Encoding]::ASCII.GetBytes('Is anyone there!')
$bytesSent=$udpclient.Send($b,$b.length,$endpoint)
$udpclient.Close()
param([String]$ips,[String]$subs)
$sub=$subs.Split(".") # Array Oktette der Subnezmaske
$ip=$ips.Split(".") # Array Oktelle der Netzip
# Netz IP bestimmen
$netz=0,0,0,0
for ($i=0; $i -lt 4;$i++) {
$netz[$i]=$ip[$i] -band $sub[$i]
}
$imSubnetz=$true
$aktuelleIP=0,0,0,0
@jtuttas
jtuttas / 0_reuse_code.js
Created May 7, 2014 14:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
$hmax = read-host Maximale Länge für Hypothenuse eingeben!;
for ($j=1; $j -le $hmax; $j++){
for ($k=1; $k -lt $j; $k++){
$h= [math]::Sqrt(($j * $j)+($k * $k));
if ($h % 1.0 -eq 0.0 -and $h -le $hmax){
write-host $h + $j + $k;
}
}
}
do {
[int32]$zstart = read-host "Startzahl"
} while (($zstart % 2) -eq 0)
do {
[int32]$zende = read-host "Endezahl"
} while (($zende % 2) -eq 0)
[int32]$summe = 0
for ($i=$zstart+2;$i -le $zende -2;$i+=2) {
# Login
Invoke-WebRequest "http://192.168.178.29/mmbbsapp/news.php?user=mmbbs&password=mmbbs" -SessionVariable s
# Logout
Invoke-WebRequest "http://192.168.178.29/mmbbsapp/news.php?cmd=logout" -WebSession $s
# Abfrage letzte News
Invoke-WebRequest http://192.168.178.29/mmbbsapp/news.php -WebSession $s
# Abfragen News ab ID
Invoke-WebRequest http://192.168.178.29/mmbbsapp/news.php?id=2 -WebSession $s
# Eintragen einer News
Invoke-WebRequest "http://192.168.178.29/mmbbsapp/news.php?Headline=Überschrift&Text=Dies ist ein Text mit öäü" -WebSession $s
function ipinfo($ip) {
$ip
[int[]]$x = $ip.Split(".")
if($x[0] -le 127)
{
"Class A"
}
elseif($x[0] -gt 127 -and $x[0] -le 191)
{
"Class B"
$ci=New-Object System.Object | Select-Object -Property MACAddress,Architecture,OS,RAM,freeDiskspace,ComputerName
$ci.MACAddress=Get-WmiObject win32_networkadapterconfiguration | Where-Object ipaddress | Select-Object -ExpandProperty MACAddress
$ci.Architecture=(Get-WmiObject win32_operatingsystem).OSArchitecture
$ci.OS=(Get-WmiObject win32_operatingsystem).Caption
[double]$ci.RAM=(Get-WmiObject win32_computersystem).totalPhysicalmemory/1gb
$ci.freeDiskspace=(Get-WmiObject win32_logicaldisk) | Where-Object {$_.DeviceID -eq "c:"} | Select-Object -ExpandProperty FreeSpace
$ci.ComputerName=$env:COMPUTERNAME
$ci