Functions/StreamDeck/Uninstall-StreamDeckPlugin.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
function Uninstall-StreamDeckPlugin { <# .SYNOPSIS Uninstalls StreamDeck Plugins .DESCRIPTION Uninstalls StreamDeck Plugins. StreamDeck must not be running when this command is run. .EXAMPLE Uninstall-StreamDeckPlugin ScriptDeck .EXAMPLE Uninstall-StreamDeckPlugin WindowsScriptDeck .LINK Stop-StreamDeck .LINK Install-StreamDeckPlugin #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')] param( # The name of the plugin [Parameter(ValueFromPipelineByPropertyName)] [string] $Name, # The Plugin UUID [Parameter(ParameterSetName='Plugin',ValueFromPipelineByPropertyName)] [string] $UUID, # If set, will rebuild the cache of streamdeck plugins. [Parameter(ValueFromPipelineByPropertyName)] [switch] $Force, # The path to a plugin or a directory containing plugins. [Parameter(ValueFromPipelineByPropertyName)] [Alias('Fullname')] [string] $PluginPath ) begin { $getStreamDeckPlugin = $ExecutionContext.SessionState.InvokeCommand.GetCommand('Get-StreamDeckPlugin', 'Function') } process { $myParams = [Ordered]@{} + $PSBoundParameters $getStreamDeckParams = [Ordered]@{} foreach ($param in $getStreamDeckPlugin.Parameters.Keys) { if ($myParams.Contains($param)) { $getStreamDeckParams[$param] = $myParams[$param] } } $pluginFound = Get-StreamDeckPlugin @getStreamDeckParams if ($pluginFound) { $pluginFound | Select-Object -ExpandProperty PluginPath | Split-Path | Remove-Item -Recurse -Force if ($?) { [PSCustomObject]@{ PSTypeName = 'StreamDeck.Plugin.Uninstall' Uninstalled = $myParams } } } else { Write-Warning "Could not find plugin: $([PSCustomObject]$getStreamDeckParams)" } } } |