functions/logging/Get-PSFLoggingProviderInstance.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 |
function Get-PSFLoggingProviderInstance { <# .SYNOPSIS Returns a list of the enabled logging provider instances. .DESCRIPTION Returns a list of the enabled logging provider instances. Those are used to log messages to whatever system they are designed to log to. PSFramework ships with a few default logging providers. Custom logging destinations can be created by implementing your own, custom provider and registering it using Register-PSFLoggingProvider. .PARAMETER ProviderName Default: '*' The name of the provider the instance is an instance of. .PARAMETER Name Default: '*' The name of the instance to filter by. .PARAMETER Force Enables returning disabled instances. .EXAMPLE PS C:\> Get-PSFLoggingProviderInstance Returns all enabled logging provider instances. .EXAMPLE PS C:\> Get-PSFLoggingProviderInstance -ProviderName logfile -Force Returns all logging provider instances - enabled or not - of the logfile provider #> [CmdletBinding(HelpUri = 'https://psframework.org/documentation/commands/PSFramework/Get-PSFLoggingProvider')] [OutputType([PSFramework.Logging.Provider])] param ( [string] $ProviderName = '*', [string] $Name = '*', [switch] $Force ) process { foreach ($provider in ([PSFramework.Logging.ProviderHost]::Providers.Values | Sort-Object Name)) { if ($provider.ProviderVersion -lt 2) { continue } if ($provider.Name -notlike $ProviderName) { continue } foreach ($instance in ($provider.Instances.Values | Sort-Object Name)) { if ($instance.Name -notlike $Name) { continue } if (-not ($instance.Enabled -or $Force)) { continue } $instance } } } } |