mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-12 06:02:56 +02:00
Updated some scripts
This commit is contained in:
@ -162,7 +162,7 @@ try {
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
Set-Location "$previousPath"
|
||||
exit 1
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ try {
|
||||
"✅ Built $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -48,6 +48,6 @@ try {
|
||||
"✅ Repo '$repoName' cleaned in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -49,6 +49,6 @@ try {
|
||||
"✅ Cleaned $numFolders Git repositories under 📂$parentDirName in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ try {
|
||||
"✅ Updates fetched into 📂$repoDirName repo in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -52,6 +52,6 @@ try {
|
||||
"✅ Installed $numInstalled basic apps ($numSkipped skipped) in $elapsed sec."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -44,6 +44,6 @@ try {
|
||||
"✅ Installed 20 snap apps in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -53,6 +53,6 @@ try {
|
||||
" (URL=http://$(hostname):$port media=$mediaFolder userDB=$userDB log=$logfile)."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
.EXAMPLE
|
||||
PS> ./install-edit.ps1
|
||||
⏳ Installing Microsoft Edit from Microsoft Store...
|
||||
✅ Microsoft Edit installed successfully in 25s.
|
||||
✅ Microsoft Edit installed successfully (took 25s).
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -28,9 +28,9 @@ try {
|
||||
if ($lastExitCode -ne 0) { throw "Can't install Microsoft Edit, is it already installed?" }
|
||||
}
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Microsoft Edit installed successfully in $($elapsed)s."
|
||||
"✅ Microsoft Edit installed successfully (took $($elapsed)s)."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -41,6 +41,6 @@ try {
|
||||
"✅ evcc installed successfully in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"Sorry: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -31,6 +31,6 @@ try {
|
||||
"✅ GitHub CLI installed successfully in $($elapsed)s - to authenticate execute: 'gh auth login'"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ try {
|
||||
"✅ installed Knot Resolver in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ try {
|
||||
|
||||
exit 0 # success
|
||||
} catch {
|
||||
Write-Output "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
Write-Output "⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -40,10 +40,10 @@ try {
|
||||
rm "signal-cli-$Version.tar.gz"
|
||||
if ($lastExitCode -ne 0) { throw "'rm' failed" }
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✅ installed signal-cli $Version to /opt and /usr/local/bin in $Elapsed sec"
|
||||
[int]$elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✅ Signal-cli $Version installed to /opt and /usr/local/bin in $elapsed sec."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Installs Skype
|
||||
.DESCRIPTION
|
||||
This PowerShell script installs Skype from the Microsoft Store.
|
||||
.EXAMPLE
|
||||
PS> ./install-skype.ps1
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
"Installing Skype, please wait..."
|
||||
|
||||
& winget install "Skype" --source msstore --accept-package-agreements --accept-source-agreements
|
||||
if ($lastExitCode -ne 0) { throw "'winget install' failed" }
|
||||
|
||||
"Skype installed successfully."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
@ -40,6 +40,6 @@ try {
|
||||
"✅ installed and started SSH server in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Installs Twitter
|
||||
.DESCRIPTION
|
||||
This PowerShell script installs Twitter from the Microsoft Store.
|
||||
.EXAMPLE
|
||||
PS> ./install-twitter.ps1
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
"Installing Twitter, please wait..."
|
||||
|
||||
& winget install "Twitter" --source msstore --accept-package-agreements --accept-source-agreements
|
||||
if ($lastExitCode -ne 0) { throw "'winget install' failed" }
|
||||
|
||||
"Twitter installed successfully."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"Sorry: $($Error[0])"
|
||||
exit 1
|
||||
}
|
@ -61,6 +61,6 @@ try {
|
||||
"✅ Installed Unbound in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -74,6 +74,6 @@ try {
|
||||
"✅ Updates installed in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ try {
|
||||
"Visual Studio Code installed successfully."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -55,6 +55,6 @@ try {
|
||||
"💡 Execute 'install-updates.ps1' to install the listed updates."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -65,6 +65,6 @@ try {
|
||||
"✅ Repo '$repoName' on new branch '$newBranch' (based on '$currentBranch', took $($elapsed)s)."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -27,6 +27,6 @@ try {
|
||||
"✅ New 📂$path created."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ try {
|
||||
Start-Process $URL
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -27,6 +27,6 @@ try {
|
||||
"✅ New junction '$junction' created, linking to: 📂$targetDir"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -26,6 +26,6 @@ try {
|
||||
"✅ New '$path' created (from data/templates/New.md)."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -26,6 +26,6 @@ try {
|
||||
"✅ New '$path' created (from data/templates/New.ps1)."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -28,6 +28,6 @@ try {
|
||||
"✅ Created new symlink '$symlink' linking to: $target"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ try {
|
||||
if ($lastExitCode -ne 0) { throw "Error: 'git push origin $TagName' failed!" }
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✅ created new tag '$TagName' in $Elapsed sec"
|
||||
"✅ Created new tag '$TagName' in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -29,6 +29,6 @@ try {
|
||||
"✅ Created user account '$username' with encrypted home directory in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -48,6 +48,6 @@ try {
|
||||
"✅ Repo '$dirName' updated in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -55,6 +55,6 @@ try {
|
||||
exit 1
|
||||
}
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
Specifies the file path to the directory tree
|
||||
.EXAMPLE
|
||||
PS> ./remove-dir.ps1 C:\Temp
|
||||
⏳ Removing 'C:\Temp'... (please wait)"
|
||||
⏳ Removing directory 'C:\Temp', please wait..."
|
||||
✅ Directory C:\Temp\ removed (took 9s).
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -20,16 +20,18 @@ param([string]$pathToDir = "")
|
||||
|
||||
try {
|
||||
if ($pathToDir -eq "" ) { $pathToDir = Read-Host "Enter the file path to the obsolete directory" }
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
"⏳ Removing '$pathToDir'... (please wait)"
|
||||
|
||||
Remove-Item -Force -Recurse -Confirm:$false $pathToDir
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
if (!(Test-Path "$pathToDir" -pathType container)) { throw "Cannot access directory '$pathToDir'" }
|
||||
|
||||
"⏳ Removing directory '$pathToDir', please wait..."
|
||||
Remove-Item -force -recurse -confirm:$false $pathToDir
|
||||
if ($lastExitCode -ne 0) { throw "'Remove-Item' failed with exit code $lastExitCode" }
|
||||
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Directory $pathToDir removed (took $($elapsed)s)."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
|
Reference in New Issue
Block a user