Functions/StreamDeck/Get-StreamDeckAction.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 |
function Get-StreamDeckAction { <# .Synopsis Gets Actions for StreamDeck .Description Gets available actions for StreamDeck .Example Get-StreamDeckAction .Link Get-StreamDeckPlugin .Link New-StreamDeckAction #> [OutputType('StreamDeck.PluginAction')] param( # The name of the action [Parameter(ValueFromPipelineByPropertyName)] [string] $Name, # The action UUID [Parameter(ValueFromPipelineByPropertyName)] [string] $UUID, # If set, will rebuild the cache of streamdeck actions. [Parameter(ValueFromPipelineByPropertyName)] [switch] $Force ) process { #region Cache Plugins $plugins = Get-StreamDeckPlugin -Force:$Force if ($force -or -not $Script:CachedStreamDeckActions) { $Script:CachedStreamDeckActions = @(foreach ($plug in $plugins) { foreach ($act in $plug.Actions) { $act.pstypenames.clear() $act.pstypenames.add('StreamDeck.PluginAction') $act } }) } #endregion Cache Plugins #region Return Matching Plugins if (-not ($Name -or $UUID)) { $Script:CachedStreamDeckActions } else { foreach ($_ in $Script:CachedStreamDeckActions) { if ($UUID -and ($_.UUID -notlike $UUID)) { continue } if ($Name -and ($_.Name -notlike $Name)) { continue} $_ } } #region Return Matching Plugins } } |