mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-30 12:41:46 +02:00
Moved .ps1 files to subdir Scripts/
This commit is contained in:
283
Scripts/crash_dumps.ps1
Executable file
283
Scripts/crash_dumps.ps1
Executable file
@ -0,0 +1,283 @@
|
||||
##################################################################
|
||||
# #
|
||||
# Written by: Ryan Waters #
|
||||
# #
|
||||
# Program: Get-Dump.ps1 #
|
||||
# Date: 2-06-2020 #
|
||||
# Purpose: To set registry keys to gather a WER Usermode Dump #
|
||||
# and be able to change from a custom, mini, or FULL #
|
||||
# Dumps for ease of use for customers and others. #
|
||||
# #
|
||||
# EULA: Code is free to use for all, and free to distribute #
|
||||
# I just ask that you leave the credit information and #
|
||||
# this EULA and Comment Section in tact and do not delete. #
|
||||
# #
|
||||
# Bitwise Values: (For reference) #
|
||||
# #
|
||||
# 0x00000000 - MiniDumpNormal #
|
||||
# 0x00000001 - MiniDumpWithDataSegs #
|
||||
# 0x00000002 - MiniDumpWithFullMemory #
|
||||
# 0x00000004 - MiniDumpWithHandleData #
|
||||
# 0x00000008 - MiniDumpFilterMemory #
|
||||
# 0x00000010 - MiniDumpScanMemory #
|
||||
# 0x00000020 - MiniDumpWithUnloadedModules #
|
||||
# 0x00000040 - MiniDumpWithIndirectlyReferenced #
|
||||
# 0x00000080 - MemoryMiniDumpFilterModulePaths #
|
||||
# 0x00000100 - MiniDumpWithProcessThreadData #
|
||||
# 0x00000200 - MiniDumpWithPrivateReadWriteMemory #
|
||||
# 0x00000400 - MiniDumpWithoutOptionalData #
|
||||
# 0x00000800 - MiniDumpWithFullMemoryInfo #
|
||||
# 0x00001000 - MiniDumpWithThreadInfo #
|
||||
# 0x00002000 - MiniDumpWithCodeSegs #
|
||||
# 0x00004000 - MiniDumpWithoutAuxiliaryState #
|
||||
# 0x00008000 - MiniDumpWithFullAuxiliaryState #
|
||||
# 0x00010000 - MiniDumpWithPrivateWriteCopyMemory #
|
||||
# 0x00020000 - MiniDumpIgnoreInaccessibleMemory #
|
||||
# 0x00040000 - MiniDumpWithTokenInformation #
|
||||
# #
|
||||
##################################################################
|
||||
|
||||
#Setting Values:
|
||||
$MDN = '0'
|
||||
$MDWDS = '1'
|
||||
$MDWFM = '2'
|
||||
$MDWHD = '4'
|
||||
$MDFM = '8'
|
||||
$MDSM = '10'
|
||||
$MDWUM = '20'
|
||||
$MDWIR = '40'
|
||||
$MMDFMP = '80'
|
||||
$MDWPTD = '100'
|
||||
$MDWPRWM = '200'
|
||||
$MDWOD = '400'
|
||||
$MDWFMI = '800'
|
||||
$MDWTI = '1000'
|
||||
$MDWCS = '2000'
|
||||
$MDWAS = '4000'
|
||||
$MDWFAS = '8000'
|
||||
$MDWPWCM = '10000'
|
||||
$MDIIM = '20000'
|
||||
$MDWTOI = '40000'
|
||||
|
||||
$a = $MDN
|
||||
$b = $MDWDS
|
||||
$c = $MDWFM
|
||||
$d = $MDWHD
|
||||
$e = $MDFM
|
||||
$f = $MDSM
|
||||
$g = $MDWUM
|
||||
$h = $MDWIR
|
||||
$i = $MMDFMP
|
||||
$j = $MDWPTD
|
||||
$k = $MDWPRWM
|
||||
$l = $MDWOD
|
||||
$m = $MDWFMI
|
||||
$n = $MDWTI
|
||||
$o = $MDWCS
|
||||
$p = $MDWAS
|
||||
$q = $MDWFAS
|
||||
$r = $MDWPWCM
|
||||
$s = $MDIIM
|
||||
$t = $MDWTOI
|
||||
|
||||
$0x = "0x"
|
||||
|
||||
$array = @()
|
||||
|
||||
Clear-host
|
||||
write-host "Setting up your machine to receive Usermode Dumps via WER."
|
||||
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 "DumpCount" -Value "10" -PropertyType DWORD -Force
|
||||
|
||||
clear-host
|
||||
write-host "What would you like to do?"
|
||||
write-host "(0) Disable Dumps and restore system to factory."
|
||||
write-host "(1) Enable System for Full Dumps."
|
||||
write-host "(2) Enable System for Mini Dumps."
|
||||
write-host "(3) Enable System for custom dump with options."
|
||||
$NCD = Read-Host "Enter a number option"
|
||||
|
||||
If ($NCD -eq '3')
|
||||
{
|
||||
|
||||
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "0" -PropertyType DWORD -Force
|
||||
Do
|
||||
{
|
||||
clear-host
|
||||
write-host "Here are the optional custom dump to add to your custom dump parameters:"
|
||||
write-host "(1) Mini Dump Normal"
|
||||
write-host "(2) Mini Dump With Data Segs"
|
||||
write-host "(3) Mini Dump With Full Memory"
|
||||
write-host "(4) Mini Dump With Handle Data"
|
||||
write-host "(5) Mini Dump Filter Memory"
|
||||
write-host "(6) Mini Dump Scan Memory"
|
||||
write-host "(7) Mini Dump With Unloaded Modules"
|
||||
write-host "(8) Mini Dump With Indirectly Referenced"
|
||||
write-host "(9) Memory Mini Dump Filter Module Paths"
|
||||
write-host "(10) Mini Dump With Process Thread Data"
|
||||
write-host "(11) Mini Dump With Private Read Write Memory"
|
||||
write-host "(12) Mini Dump Without Optional Data"
|
||||
write-host "(13) Mini Dump With Full Memory Info"
|
||||
write-host "(14) Mini Dump With Thread Info"
|
||||
write-host "(15) Mini Dump With Code Segs"
|
||||
write-host "(16) Mini Dump Without Auxiliary State"
|
||||
write-host "(17) Mini Dump With Full Auxiliary State"
|
||||
write-host "(18) Mini Dump With Private Write Copy Memory"
|
||||
write-host "(19) Mini Dump Ignore Inaccessible Memory"
|
||||
write-host "(20) Mini Dump With Token Information"
|
||||
$Option = Read-Host "Enter one number value at a time and press enter. (Press 'q' when finished)"
|
||||
if($Option -eq '1')
|
||||
{
|
||||
$array += [int]$a
|
||||
}
|
||||
ElseIf($Option -eq '2')
|
||||
{
|
||||
$array += [int]$b
|
||||
}
|
||||
ElseIf($Option -eq '3')
|
||||
{
|
||||
$array += [int]$c
|
||||
}
|
||||
ElseIf($Option -eq '4')
|
||||
{
|
||||
$array += [int]$d
|
||||
}
|
||||
ElseIf($Option -eq '5')
|
||||
{
|
||||
$array += [int]$e
|
||||
}
|
||||
ElseIf($Option -eq '6')
|
||||
{
|
||||
$array += [int]$f
|
||||
}
|
||||
ElseIf($Option -eq '7')
|
||||
{
|
||||
$array += [int]$g
|
||||
}
|
||||
ElseIf($Option -eq '8')
|
||||
{
|
||||
$array += [int]$h
|
||||
}
|
||||
ElseIf($Option -eq '9')
|
||||
{
|
||||
$array += [int]$i
|
||||
}
|
||||
ElseIf($Option -eq '10')
|
||||
{
|
||||
$array += [int]$j
|
||||
}
|
||||
ElseIf($Option -eq '11')
|
||||
{
|
||||
$array += [int]$k
|
||||
}
|
||||
ElseIf($Option -eq '12')
|
||||
{
|
||||
$array += [int]$l
|
||||
}
|
||||
ElseIf($Option -eq '13')
|
||||
{
|
||||
$array += [int]$m
|
||||
}
|
||||
ElseIf($Option -eq '14')
|
||||
{
|
||||
$array += [int]$n
|
||||
}
|
||||
ElseIf($Option -eq '15')
|
||||
{
|
||||
$array += [int]$o
|
||||
}
|
||||
ElseIf($Option -eq '16')
|
||||
{
|
||||
$array += [int]$p
|
||||
}
|
||||
ElseIf($Option -eq '17')
|
||||
{
|
||||
$array += [int]$q
|
||||
}
|
||||
ElseIf($Option -eq '18')
|
||||
{
|
||||
$array += [int]$r
|
||||
}
|
||||
ElseIf($Option -eq '19')
|
||||
{
|
||||
$array += [int]$s
|
||||
}
|
||||
ElseIf($Option -eq '20')
|
||||
{
|
||||
$array += [int]$t
|
||||
}
|
||||
ElseIf($Option -eq 'q')
|
||||
{
|
||||
write-host "Closing application."
|
||||
Start-Sleep -s 2
|
||||
}
|
||||
Else
|
||||
{
|
||||
write-host "Invalid Option, Try again."
|
||||
Start-sleep -s 2
|
||||
}
|
||||
|
||||
}
|
||||
While($Option -ne "q")
|
||||
$sum = $array -join '+'
|
||||
$SumArray = Invoke-Expression $sum
|
||||
$FinalSum = $0x + $SumArray
|
||||
|
||||
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "CustomDumpFlags" -Value "$FinalSum" -PropertyType DWORD -Force
|
||||
|
||||
write-host " "
|
||||
write-host "Setting up the system for crash dumps requires a reboot"
|
||||
}
|
||||
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 "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 "CustomDumpFlags" -Force -ErrorAction SilentlyContinue
|
||||
write-host " "
|
||||
$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")
|
||||
{
|
||||
shutdown -r
|
||||
}
|
||||
Else
|
||||
{
|
||||
write-host "Please restart the machine for settings to take effect at your convenience."
|
||||
}
|
||||
}
|
||||
ElseIf ($NCD -eq '1')
|
||||
{
|
||||
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 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")
|
||||
{
|
||||
shutdown -r
|
||||
}
|
||||
Else
|
||||
{
|
||||
write-host "Please restart the machine for settings to take effect at your convenience."
|
||||
}
|
||||
}
|
||||
ElseIf ($NCD -eq '2')
|
||||
{
|
||||
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 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")
|
||||
{
|
||||
shutdown -r
|
||||
}
|
||||
Else
|
||||
{
|
||||
write-host "Please restart the machine for settings to take effect at your convenience."
|
||||
}
|
||||
}
|
||||
Else
|
||||
{
|
||||
write-host "You did not enter a valid option. Please re-run Get-Dump.ps1"
|
||||
start-sleep -s 5
|
||||
}
|
12
Scripts/init_git.ps1
Normal file
12
Scripts/init_git.ps1
Normal file
@ -0,0 +1,12 @@
|
||||
#
|
||||
|
||||
|
||||
$UserName = read-host "Your full name: "
|
||||
$UserEmail = read-host "Your email address: "
|
||||
$UserEditor = read-host "Your favorite editor (nano, vi, emacs): "
|
||||
|
||||
git config --global user.name $UserName
|
||||
git config --global user.email $UserEmail
|
||||
git config --global core.editor $UserEditor
|
||||
echo "Done."
|
||||
exit 0
|
22
Scripts/password.ps1
Executable file
22
Scripts/password.ps1
Executable file
@ -0,0 +1,22 @@
|
||||
# PowerShell Script to Create a New Password
|
||||
# ------------------------------------------
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
$CharsPerPassword = 15
|
||||
$MinCharCode = 33
|
||||
$MaxCharCode = 126
|
||||
|
||||
function new_password() {
|
||||
$password = ""
|
||||
$generator = New-Object System.Random
|
||||
for ($i = 0; $i -lt $CharsPerPassword; $i++) {
|
||||
$password = $password +[char]$generator.next($MinCharCode,$MaxCharCode)
|
||||
}
|
||||
return $password
|
||||
}
|
||||
|
||||
$password = new_password
|
||||
write-output $password
|
||||
exit 0
|
25
Scripts/passwords.ps1
Executable file
25
Scripts/passwords.ps1
Executable file
@ -0,0 +1,25 @@
|
||||
# PowerShell Script to Create New Passwords
|
||||
# -----------------------------------------
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
$NumPasswords = 20
|
||||
$CharsPerPassword = 15
|
||||
$MinCharCode = 33
|
||||
$MaxCharCode = 126
|
||||
|
||||
function new_password() {
|
||||
$password = ""
|
||||
$generator = New-Object System.Random
|
||||
for ($i = 0; $i -lt $CharsPerPassword; $i++) {
|
||||
$password = $password +[char]$generator.next($MinCharCode,$MaxCharCode)
|
||||
}
|
||||
return $password
|
||||
}
|
||||
|
||||
for ($j = 0; $j -lt $NumPasswords; $j++) {
|
||||
$password = new_password
|
||||
write-output $password
|
||||
}
|
||||
exit 0
|
10
Scripts/poweroff.ps1
Executable file
10
Scripts/poweroff.ps1
Executable file
@ -0,0 +1,10 @@
|
||||
# PowerShell Script to Shutdown the Local Computer
|
||||
# ------------------------------------------------
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
#
|
||||
# NOTE: Halts the local computer! Administrator rights might be needed!
|
||||
|
||||
Stop-Computer
|
||||
exit 0
|
10
Scripts/reboot.ps1
Executable file
10
Scripts/reboot.ps1
Executable file
@ -0,0 +1,10 @@
|
||||
# PowerShell Script to Reboot the Local Computer
|
||||
# ----------------------------------------------
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
#
|
||||
# NOTE: Reboots the local computer! Administrator rights might be needed.
|
||||
|
||||
Restart-Computer
|
||||
exit 0
|
11
Scripts/speak.ps1
Executable file
11
Scripts/speak.ps1
Executable file
@ -0,0 +1,11 @@
|
||||
# PowerShell Script for Text-To-Speech (TTS)
|
||||
# ------------------------------------------
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
$Text = "Hello World!"
|
||||
|
||||
$voice = New-Object ComObject SAPI.SPVoice
|
||||
$voice.Speak($Text);
|
||||
exit 0
|
8
Scripts/test.ps1
Executable file
8
Scripts/test.ps1
Executable file
@ -0,0 +1,8 @@
|
||||
# PowerShell Script for Testing
|
||||
# -----------------------------
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
write-output "PowerShell Works!"
|
||||
exit 0
|
36
Scripts/translate.ps1
Executable file
36
Scripts/translate.ps1
Executable file
@ -0,0 +1,36 @@
|
||||
# PowerShell Script for Translating Texts
|
||||
# ---------------------------------------
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
$SourceText = "Hello World!"
|
||||
$SourceLang = "en"
|
||||
$TargetLanguages = "af","da","de","el","es","hr","it","ja","ko","pl","pt","nl","ru","tr","uk","vi"
|
||||
|
||||
function TranslateWithGoogle {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Position = 1, ValueFromPipeline = $true)]
|
||||
[ValidateNotNullorEmpty()]
|
||||
[string]$Text,
|
||||
|
||||
[Parameter(Position = 2)]
|
||||
[ValidateNotNullorEmpty()]
|
||||
[string]$SourceLang,
|
||||
|
||||
[Parameter(Position = 3)]
|
||||
[ValidateNotNullorEmpty()]
|
||||
[string]$TargetLang
|
||||
)
|
||||
|
||||
$URL = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=$($SourceLang)&tl=$($TargetLang)&dt=t&q=$($Text)"
|
||||
$result = Invoke-RestMethod $URL
|
||||
return $result[0][0][0]
|
||||
}
|
||||
|
||||
foreach($TargetLang in $TargetLanguages) {
|
||||
$Result = TranslateWithGoogle $SourceText $SourceLang $TargetLang
|
||||
write-output $TargetLang" : "$Result
|
||||
}
|
||||
exit 0
|
20
Scripts/txt2wav.ps1
Executable file
20
Scripts/txt2wav.ps1
Executable file
@ -0,0 +1,20 @@
|
||||
# PowerShell Script to Convert Text to Audio WAV files
|
||||
# ----------------------------------------------------
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
# Configuration:
|
||||
$Text = "Hello, my name ist Bond, James Bond"
|
||||
$Speed = -1 # -10 is slowest, 10 is fastest
|
||||
$TargetWavFile = "spoken.wav"
|
||||
|
||||
# Run:
|
||||
Add-Type -AssemblyName System.Speech
|
||||
$SpeechSynthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
||||
# $SpeechSynthesizer.SelectVoice("Microsoft Eva Mobile")
|
||||
$SpeechSynthesizer.Rate = $Speed
|
||||
$SpeechSynthesizer.SetOutputToWaveFile($TargetWavFile)
|
||||
$SpeechSynthesizer.Speak($Text)
|
||||
$SpeechSynthesizer.Dispose()
|
||||
exit 0
|
59
Scripts/wakeup.ps1
Executable file
59
Scripts/wakeup.ps1
Executable file
@ -0,0 +1,59 @@
|
||||
# PowerShell Script to Wake-up Other Computers
|
||||
# --------------------------------------------
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
function Send-WOL
|
||||
{
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Send a WOL packet to a broadcast address
|
||||
.PARAMETER mac
|
||||
The MAC address of the device that need to wake up
|
||||
.PARAMETER ip
|
||||
The IP address where the WOL packet will be sent to
|
||||
.EXAMPLE
|
||||
Send-WOL -mac 00:11:32:21:2D:11 -ip 192.168.8.255
|
||||
.EXAMPLE
|
||||
Send-WOL -mac 00:11:32:21:2D:11
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$True,Position=1)]
|
||||
[string]$mac,
|
||||
[string]$ip="255.255.255.255",
|
||||
[int]$port=9
|
||||
)
|
||||
$broadcast = [Net.IPAddress]::Parse($ip)
|
||||
|
||||
$mac=(($mac.replace(":","")).replace("-","")).replace(".","")
|
||||
$target=0,2,4,6,8,10 | % {[convert]::ToByte($mac.substring($_,2),16)}
|
||||
$packet = (,[byte]255 * 6) + ($target * 16)
|
||||
|
||||
$UDPclient = new-Object System.Net.Sockets.UdpClient
|
||||
$UDPclient.Connect($broadcast,$port)
|
||||
[void]$UDPclient.Send($packet, 102)
|
||||
}
|
||||
|
||||
$Hostname = read-host "Enter hostname: "
|
||||
$MyMACAddresses = "io=11:22:33:44:55:66","pi=11:22:33:44:55:66"
|
||||
|
||||
foreach($item in $MyMACAddresses) {
|
||||
$array = $item.Split("=")
|
||||
$thisHost=$array[0]
|
||||
$thisMAC=$array[1]
|
||||
if ($thisHost -like $Hostname) {
|
||||
Send-WOL $thisMAC
|
||||
echo ""
|
||||
echo "OK - host $thisHost waked up (MAC $thisMAC)."
|
||||
echo ""
|
||||
pause
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
echo "Sorry, hostname $Hostname is unknown."
|
||||
pause
|
||||
exit 1
|
Reference in New Issue
Block a user