mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-11 16:39:10 +01:00
Improved the scripts
This commit is contained in:
parent
47459e0139
commit
60eb59b52a
@ -24,7 +24,7 @@ for($i = 1; $i -lt $args.count; $i++){
|
|||||||
write-output $output
|
write-output $output
|
||||||
$null = New-NetFirewallRule -DisplayName $name -Direction Inbound -Program $path -Profile Domain, Private -Action Allow
|
$null = New-NetFirewallRule -DisplayName $name -Direction Inbound -Program $path -Profile Domain, Private -Action Allow
|
||||||
}
|
}
|
||||||
Write-Host -NoNewLine ''Done - press any key to continue...'';
|
write-host -foregroundColor green -noNewline ''Done - press any key to continue...'';
|
||||||
[void]$Host.UI.RawUI.ReadKey(''NoEcho,IncludeKeyDown'');
|
[void]$Host.UI.RawUI.ReadKey(''NoEcho,IncludeKeyDown'');
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ try {
|
|||||||
if ($ProcessCount -eq 0) {
|
if ($ProcessCount -eq 0) {
|
||||||
throw "$FullProgramName is not started yet"
|
throw "$FullProgramName is not started yet"
|
||||||
}
|
}
|
||||||
write-output "OK - $FullProgramName with $ProcessCount process(es) has been closed."
|
write-host -foregroundColor green "Done - $FullProgramName with $ProcessCount process(es) has been closed."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -33,7 +33,7 @@ try {
|
|||||||
git config --global core.autocrlf false
|
git config --global core.autocrlf false
|
||||||
git config --global core.symlinks true
|
git config --global core.symlinks true
|
||||||
git config --global init.defaultBranch main
|
git config --global init.defaultBranch main
|
||||||
write-output "OK - your Git user configuration is now:"
|
write-host -foregroundColor green "Done - your Git user configuration is now:"
|
||||||
git config --list
|
git config --list
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -161,7 +161,7 @@ try {
|
|||||||
|
|
||||||
$PasswordBase64 = [System.Convert]::ToBase64String($Password)
|
$PasswordBase64 = [System.Convert]::ToBase64String($Password)
|
||||||
DecryptFile "$Path" -algorithm AES -keyAsPlainText $PasswordBase64 -removeSource
|
DecryptFile "$Path" -algorithm AES -keyAsPlainText $PasswordBase64 -removeSource
|
||||||
write-output "OK."
|
write-host -foregroundColor green "Done."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -14,7 +14,8 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent $URL --directory-prefix . --no-verbose
|
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent $URL --directory-prefix . --no-verbose
|
||||||
write-output "OK."
|
|
||||||
|
write-host -foregroundColor green "Done."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -145,7 +145,8 @@ try {
|
|||||||
|
|
||||||
$PasswordBase64 = [System.Convert]::ToBase64String($Password)
|
$PasswordBase64 = [System.Convert]::ToBase64String($Password)
|
||||||
EnryptFile "$Path" -Algorithm AES -KeyAsPlainText $PasswordBase64 -RemoveSource
|
EnryptFile "$Path" -Algorithm AES -KeyAsPlainText $PasswordBase64 -RemoveSource
|
||||||
write-output "OK."
|
|
||||||
|
write-host -foregroundColor green "Done."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -28,7 +28,8 @@ try {
|
|||||||
"&size=" + $ImageSize + "&qzone=" + $QuietZone + `
|
"&size=" + $ImageSize + "&qzone=" + $QuietZone + `
|
||||||
"&color=" + $ForegroundColor + "&bgcolor=" + $BackgroundColor.Text + `
|
"&color=" + $ForegroundColor + "&bgcolor=" + $BackgroundColor.Text + `
|
||||||
"&format=" + $FileFormat), $NewFile)
|
"&format=" + $FileFormat), $NewFile)
|
||||||
write-output "OK - QR code has been written to $NewFile"
|
|
||||||
|
write-host -foregroundColor green "Done - QR code has been written to $NewFile"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -17,9 +17,7 @@ try {
|
|||||||
|
|
||||||
echo ------------------------------------------------------------------------------
|
echo ------------------------------------------------------------------------------
|
||||||
echo.
|
echo.
|
||||||
echo DONE - synced to %DST_DIR%
|
write-host -foregroundColor green "Done - synced to %DST_DIR%"
|
||||||
echo.
|
|
||||||
pause
|
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
try {
|
try {
|
||||||
$obj = new-object -com wscript.shell
|
$obj = new-object -com wscript.shell
|
||||||
$obj.SendKeys([char]173)
|
$obj.SendKeys([char]173)
|
||||||
write-output "OK"
|
|
||||||
|
write-host -foregroundColor green "Done."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -47,7 +47,7 @@ try {
|
|||||||
Invoke-Expression $Cmd > $Filename
|
Invoke-Expression $Cmd > $Filename
|
||||||
$DevInfo++
|
$DevInfo++
|
||||||
}
|
}
|
||||||
write-output "DONE."
|
write-host -foregroundColor green "Done."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -31,7 +31,7 @@ try {
|
|||||||
$Stream.Close()
|
$Stream.Close()
|
||||||
$Socket.Close()
|
$Socket.Close()
|
||||||
|
|
||||||
write-output "Done."
|
write-host -foregroundColor green "Done."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -26,7 +26,7 @@ try {
|
|||||||
$EncodedText = [Text.Encoding]::ASCII.GetBytes($Message)
|
$EncodedText = [Text.Encoding]::ASCII.GetBytes($Message)
|
||||||
$SendMessage = $Socket.Send($EncodedText, $EncodedText.Length, $EndPoints)
|
$SendMessage = $Socket.Send($EncodedText, $EncodedText.Length, $EndPoints)
|
||||||
$Socket.Close()
|
$Socket.Close()
|
||||||
write-output "Done."
|
write-host -foregroundColor green "Done."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -18,7 +18,7 @@ try {
|
|||||||
./write-big "T-$i seconds"
|
./write-big "T-$i seconds"
|
||||||
start-sleep -s 1
|
start-sleep -s 1
|
||||||
}
|
}
|
||||||
write-output "OK - $Seconds seconds countdown finished"
|
write-host -foregroundColor green "Done - $Seconds seconds countdown finished"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -20,7 +20,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$Result = Invoke-RestMethod "http://$($IPaddr)/relay/0?turn=$($TurnMode)&timer=$($Timer)"
|
$Result = Invoke-RestMethod "http://$($IPaddr)/relay/0?turn=$($TurnMode)&timer=$($Timer)"
|
||||||
write-output "OK - switched Shelly1 device at $IPaddr to $TurnMode for $Timer second(s)"
|
write-host -foregroundColor green "Done - switched Shelly1 device at $IPaddr to $TurnMode for $Timer second(s)"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -25,7 +25,7 @@ try {
|
|||||||
$Count = $Table.Length
|
$Count = $Table.Length
|
||||||
$StopTime = Get-Date
|
$StopTime = Get-Date
|
||||||
$TimeInterval = New-Timespan -start $StartTime -end $StopTime
|
$TimeInterval = New-Timespan -start $StartTime -end $StopTime
|
||||||
write-output "OK - DNS cache trained with $Count domain names in $TimeInterval seconds"
|
write-host -foregroundColor green "Done - DNS cache trained with $Count domain names in $TimeInterval seconds"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -13,7 +13,7 @@ try {
|
|||||||
for ([int]$i = 0; $i -lt $Percent; $i += 2) {
|
for ([int]$i = 0; $i -lt $Percent; $i += 2) {
|
||||||
$obj.SendKeys([char]174) # each tick is -2%
|
$obj.SendKeys([char]174) # each tick is -2%
|
||||||
}
|
}
|
||||||
write-output "OK"
|
write-host -foregroundColor green "Done."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -13,7 +13,7 @@ try {
|
|||||||
for ([int]$i = 0; $i -lt $Percent; $i += 2) {
|
for ([int]$i = 0; $i -lt $Percent; $i += 2) {
|
||||||
$obj.SendKeys([char]175) # each tick is +2%
|
$obj.SendKeys([char]175) # each tick is +2%
|
||||||
}
|
}
|
||||||
write-output "OK"
|
write-host -foregroundColor green "Done."
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
try {
|
try {
|
||||||
$obj = new-object -com wscript.shell
|
$obj = new-object -com wscript.shell
|
||||||
$obj.SendKeys([char]173)
|
$obj.SendKeys([char]173)
|
||||||
write-output "OK"
|
write-host -foregroundColor green "Done"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -32,7 +32,7 @@ try {
|
|||||||
start-sleep -milliseconds 100
|
start-sleep -milliseconds 100
|
||||||
Send-WOL $MACaddress $IPaddress
|
Send-WOL $MACaddress $IPaddress
|
||||||
|
|
||||||
write-output "OK - magic packet sent twice to IP $IPaddress (MAC $MACaddress)"
|
write-host -foregroundColor green "Done - magic packet sent twice to IP $IPaddress (MAC $MACaddress)"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
.NOTES Author: Markus Fleschutz / License: CC0
|
.NOTES Author: Markus Fleschutz / License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([string]$Directory = "")
|
param($Directory = "")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($Directory -eq "" ) {
|
if ($Directory -eq "" ) {
|
||||||
@ -14,7 +14,8 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compress-archive -path $Directory -destinationPath $Directory.zip
|
compress-archive -path $Directory -destinationPath $Directory.zip
|
||||||
write-output "OK - created zip archive $($Directory).zip"
|
|
||||||
|
write-host -foregroundColor green "Done - created zip archive $($Directory).zip"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user