1616 . PARAMETER InstanceName
1717 Name of the instance of the logging provider to disable.
1818 Defaults to: Default
19+
20+ . PARAMETER InstanceObject
21+ A full Logging Provider Instance object, as return by Get-PSFLoggingProviderInstance
1922
2023 . PARAMETER NoFinalizeWait
2124 Do not wait for the logging to conclude or the final events shutting down the provider instance to finish.
4346
4447 Disables the "mytask" instance of the logfile provider, then waits until all applicable logs are processed
4548 but not for the logfile to be released (which will happen soon after, in most cases).
49+
50+ . EXAMPLE
51+ PS C:\> Get-PSFLoggingProviderInstance | Disable-PSFLoggingProvider
52+
53+ Disables all active logging provider instacnes
4654 #>
47- [CmdletBinding ()]
55+ [CmdletBinding (DefaultParameterSetName = ' ByName ' )]
4856 param (
49- [Parameter (Mandatory = $true )]
57+ [Parameter (Mandatory = $true , ParameterSetName = ' ByName ' )]
5058 [PsfArgumentCompleter (' PSFramework-logging-provider' )]
5159 [ValidateNotNullOrEmpty ()]
5260 [Alias (' Provider' , ' ProviderName' )]
5361 [string ]
5462 $Name ,
5563
64+ [Parameter (ParameterSetName = ' ByName' )]
5665 [PsfArgumentCompleter (' PSFramework-logging-instance-name2' )]
5766 [string ]
5867 $InstanceName = ' Default' ,
5968
69+ [Parameter (Mandatory = $true , ValueFromPipeline = $true , ParameterSetName = ' ByObject' )]
70+ [PSFramework.Logging.ProviderInstance []]
71+ $InstanceObject ,
72+
6073 [switch ]
6174 $NoFinalizeWait
6275 )
6376
64- process {
77+ begin {
78+ $inInstances = [System.Collections.ArrayList ]@ ()
6579 $limit = Get-Date
66- $instances = Get-PSFLoggingProviderInstance - ProviderName $Name - Name $InstanceName
67-
68- foreach ($instance in $instances ) {
69- $instance.NotAfter = $limit
80+ }
81+ process {
82+ if ($Name ) {
83+ $instances = Get-PSFLoggingProviderInstance - ProviderName $Name - Name $InstanceName
84+
85+ foreach ($instance in $instances ) {
86+ $instance.NotAfter = $limit
87+ }
88+
89+ foreach ($instance in $instances ) {
90+ $instance.Drain ((-not $NoFinalizeWait ))
91+ }
7092 }
7193
72- foreach ($instance in $instances ) {
73- $instance.Drain ((-not $NoFinalizeWait ))
94+ foreach ($instance in $InstanceObject ) {
95+ $instance.NotAfter = $limit
96+ $null = $inInstances.Add ($instance )
7497 }
7598 }
99+ end {
100+ foreach ($instance in $inInstances ) {
101+ $instance.Drain ((-not $NoFinalizeWait ))
102+ }
103+ }
76104}
0 commit comments