mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 21:07:40 +02:00
Updated clean-repo.ps1 and kill-process.ps1
This commit is contained in:
@ -22,6 +22,8 @@
|
||||
param([string]$path = "$PWD")
|
||||
|
||||
try {
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
Write-Host "⏳ (1/4) Searching for Git executable... " -noNewline
|
||||
& git --version
|
||||
if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
@ -42,7 +44,8 @@ try {
|
||||
& git -C "$path" submodule foreach --recursive git clean -xfd -f # to delete all untracked files in the submodules
|
||||
if ($lastExitCode -ne 0) { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
|
||||
|
||||
"✅ Repo '$repoName' is clean now."
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Repo '$repoName' cleaned in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -1,35 +1,26 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Kills all local processes matching the given name
|
||||
Kills local processes
|
||||
.DESCRIPTION
|
||||
← enter a detailed description of the script here
|
||||
.PARAMETER
|
||||
← enter the description of a parameter here (repeat the .PARAMETER for each parameter)
|
||||
This PowerShell script stops all local processes matching the given name
|
||||
.PARAMETER processName
|
||||
Specifies the process name (ask user by default)
|
||||
.EXAMPLE
|
||||
← enter a sample command that uses the script, optionally followed by sample output and a description (repeat the .EXAMPLE for each example)
|
||||
.NOTES
|
||||
Author: ← enter full name here
|
||||
License: ← enter license here
|
||||
PS> ./kill-process.ps1
|
||||
.LINK
|
||||
← enter URL to additional information here
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
# [Parameter(Mandatory,ParameterSetName='ByProcessName')]
|
||||
[string]$ProcessName = $(Read-Host -Prompt 'Enter the process name'))
|
||||
|
||||
function KillProcesses {
|
||||
Write-Host -BackgroundColor Yellow -ForegroundColor Red "Process to kill: $ProcessName"
|
||||
Get-Process | Where-Object -FilterScript {$_.processname -eq $ProcessName} | Select-Object id | Stop-Process
|
||||
}
|
||||
|
||||
param([string]$processName = "")
|
||||
|
||||
try {
|
||||
KillProcesses -ProcessName $processName
|
||||
if ($processName -eq "") { $processName = Read-Host "Enter the process name" }
|
||||
Get-Process | Where-Object -FilterScript {$_.processname -eq $processName} | Select-Object id | Stop-Process
|
||||
"✔️ Done."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
Reference in New Issue
Block a user