"Invoke-Repair" Function feature request

Exactly what I do.

For example:

#region INSTALLATION
#   ________________
#┌─┤ INSTALLATION ► ├────────────────────────────────────┐
#   ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
[ScriptBlock]$InstallScriptBlock = {
	$installPhase = "Pre-Installation"

	# < Commands >

#├───────────────────────────────────────────────────────┤

	$installPhase = "Installation"

	# < Commands >

#├───────────────────────────────────────────────────────┤

	$installPhase = "Post-Installation"

	# < Commands >
}
#└───────────────────────────────────────────────────────┘
#endregion
#region UNINSTALLATION
#   __________________
#┌─┤ UNINSTALLATION ► ├──────────────────────────────────┐
#   ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
[ScriptBlock]$UninstallScriptBlock = {
	$installPhase = "Pre-Uninstallation"

	# < Commands >

#├───────────────────────────────────────────────────────┤

	$installPhase = "Uninstallation"

	# < Commands >

#├───────────────────────────────────────────────────────┤

	$installPhase = "Post-Uninstallation"

	# < Commands >
}
#└───────────────────────────────────────────────────────┘
#endregion
#region REPAIR
#   __________
#┌─┤ REPAIR ► ├──────────────────────────────────────────┐
#   ‾‾‾‾‾‾‾‾‾‾
[ScriptBlock]$RepairScriptBlock = {
	$installPhase = "Pre-Repair"

	# < Commands >

#├───────────────────────────────────────────────────────┤

	$installPhase = "Repair"

	#▌Invokes the uninstallation commands
	Invoke-Command -ScriptBlock $UninstallScriptBlock -NoNewScope

	#▌Invokes the installation commands
	Invoke-Command -ScriptBlock $InstallScriptBlock -NoNewScope
		
#├───────────────────────────────────────────────────────┤

	$installPhase = "Post-Repair"

	# < Comandos >
}
#└───────────────────────────────────────────────────────┘
#endregion
# ▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲

if ($deploymentType -ine "Uninstall" -and $deploymentType -ine "Repair") { Invoke-Command -ScriptBlock $InstallScriptBlock -NoNewScope }
elseif ($deploymentType -ieq "Uninstall") { Invoke-Command -ScriptBlock $UninstallScriptBlock -NoNewScope }
elseif ($deploymentType -ieq "Repair") { Invoke-Command -ScriptBlock $RepairScriptBlock -NoNewScope }
4 Likes