mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
2321c071ee
* Updated Edge Removal Script to the more up-to-date one. (#918) * Update edgeremoval.bat from the original source. * Added my modifications to the extra cleanup part * Updates credits for Edge Removal script * Removed "getfirefox" * Credit to the original source * Compile Winutil * fix typos (#924) * Compile Winutil * Remove ooshutup10 "Disable search box in task bar" (#929) * Compile Winutil * Fix Panel Glitch and add intl * Compile Winutil * Fix Bluetooth services * Compile Winutil * fix function --------- Co-authored-by: Antun Nitraj <antnitraj@gmail.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> Co-authored-by: AdamJedl <100023363+AdamJedl@users.noreply.github.com>
44 lines
1.5 KiB
PowerShell
44 lines
1.5 KiB
PowerShell
function Invoke-WinUtilScript {
|
|
<#
|
|
|
|
.DESCRIPTION
|
|
This function will run a separate powershell script. Meant for things that can't be handled with the other functions
|
|
|
|
.EXAMPLE
|
|
|
|
$Scriptblock = [scriptblock]::Create({"Write-output 'Hello World'"})
|
|
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name "Hello World"
|
|
|
|
#>
|
|
param (
|
|
$Name,
|
|
[scriptblock]$scriptblock
|
|
)
|
|
|
|
Try {
|
|
Write-Host "Running Script for $name"
|
|
Invoke-Command $scriptblock -ErrorAction Stop
|
|
}
|
|
Catch [System.Management.Automation.CommandNotFoundException] {
|
|
Write-Warning "The specified command was not found."
|
|
Write-Warning $PSItem.Exception.message
|
|
}
|
|
Catch [System.Management.Automation.RuntimeException] {
|
|
Write-Warning "A runtime exception occurred."
|
|
Write-Warning $PSItem.Exception.message
|
|
}
|
|
Catch [System.Security.SecurityException] {
|
|
Write-Warning "A security exception occurred."
|
|
Write-Warning $PSItem.Exception.message
|
|
}
|
|
Catch [System.UnauthorizedAccessException] {
|
|
Write-Warning "Access denied. You do not have permission to perform this operation."
|
|
Write-Warning $PSItem.Exception.message
|
|
}
|
|
Catch {
|
|
# Generic catch block to handle any other type of exception
|
|
Write-Warning "Unable to run script for $name due to unhandled exception"
|
|
Write-Warning $psitem.Exception.StackTrace
|
|
}
|
|
|
|
} |