mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 16:03:22 +01:00
Cleanup
This commit is contained in:
parent
4cb019eee0
commit
94106839fd
@ -7,15 +7,14 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$File)
|
||||
if ($File -eq "" ) {
|
||||
$File = read-host "Enter file"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($File -eq "" ) {
|
||||
$File = read-host "Enter path to file"
|
||||
}
|
||||
$Result = get-filehash $File -algorithm MD5
|
||||
write-host "✔️ MD5 hash is" $Result.Hash
|
||||
write-output "MD5 hash is" $Result.Hash
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,15 +7,15 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$File)
|
||||
if ($File -eq "" ) {
|
||||
$File = read-host "Enter file"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($File -eq "" ) {
|
||||
$File = read-host "Enter file"
|
||||
}
|
||||
|
||||
$Result = get-filehash $File -algorithm SHA1
|
||||
write-host "✔️ SHA1 hash is" $Result.Hash
|
||||
write-output "SHA1 hash is" $Result.Hash
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,15 +7,15 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$File)
|
||||
if ($File -eq "" ) {
|
||||
$File = read-host "Enter file"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($File -eq "" ) {
|
||||
$File = read-host "Enter file"
|
||||
}
|
||||
|
||||
$Result = get-filehash $File -algorithm SHA256
|
||||
write-host "✔️ SHA256 hash is" $Result.Hash
|
||||
write-output "SHA256 hash is:" $Result.Hash
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ try {
|
||||
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ try {
|
||||
exit 0
|
||||
}
|
||||
} catch {
|
||||
write-warning "$($MyInvocation.MyCommand.Name) - Error: $($_.Exception.Message) - Line Number: $($_.InvocationInfo.ScriptLineNumber)"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
write-host "Done."
|
||||
write-output "Done."
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ try {
|
||||
git config --global user.email $UserEmail
|
||||
git config --global core.editor $UserEditor
|
||||
git config --global init.defaultBranch main
|
||||
echo "Done."
|
||||
write-output "Done."
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -21,6 +21,6 @@ try {
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ try {
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ try {
|
||||
}
|
||||
|
||||
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent $URL --directory-prefix . --no-verbose
|
||||
Write-Output "OK."
|
||||
write-output "OK."
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,15 +7,14 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$File)
|
||||
if ($File -eq "" ) {
|
||||
$File = read-host "Enter path to executable file"
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if ($File -eq "" ) {
|
||||
$File = read-host "Enter path to executable file"
|
||||
}
|
||||
get-childitem $File | % {$_.VersionInfo} | Select *
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -56,6 +56,6 @@ try {
|
||||
GetPermutations -String $Word | Format-Wide -Column $Columns
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ try {
|
||||
Get-Command -Command-Type cmdlet
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ $MinMagnitude=6.0
|
||||
$OrderBy="time" # time, time-asc, magnitude, magnitude-asc
|
||||
|
||||
try {
|
||||
Write-Progress "Querying earthquakes for the last 30 days ..."
|
||||
write-progress "Querying earthquakes for the last 30 days ..."
|
||||
(Invoke-WebRequest -Uri "https://earthquake.usgs.gov/fdsnws/event/1/query?format=$Format&minmagnitude=$MinMagnitude&orderby=$OrderBy" -UserAgent "curl" ).Content
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -8,13 +8,12 @@
|
||||
|
||||
param([string]$DirTree)
|
||||
|
||||
write-host "Listing empty subfolders in $DirTree ..."
|
||||
|
||||
try {
|
||||
write-progress "Listing empty subfolders in $DirTree ..."
|
||||
(Get-ChildItem $DirTree -recurse | ? {$_.PSIsContainer -eq $True}) | ?{$_.GetFileSystemInfos().Count -eq 0} | select FullName
|
||||
echo "Done."
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ try {
|
||||
Get-Module
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ try {
|
||||
Get-Process | Format-Table -Property Id, @{Label="CPU(s)";Expression={$_.CPU.ToString("N")+"%"};Alignment="Right"}, ProcessName -AutoSize
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ try {
|
||||
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ if ($City -eq "" ) {
|
||||
|
||||
try {
|
||||
write-progress "Reading worldcities.csv..."
|
||||
$PathToData=(get-item $MyInvocation.MyCommand.Path).directory
|
||||
$PathToData="$PathToData/../Data"
|
||||
$Table = import-csv "$PathToData/worldcities.csv"
|
||||
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
|
||||
$Table = import-csv "$PathToRepo/Data/worldcities.csv"
|
||||
|
||||
$FoundOne = 0
|
||||
foreach($Row in $Table) {
|
||||
if ($Row.city -eq $City) {
|
||||
@ -35,6 +35,6 @@ try {
|
||||
write-error "City $City not found"
|
||||
exit 1
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,15 +7,14 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$IPaddr)
|
||||
if ($IPaddr -eq "" ) {
|
||||
$IPaddr = read-host "Enter IP address to locate"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($IPaddr -eq "" ) {
|
||||
$IPaddr = read-host "Enter IP address to locate"
|
||||
}
|
||||
$result = Invoke-RestMethod -Method Get -Uri "http://ip-api.com/json/$IPaddr"
|
||||
write-host $result
|
||||
write-output $result
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,18 +7,18 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$CountryCode, [string]$ZipCode)
|
||||
if ($CountryCode -eq "" ) {
|
||||
$CountryCode = read-host "Enter the country code"
|
||||
}
|
||||
if ($ZipCode -eq "" ) {
|
||||
$ZipCode = read-host "Enter the zip code"
|
||||
}
|
||||
$PathToDataDir=(get-item $MyInvocation.MyCommand.Path).directory
|
||||
$PathToDataDir="$PathToDataDir/../Data"
|
||||
|
||||
|
||||
try {
|
||||
if ($CountryCode -eq "" ) {
|
||||
$CountryCode = read-host "Enter the country code"
|
||||
}
|
||||
if ($ZipCode -eq "" ) {
|
||||
$ZipCode = read-host "Enter the zip code"
|
||||
}
|
||||
|
||||
write-progress "Reading zip-codes.csv..."
|
||||
$Table = import-csv "$PathToDataDir/zip-codes.csv"
|
||||
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
|
||||
$Table = import-csv "$PathToRepo/Data/zip-codes.csv"
|
||||
|
||||
$FoundOne = 0
|
||||
foreach($Row in $Table) {
|
||||
@ -28,7 +28,7 @@ try {
|
||||
$City = $Row.city
|
||||
$Lat = $Row.latitude
|
||||
$Lon = $Row.longitude
|
||||
write-host "* $Country $ZipCode $City is at $Lat°N, $Lon°W"
|
||||
write-output "* $Country $ZipCode $City is at $Lat°N, $Lon°W"
|
||||
$FoundOne = 1
|
||||
}
|
||||
}
|
||||
@ -40,6 +40,6 @@ try {
|
||||
write-error "Zip-code $ZipCode in country $CountryCode not found"
|
||||
exit 1
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -21,6 +21,6 @@ try {
|
||||
pause
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ try {
|
||||
(Invoke-WebRequest http://wttr.in/Moon -UserAgent "curl" ).Content
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,15 +7,14 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$emailAddress)
|
||||
if ($emailAddress -eq "" ) {
|
||||
$emailAddress = "markus@fleschutz.de"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($emailAddress -eq "" ) {
|
||||
$emailAddress = "markus@fleschutz.de"
|
||||
}
|
||||
$URL="mailto:$emailAddress"
|
||||
Start-Process $URL
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -13,15 +13,15 @@ $RSS_URL = "https://yahoo.com/news/rss/world"
|
||||
try {
|
||||
[xml]$FileContent = (Invoke-WebRequest -Uri $RSS_URL).Content
|
||||
|
||||
write-host ""
|
||||
write-host "+++ " $FileContent.rss.channel.title " +++"
|
||||
write-host ""
|
||||
write-output ""
|
||||
write-output "+++ " $FileContent.rss.channel.title " +++"
|
||||
write-output ""
|
||||
|
||||
foreach ($item in $FileContent.rss.channel.item) {
|
||||
write-host "*" $item.title
|
||||
write-output "*" $item.title
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,14 +7,13 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$URL)
|
||||
if ($URL -eq "" ) {
|
||||
$URL = "http://www.fleschutz.de"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($URL -eq "" ) {
|
||||
$URL = "http://www.fleschutz.de"
|
||||
}
|
||||
Start-Process $URL
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ try {
|
||||
Start-Process "mailto:markus@fleschutz.de"
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ try {
|
||||
Stop-Computer
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ try {
|
||||
Restart-Computer
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -13,14 +13,14 @@ $ErrorActionPreference= "silentlycontinue"
|
||||
|
||||
foreach($add in $range) {
|
||||
$ip = "{0}.{1}" -F $network,$add
|
||||
Write-Progress "Scanning IP $ip" -PercentComplete (($add/$range.Count)*100)
|
||||
write-progress "Scanning IP $ip" -PercentComplete (($add/$range.Count)*100)
|
||||
if (Test-Connection -BufferSize 32 -Count 1 -quiet -ComputerName $ip) {
|
||||
$socket = new-object System.Net.Sockets.TcpClient($ip, $port)
|
||||
if ($socket.Connected) {
|
||||
write-host "TCP port $port at $ip is open"
|
||||
write-output "TCP port $port at $ip is open"
|
||||
$socket.Close()
|
||||
} else {
|
||||
write-host "TCP port $port at $ip is not open"
|
||||
write-output "TCP port $port at $ip is not open"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,6 @@ try {
|
||||
$smtp.Send($msg)
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -8,17 +8,17 @@
|
||||
|
||||
param([string]$TargetIP, [int]$TargetPort, [string]$Message)
|
||||
|
||||
if ($TargetIP -eq "" ) {
|
||||
$TargetIP = read-host "Enter target IP address"
|
||||
}
|
||||
if ($TargetPort -eq 0 ) {
|
||||
$TargetPort = read-host "Enter target port"
|
||||
}
|
||||
if ($Message -eq "" ) {
|
||||
$Message = read-host "Enter message to send"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($TargetIP -eq "" ) {
|
||||
$TargetIP = read-host "Enter target IP address"
|
||||
}
|
||||
if ($TargetPort -eq 0 ) {
|
||||
$TargetPort = read-host "Enter target port"
|
||||
}
|
||||
if ($Message -eq "" ) {
|
||||
$Message = read-host "Enter message to send"
|
||||
}
|
||||
|
||||
$IP = [System.Net.Dns]::GetHostAddresses($TargetIP)
|
||||
$Address = [System.Net.IPAddress]::Parse($IP)
|
||||
$Socket = New-Object System.Net.Sockets.TCPClient($Address,$TargetPort)
|
||||
@ -31,9 +31,9 @@ try {
|
||||
$Stream.Close()
|
||||
$Socket.Close()
|
||||
|
||||
echo "Done."
|
||||
write-output "Done."
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -8,17 +8,17 @@
|
||||
|
||||
param([string]$TargetIP, [int]$TargetPort, [string]$Message)
|
||||
|
||||
if ($TargetIP -eq "" ) {
|
||||
$TargetIP = read-host "Enter target IP address"
|
||||
}
|
||||
if ($TargetPort -eq 0 ) {
|
||||
$TargetPort = read-host "Enter target port"
|
||||
}
|
||||
if ($Message -eq "" ) {
|
||||
$Message = read-host "Enter message to send"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($TargetIP -eq "" ) {
|
||||
$TargetIP = read-host "Enter target IP address"
|
||||
}
|
||||
if ($TargetPort -eq 0 ) {
|
||||
$TargetPort = read-host "Enter target port"
|
||||
}
|
||||
if ($Message -eq "" ) {
|
||||
$Message = read-host "Enter message to send"
|
||||
}
|
||||
|
||||
$IP = [System.Net.Dns]::GetHostAddresses($TargetIP)
|
||||
$Address = [System.Net.IPAddress]::Parse($IP)
|
||||
$EndPoints = New-Object System.Net.IPEndPoint($Address, $TargetPort)
|
||||
@ -26,9 +26,9 @@ try {
|
||||
$EncodedText = [Text.Encoding]::ASCII.GetBytes($Message)
|
||||
$SendMessage = $Socket.Send($EncodedText, $EncodedText.Length, $EndPoints)
|
||||
$Socket.Close()
|
||||
echo "Done."
|
||||
write-output "Done."
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ try {
|
||||
write-progress "$i seconds"
|
||||
start-sleep -s 1
|
||||
}
|
||||
write-host "OK - $Seconds seconds countdown finished"
|
||||
write-output "OK - $Seconds seconds countdown finished"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -7,9 +7,9 @@
|
||||
# License: CC0
|
||||
|
||||
try {
|
||||
$PathToData=(get-item $MyInvocation.MyCommand.Path).directory
|
||||
$PathToData="$PathToData/../Data"
|
||||
$Table = import-csv "$PathToData/Matrix.csv"
|
||||
write-progress "Reading Matrix.csv..."
|
||||
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
|
||||
$Table = import-csv "$PathToRepo/Data/Matrix.csv"
|
||||
|
||||
Clear-Host
|
||||
foreach($Row in $Table) {
|
||||
@ -46,6 +46,6 @@ try {
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,17 +7,16 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$File)
|
||||
if ($File -eq "") {
|
||||
$File = read-host "Enter path to file"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($File -eq "") {
|
||||
$File = read-host "Enter path to file"
|
||||
}
|
||||
$Text = Get-Content $File
|
||||
|
||||
$voice = New-Object ComObject SAPI.SPVoice
|
||||
$voice.Speak($Text);
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,15 +7,15 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$Text)
|
||||
if ($Text -eq "") {
|
||||
$Text = "Hello World!"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($Text -eq "") {
|
||||
$Text = read-host "Enter text to speak"
|
||||
}
|
||||
|
||||
$voice = New-Object ComObject SAPI.SPVoice
|
||||
$voice.Speak($Text);
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ Function Get-TimedScreenshot {
|
||||
#run screenshot function
|
||||
GenScreenshot
|
||||
|
||||
Write-Verbose "Saved screenshot to $FilePath. Sleeping for $Interval seconds"
|
||||
write-verbose "Saved screenshot to $FilePath. Sleeping for $Interval seconds"
|
||||
|
||||
Start-Sleep -Seconds $Interval
|
||||
}
|
||||
@ -93,6 +93,6 @@ Function Get-TimedScreenshot {
|
||||
While ((Get-Date -Format HH:%m) -lt $EndTime)
|
||||
}
|
||||
|
||||
Catch {Write-Warning "$Error[0].ToString() + $Error[0].InvocationInfo.PositionMessage"}
|
||||
Catch {write-error "$Error[0].ToString() + $Error[0].InvocationInfo.PositionMessage"}
|
||||
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ Function Get-TimedScreenshot {
|
||||
#run screenshot function
|
||||
GenScreenshot
|
||||
|
||||
Write-Verbose "Saved screenshot to $FilePath. Sleeping for $Interval seconds"
|
||||
write-verbose "Saved screenshot to $FilePath. Sleeping for $Interval seconds"
|
||||
|
||||
Start-Sleep -Seconds $Interval
|
||||
}
|
||||
@ -93,6 +93,6 @@ Function Get-TimedScreenshot {
|
||||
While ((Get-Date -Format HH:%m) -lt $EndTime)
|
||||
}
|
||||
|
||||
Catch {Write-Warning "$Error[0].ToString() + $Error[0].InvocationInfo.PositionMessage"}
|
||||
Catch {write-error "$Error[0].ToString() + $Error[0].InvocationInfo.PositionMessage"}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ try {
|
||||
echo $PSVersionTable
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -9,22 +9,21 @@
|
||||
try {
|
||||
$StartTime = Get-Date
|
||||
|
||||
$PathToData=(get-item $MyInvocation.MyCommand.Path).directory
|
||||
$PathToData="$PathToData/../Data"
|
||||
$Table = import-csv "$PathToData/domain_table.csv"
|
||||
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
|
||||
$Table = import-csv "$PathToRepo/Data/domain_table.csv"
|
||||
|
||||
foreach($Row in $Table) {
|
||||
$Domain = $Row.Domain
|
||||
Write-Progress "Training DNS cache with $Domain..."
|
||||
write-progress "Training DNS cache with $Domain..."
|
||||
$Ignore = nslookup $Domain
|
||||
}
|
||||
|
||||
$Count = $Table.Length
|
||||
$StopTime = Get-Date
|
||||
$TimeInterval = New-Timespan -start $StartTime -end $StopTime
|
||||
Write-Output "OK - DNS cache trained with $Count domain names in $TimeInterval seconds"
|
||||
write-output "OK - DNS cache trained with $Count domain names in $TimeInterval seconds"
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,22 +7,22 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$SourceFile, [string]$SourceLanguage, [string]$TargetLanguage)
|
||||
if ($SourceFile -eq "" ) {
|
||||
$SourceFile = read-host "Enter path to file"
|
||||
}
|
||||
if ($SourceLanguage -eq "" ) {
|
||||
$SourceLanguage = read-host "Enter language of this file"
|
||||
}
|
||||
if ($TargetLanguage -eq "" ) {
|
||||
$TargetLanguage = read-host "Enter language to translate to"
|
||||
}
|
||||
|
||||
try {
|
||||
$PathToData=(get-item $MyInvocation.MyCommand.Path).directory
|
||||
$PathToData="$PathToData/../Data"
|
||||
Start-Process -FilePath "$PathToData/trans" -ArgumentList "-i $SourceFile -s $SourceLanguage -t $TargetLanguage -e google -brief" -NoNewWindow -Wait
|
||||
if ($SourceFile -eq "" ) {
|
||||
$SourceFile = read-host "Enter path to file"
|
||||
}
|
||||
if ($SourceLanguage -eq "" ) {
|
||||
$SourceLanguage = read-host "Enter language of this file"
|
||||
}
|
||||
if ($TargetLanguage -eq "" ) {
|
||||
$TargetLanguage = read-host "Enter language to translate to"
|
||||
}
|
||||
|
||||
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
|
||||
|
||||
Start-Process -FilePath "$PathToRepo/Data/trans" -ArgumentList "-i $SourceFile -s $SourceLanguage -t $TargetLanguage -e google -brief" -NoNewWindow -Wait
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -41,6 +41,6 @@ try {
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ try {
|
||||
$SpeechSynthesizer.Dispose()
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -53,15 +53,15 @@ try {
|
||||
$thisMAC=$array[1]
|
||||
if ($thisHost -like $Hostname) {
|
||||
Send-WOL $thisMAC
|
||||
write-output "✔️ host $thisHost waked up (MAC $thisMAC)"
|
||||
write-output "OK - host $thisHost waked up (MAC $thisMAC)"
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
echo "Sorry, hostname $Hostname is unknown."
|
||||
write-output "Sorry, hostname $Hostname is unknown."
|
||||
pause
|
||||
exit 1
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -34,6 +34,6 @@ try {
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ try {
|
||||
(Invoke-WebRequest http://v2d.wttr.in/$GeoLocation -UserAgent "curl" ).Content
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -19,6 +19,6 @@ try {
|
||||
write-output ""
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ try {
|
||||
(Invoke-WebRequest http://wttr.in/$GeoLocation -UserAgent "curl" ).Content
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -15,14 +15,12 @@ $Speed = 250 # milliseconds
|
||||
try {
|
||||
$Random = New-Object System.Random
|
||||
|
||||
$Text -split '' |
|
||||
ForEach-Object {
|
||||
Write-Host -nonewline $_
|
||||
Start-Sleep -milliseconds $(1 + $Random.Next($Speed))
|
||||
}
|
||||
|
||||
$Text -split '' | ForEach-Object {
|
||||
Write-Host -nonewline $_
|
||||
Start-Sleep -milliseconds $(1 + $Random.Next($Speed))
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -7,14 +7,14 @@
|
||||
# License: CC0
|
||||
|
||||
param([string]$Path)
|
||||
if ($Path -eq "" ) {
|
||||
$URL = read-host "Enter path to folder to zip"
|
||||
}
|
||||
|
||||
try {
|
||||
if ($Path -eq "" ) {
|
||||
$URL = read-host "Enter path to folder to zip"
|
||||
}
|
||||
|
||||
Compress-Archive -Path $Path -DestinationPath $Path.zip
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user