
Druidsys.com's collection of Windows PowerShell Scripts.
Save the script in a text document and save it with the ps1 extension and then call it from a PowerShell prompt.
$client = new-object system.net.WebClient
$client.Headers.Add("user-agent", "PowerShell")
$data = $client.OpenRead("http://icanhazip.com")
$reader = new-object system.io.StreamReader $data
[string] $s = $reader.ReadToEnd()
write-host "Your external IP is $s"
$data.Close()
$reader.Close()
Save the script in a text document and save it with the ps1 extension and then call it from a PowerShell prompt.
write-host
write-host "Locked out accounts"
write-host "###################"
$dn = "dc=$args[0],dc=druidsys,dc=com" #replace with your domain
$domain = "LDAP://$dn"
$root = New-Object System.DirectoryServices.DirectoryEntry $domain
$query = new-Object System.DirectoryServices.DirectorySearcher
$query.searchroot = $root
$objClass = $query.findall() | Where-Object {$_.properties.objectclass -eq "user" -and $_.properties.lockouttime -ge 1}
foreach ($user in $objClass) {
$prop = $user.properties
write-host $prop.samaccountname
}
write-host
Save the script in a text document and save it with the ps1 extension and then call it from a PowerShell prompt.
$buffer = ping $args[0] | findstr "Reply"
if ($buffer -match "Reply*")
{
write-host
write-host "Rebooting $target..."
(gwmi Win32_OperatingSystem -computer $args[0]).reboot() | out-null
write-host
write-host "The machine is now monitored until it is back online."
write-host "Press [Ctrl-C] to stop this monitor."
write-host
write-host "Waiting for power off..." -nonewline
while ($buffer -match "Reply*") { $buffer = ping -n 1 $args[0] | findstr "Reply" }
write-host "done."
write-host "Waiting for system to come back online..." -nonewline
$buffer = ping $args[0] | findstr "Request"
while ($buffer -match "Request*") { $buffer = ping -n 1 $args[0] | findstr "Request" }
write-host "done."
write-host
write-host "Reboot completed."
write-host
}
else
{
write-host $target "does not respond."
}
write-host
Save the script in a text document and save it with the ps1 extension and then call it from a PowerShell prompt.
$args[0] = $args[0].ToUpper()
if ($args[0][0] -eq "A") {
if ($args[0][1] -eq "#") { $n = 1 }
elseif ($args[0][1] -eq "B") { $n = -1 }
else { $n = 0 }
}
if ($args[0][0] -eq "B") {
if ($args[0][1] -eq "B") { $n = 1 }
else { $n = 2 }
}
if ($args[0][0] -eq "C") {
if ($args[0][1] -eq "#") { $n = -8 }
else { $n = -9 }
}
if ($args[0][0] -eq "D") {
if ($args[0][1] -eq "#") { $n = -6 }
elseif ($args[0][1] -eq "B") { $n = -8 }
else { $n = -7 }
}
if ($args[0][0] -eq "E") {
if ($args[0][1] -eq "B") { $n = -6 }
else { $n = -5 }
}
if ($args[0][0] -eq "F") {
if ($args[0][1] -eq "#") { $n = -3 } else { $n = -4 }
}
if ($args[0][0] -eq "G") {
if ($args[0][1] -eq "#") { $n = -1 }
elseif ($args[0][1] -eq "B") { $n = -3 }
else { $n = -2 }
}
$p = $n / 12
$hz = [math]::round(([math]::pow(2,$p)) * 440, 3)
if ($args[1] -le 1) { $oct = 4 } else { $oct = $args[1] }
if ($oct -ne 4) {
if ($oct -le 3) { $hz = $hz / 2 }
if ($oct -le 2) { $hz = $hz / 2 }
if ($oct -ge 5) { $hz = $hz * 2 }
if ($oct -ge 6) { $hz = $hz * 2 }
if ($oct -ge 7) { $hz = $hz * 2 }
}
write-host
write-host "$hz Hz (Octave: $oct)"
write-host
[console]::beep($hz,500)