Updated some scripts

This commit is contained in:
Markus Fleschutz
2020-11-06 14:30:14 +00:00
parent 0ffef56c95
commit 946e76a5ca
11 changed files with 227 additions and 219 deletions

View File

@ -1,6 +1,6 @@
#!/snap/bin/powershell #!/snap/bin/powershell
# Syntax: ./MD5.ps1 <file> # Syntax: ./MD5.ps1 [<file>]
# Description: prints the MD5 checksum of the given file # Description: prints the MD5 checksum of the given file
# Author: Markus Fleschutz # Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell # Source: github.com/fleschutz/PowerShell
@ -8,7 +8,7 @@
param([string]$File) param([string]$File)
if ($File -eq "" ) { if ($File -eq "" ) {
$File = read-host "Enter file: " $File = read-host "Enter file"
} }
try { try {

View File

@ -1,6 +1,6 @@
#!/snap/bin/powershell #!/snap/bin/powershell
# Syntax: ./SHA1.ps1 <file> # Syntax: ./SHA1.ps1 [<file>]
# Description: prints the SHA1 checksum of the given file # Description: prints the SHA1 checksum of the given file
# Author: Markus Fleschutz # Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell # Source: github.com/fleschutz/PowerShell
@ -8,7 +8,7 @@
param([string]$File) param([string]$File)
if ($File -eq "" ) { if ($File -eq "" ) {
$File = read-host "Enter file: " $File = read-host "Enter file"
} }
try { try {

View File

@ -1,6 +1,6 @@
#!/snap/bin/powershell #!/snap/bin/powershell
# Syntax: ./SHA256.ps1 <file> # Syntax: ./SHA256.ps1 [<file>]
# Description: prints the SHA256 checksum of the given file # Description: prints the SHA256 checksum of the given file
# Author: Markus Fleschutz # Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell # Source: github.com/fleschutz/PowerShell
@ -8,7 +8,7 @@
param([string]$File) param([string]$File)
if ($File -eq "" ) { if ($File -eq "" ) {
$File = read-host "Enter file: " $File = read-host "Enter file"
} }
try { try {

View File

@ -1,4 +1,4 @@
#!/snap/bin/powershell #!/snap/bin/powershell
# Syntax: ./crash_dumps.ps1 # Syntax: ./crash_dumps.ps1
# Description: enables crash dumps # Description: enables crash dumps
@ -6,46 +6,46 @@
# Source: github.com/fleschutz/PowerShell # Source: github.com/fleschutz/PowerShell
# License: CC0 # License: CC0
################################################################## ##################################################################
# # # #
# Written by: Ryan Waters # # Written by: Ryan Waters #
# # # #
# Program: Get-Dump.ps1 # # Program: Get-Dump.ps1 #
# Date: 2-06-2020 # # Date: 2-06-2020 #
# Purpose: To set registry keys to gather a WER Usermode Dump # # Purpose: To set registry keys to gather a WER Usermode Dump #
# and be able to change from a custom, mini, or FULL # # and be able to change from a custom, mini, or FULL #
# Dumps for ease of use for customers and others. # # Dumps for ease of use for customers and others. #
# # # #
# EULA: Code is free to use for all, and free to distribute # # EULA: Code is free to use for all, and free to distribute #
# I just ask that you leave the credit information and # # I just ask that you leave the credit information and #
# this EULA and Comment Section in tact and do not delete. # # this EULA and Comment Section in tact and do not delete. #
# # # #
# Bitwise Values: (For reference) # # Bitwise Values: (For reference) #
# # # #
# 0x00000000 - MiniDumpNormal # # 0x00000000 - MiniDumpNormal #
# 0x00000001 - MiniDumpWithDataSegs # # 0x00000001 - MiniDumpWithDataSegs #
# 0x00000002 - MiniDumpWithFullMemory # # 0x00000002 - MiniDumpWithFullMemory #
# 0x00000004 - MiniDumpWithHandleData # # 0x00000004 - MiniDumpWithHandleData #
# 0x00000008 - MiniDumpFilterMemory # # 0x00000008 - MiniDumpFilterMemory #
# 0x00000010 - MiniDumpScanMemory # # 0x00000010 - MiniDumpScanMemory #
# 0x00000020 - MiniDumpWithUnloadedModules # # 0x00000020 - MiniDumpWithUnloadedModules #
# 0x00000040 - MiniDumpWithIndirectlyReferenced # # 0x00000040 - MiniDumpWithIndirectlyReferenced #
# 0x00000080 - MemoryMiniDumpFilterModulePaths # # 0x00000080 - MemoryMiniDumpFilterModulePaths #
# 0x00000100 - MiniDumpWithProcessThreadData # # 0x00000100 - MiniDumpWithProcessThreadData #
# 0x00000200 - MiniDumpWithPrivateReadWriteMemory # # 0x00000200 - MiniDumpWithPrivateReadWriteMemory #
# 0x00000400 - MiniDumpWithoutOptionalData # # 0x00000400 - MiniDumpWithoutOptionalData #
# 0x00000800 - MiniDumpWithFullMemoryInfo # # 0x00000800 - MiniDumpWithFullMemoryInfo #
# 0x00001000 - MiniDumpWithThreadInfo # # 0x00001000 - MiniDumpWithThreadInfo #
# 0x00002000 - MiniDumpWithCodeSegs # # 0x00002000 - MiniDumpWithCodeSegs #
# 0x00004000 - MiniDumpWithoutAuxiliaryState # # 0x00004000 - MiniDumpWithoutAuxiliaryState #
# 0x00008000 - MiniDumpWithFullAuxiliaryState # # 0x00008000 - MiniDumpWithFullAuxiliaryState #
# 0x00010000 - MiniDumpWithPrivateWriteCopyMemory # # 0x00010000 - MiniDumpWithPrivateWriteCopyMemory #
# 0x00020000 - MiniDumpIgnoreInaccessibleMemory # # 0x00020000 - MiniDumpIgnoreInaccessibleMemory #
# 0x00040000 - MiniDumpWithTokenInformation # # 0x00040000 - MiniDumpWithTokenInformation #
# # # #
################################################################## ##################################################################
#Setting Values: #Setting Values:
$MDN = '0' $MDN = '0'
$MDWDS = '1' $MDWDS = '1'
$MDWFM = '2' $MDWFM = '2'
@ -91,27 +91,27 @@ $t = $MDWTOI
$0x = "0x" $0x = "0x"
$array = @() $array = @()
Clear-host Clear-host
write-host "Setting up your machine to receive Usermode Dumps via WER." write-host "Setting up your machine to receive Usermode Dumps via WER."
Start-sleep -s 3 Start-sleep -s 3
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "%LOCALAPPDATA%\CrashDumps" -PropertyType ExpandString -Force New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "%LOCALAPPDATA%\CrashDumps" -PropertyType ExpandString -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpCount" -Value "10" -PropertyType DWORD -Force New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpCount" -Value "10" -PropertyType DWORD -Force
clear-host clear-host
write-host "What would you like to do?" write-host "What would you like to do?"
write-host "(0) Disable Dumps and restore system to factory." write-host "(0) Disable Dumps and restore system to factory."
write-host "(1) Enable System for Full Dumps." write-host "(1) Enable System for Full Dumps."
write-host "(2) Enable System for Mini Dumps." write-host "(2) Enable System for Mini Dumps."
write-host "(3) Enable System for custom dump with options." write-host "(3) Enable System for custom dump with options."
$NCD = Read-Host "Enter a number option" $NCD = Read-Host "Enter a number option"
If ($NCD -eq '3') If ($NCD -eq '3')
{ {
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "0" -PropertyType DWORD -Force New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "0" -PropertyType DWORD -Force
Do Do
{ {
clear-host clear-host
@ -231,61 +231,61 @@ If ($NCD -eq '3')
} }
While($Option -ne "q") While($Option -ne "q")
$sum = $array -join '+' $sum = $array -join '+'
$SumArray = Invoke-Expression $sum $SumArray = Invoke-Expression $sum
$FinalSum = $0x + $SumArray $FinalSum = $0x + $SumArray
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "CustomDumpFlags" -Value "$FinalSum" -PropertyType DWORD -Force New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "CustomDumpFlags" -Value "$FinalSum" -PropertyType DWORD -Force
write-host " " write-host " "
write-host "Setting up the system for crash dumps requires a reboot" write-host "Setting up the system for crash dumps requires a reboot"
} }
ElseIf ($NCD -eq '0') ElseIf ($NCD -eq '0')
{ {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpCount" -Force -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpCount" -Force -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Force -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Force -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Force -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Force -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "CustomDumpFlags" -Force -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "CustomDumpFlags" -Force -ErrorAction SilentlyContinue
write-host " " write-host " "
$reboot = read-host "Registry reset to factory settings and cleared. It is recommended to restart your machine, would you like to now?" $reboot = read-host "Registry reset to factory settings and cleared. It is recommended to restart your machine, would you like to now?"
if($reboot -eq "Yes" -or $reboot -eq "Y" -or $reboot -eq "yes" -or $reboot -eq "y") if($reboot -eq "Yes" -or $reboot -eq "Y" -or $reboot -eq "yes" -or $reboot -eq "y")
{ {
shutdown -r shutdown -r
} }
Else Else
{ {
write-host "Please restart the machine for settings to take effect at your convenience." write-host "Please restart the machine for settings to take effect at your convenience."
} }
} }
ElseIf ($NCD -eq '1') ElseIf ($NCD -eq '1')
{ {
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "2" -PropertyType DWORD -Force New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "2" -PropertyType DWORD -Force
write-host "The computer has been set up to create a Full Sized Dump and will be located in %LOCALAPPDATA%\CrashDumps." write-host "The computer has been set up to create a Full Sized Dump and will be located in %LOCALAPPDATA%\CrashDumps."
write-host "The computer must also restart for settings to take effect. Would you like to now? (Y/n)" write-host "The computer must also restart for settings to take effect. Would you like to now? (Y/n)"
if($reboot -eq "Yes" -or $reboot -eq "Y" -or $reboot -eq "yes" -or $reboot -eq "y") if($reboot -eq "Yes" -or $reboot -eq "Y" -or $reboot -eq "yes" -or $reboot -eq "y")
{ {
shutdown -r shutdown -r
} }
Else Else
{ {
write-host "Please restart the machine for settings to take effect at your convenience." write-host "Please restart the machine for settings to take effect at your convenience."
} }
} }
ElseIf ($NCD -eq '2') ElseIf ($NCD -eq '2')
{ {
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "1" -PropertyType DWORD -Force New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "1" -PropertyType DWORD -Force
write-host "The computer has been set up to create a Mini Dump and will be located in %LOCALAPPDATA%\CrashDumps." write-host "The computer has been set up to create a Mini Dump and will be located in %LOCALAPPDATA%\CrashDumps."
write-host "The computer must also restart for settings to take effect. Would you like to now? (Y/n)" write-host "The computer must also restart for settings to take effect. Would you like to now? (Y/n)"
if($reboot -eq "Yes" -or $reboot -eq "Y" -or $reboot -eq "yes" -or $reboot -eq "y") if($reboot -eq "Yes" -or $reboot -eq "Y" -or $reboot -eq "yes" -or $reboot -eq "y")
{ {
shutdown -r shutdown -r
} }
Else Else
{ {
write-host "Please restart the machine for settings to take effect at your convenience." write-host "Please restart the machine for settings to take effect at your convenience."
} }
} }
Else Else
{ {
write-host "You did not enter a valid option. Please re-run Get-Dump.ps1" write-host "You did not enter a valid option. Please re-run Get-Dump.ps1"
start-sleep -s 5 start-sleep -s 5
} }

View File

@ -1,6 +1,6 @@
#!/snap/bin/powershell #!/snap/bin/powershell
# Syntax: ./download.ps1 <URL> # Syntax: ./download.ps1 [<URL>]
# Description: downloads the file/directory from the given URL # Description: downloads the file/directory from the given URL
# Author: Markus Fleschutz # Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell # Source: github.com/fleschutz/PowerShell
@ -8,7 +8,7 @@
param([string]$URL) param([string]$URL)
if ($URL -eq "" ) { if ($URL -eq "" ) {
$URL = read-host "Enter URL to download: " $URL = read-host "Enter URL to download"
} }
try { try {

View File

@ -6,9 +6,9 @@
# Source: github.com/fleschutz/PowerShell # Source: github.com/fleschutz/PowerShell
# License: CC0 # License: CC0
$UserName = read-host "Your full name: " $UserName = read-host "Your full name"
$UserEmail = read-host "Your email address: " $UserEmail = read-host "Your email address"
$UserEditor = read-host "Your favorite editor (nano, vi, emacs): " $UserEditor = read-host "Your favorite editor (nano, vi, emacs)"
try { try {
git config --global user.name $UserName git config --global user.name $UserName

View File

@ -1,14 +1,18 @@
#!/snap/bin/powershell #!/snap/bin/powershell
# Syntax: ./latlong.ps1 <city> # Syntax: ./latlong.ps1 [<city>]
# Description: prints the lat/long coordinates of the given city # Description: prints the lat/long coordinates of the given city
# Author: Markus Fleschutz # Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell # Source: github.com/fleschutz/PowerShell
# License: CC0 # License: CC0
param([string]$City) param([string]$City)
if ($City -eq "" ) {
$City = read-host "Enter city"
}
try { try {
write-progress "Reading worldcities.csv..."
$Table = import-csv worldcities.csv $Table = import-csv worldcities.csv
$FoundOne = 0 $FoundOne = 0
foreach($Row in $Table) { foreach($Row in $Table) {

View File

@ -1,4 +1,4 @@
#!/snap/bin/powershell #!/snap/bin/powershell
# Syntax: ./test.ps1 # Syntax: ./test.ps1
# Description: simple PowerShell test script # Description: simple PowerShell test script

View File

@ -12,7 +12,7 @@ try {
$Table = import-csv domain_table.csv $Table = import-csv domain_table.csv
foreach($Row in $Table) { foreach($Row in $Table) {
$Domain = $Row.Domain $Domain = $Row.Domain
write-progress "Training DNS cache with $Domain ..." write-progress "Training DNS cache with $Domain..."
$Ignore = nslookup $Domain $Ignore = nslookup $Domain
} }

View File

@ -1,25 +1,25 @@
#!/snap/bin/powershell #!/snap/bin/powershell
# Syntax: ./txt2wav.ps1 # Syntax: ./txt2wav.ps1
# Description: converts the given text into an audio .WAV file # Description: converts the given text into an audio .WAV file
# Author: Markus Fleschutz # Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell # Source: github.com/fleschutz/PowerShell
# License: CC0 # License: CC0
# Configuration: # Configuration:
$Text = "Hello, my name ist Bond, James Bond" $Text = "Hello, my name ist Bond, James Bond"
$Speed = -1 # -10 is slowest, 10 is fastest $Speed = -1 # -10 is slowest, 10 is fastest
$TargetWavFile = "spoken.wav" $TargetWavFile = "spoken.wav"
# Run: # Run:
try { try {
Add-Type -AssemblyName System.Speech Add-Type -AssemblyName System.Speech
$SpeechSynthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer $SpeechSynthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer
# $SpeechSynthesizer.SelectVoice("Microsoft Eva Mobile") # $SpeechSynthesizer.SelectVoice("Microsoft Eva Mobile")
$SpeechSynthesizer.Rate = $Speed $SpeechSynthesizer.Rate = $Speed
$SpeechSynthesizer.SetOutputToWaveFile($TargetWavFile) $SpeechSynthesizer.SetOutputToWaveFile($TargetWavFile)
$SpeechSynthesizer.Speak($Text) $SpeechSynthesizer.Speak($Text)
$SpeechSynthesizer.Dispose() $SpeechSynthesizer.Dispose()
exit 0 exit 0
} catch { Write-Error $Error[0] } } catch { Write-Error $Error[0] }
exit 1 exit 1

View File

@ -1,61 +1,65 @@
#!/snap/bin/powershell #!/snap/bin/powershell
# Syntax: ./wakeup.ps1 # Syntax: ./wakeup.ps1 [<hostname>]
# Description: sends a magic packet to the given computer, waking him up # Description: sends a magic packet to the given computer, waking him up
# Author: Markus Fleschutz # Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell # Source: github.com/fleschutz/PowerShell
# License: CC0 # License: CC0
function Send-WOL param([string]$Hostname)
{ if ($Hostname -eq "" ) {
<# $Hostname = read-host "Enter hostname"
.SYNOPSIS }
Send a WOL packet to a broadcast address
.PARAMETER mac function Send-WOL
The MAC address of the device that need to wake up {
.PARAMETER ip <#
The IP address where the WOL packet will be sent to .SYNOPSIS
.EXAMPLE Send a WOL packet to a broadcast address
Send-WOL -mac 00:11:32:21:2D:11 -ip 192.168.8.255 .PARAMETER mac
.EXAMPLE The MAC address of the device that need to wake up
Send-WOL -mac 00:11:32:21:2D:11 .PARAMETER ip
#> The IP address where the WOL packet will be sent to
.EXAMPLE
[CmdletBinding()] Send-WOL -mac 00:11:32:21:2D:11 -ip 192.168.8.255
param( .EXAMPLE
[Parameter(Mandatory=$True,Position=1)] Send-WOL -mac 00:11:32:21:2D:11
[string]$mac, #>
[string]$ip="255.255.255.255",
[int]$port=9 [CmdletBinding()]
) param(
$broadcast = [Net.IPAddress]::Parse($ip) [Parameter(Mandatory=$True,Position=1)]
[string]$mac,
$mac=(($mac.replace(":","")).replace("-","")).replace(".","") [string]$ip="255.255.255.255",
$target=0,2,4,6,8,10 | % {[convert]::ToByte($mac.substring($_,2),16)} [int]$port=9
$packet = (,[byte]255 * 6) + ($target * 16) )
$broadcast = [Net.IPAddress]::Parse($ip)
$UDPclient = new-Object System.Net.Sockets.UdpClient
$UDPclient.Connect($broadcast,$port) $mac=(($mac.replace(":","")).replace("-","")).replace(".","")
[void]$UDPclient.Send($packet, 102) $target=0,2,4,6,8,10 | % {[convert]::ToByte($mac.substring($_,2),16)}
} $packet = (,[byte]255 * 6) + ($target * 16)
$Hostname = read-host "Enter hostname: " $UDPclient = new-Object System.Net.Sockets.UdpClient
$MyMACAddresses = "io=11:22:33:44:55:66","pi=11:22:33:44:55:66" $UDPclient.Connect($broadcast,$port)
[void]$UDPclient.Send($packet, 102)
try { }
foreach($item in $MyMACAddresses) {
$array = $item.Split("=") $MyMACAddresses = "io=11:22:33:44:55:66","pi=11:22:33:44:55:66"
$thisHost=$array[0]
$thisMAC=$array[1] try {
if ($thisHost -like $Hostname) { foreach($item in $MyMACAddresses) {
Send-WOL $thisMAC $array = $item.Split("=")
write-output "✔️ host $thisHost waked up (MAC $thisMAC)" $thisHost=$array[0]
exit 0 $thisMAC=$array[1]
} if ($thisHost -like $Hostname) {
} Send-WOL $thisMAC
write-output "✔️ host $thisHost waked up (MAC $thisMAC)"
echo "Sorry, hostname $Hostname is unknown." exit 0
pause }
exit 1 }
} catch { Write-Error $Error[0] }
exit 1 echo "Sorry, hostname $Hostname is unknown."
pause
exit 1
} catch { Write-Error $Error[0] }
exit 1