And here is a quick usage of the inclusive approach. When using this pattern, type in the full or partial name(s) of a TraceSource with which you would like to work. This one returns all TraceSources whose names match Cmdlet:function Limit-TraceSource{param([Parameter(Mandatory = $false)][String[]]$Name,[Parameter(Mandatory = $false)][Switch]$Exclude)if($Exclude){Get-TraceSource | Where { $_.name -notmatch "($($Name -join |))"}}else{Get-TraceSource ($Name | % { "*$_*" } )}}
This command will output this:[array] $names =Limit-TraceSources -Name Cmdlet | % { $_.name }
$namesCmdletConfigurationEntryCmdletProviderAttributeCmdletProviderClassesCmdletProviderContextCmdletGetCommandCmdletCmdletProviderIntrinsicsScriptAsCmdletCmdletInfo
[array] $names =Limit-TraceSource -Name Cmdlet,bind | % { $_.name }
In usage, it looks like this:$namesCmdletConfigurationEntryCmdletProviderAttributeCmdletProviderClassesCmdletProviderContextCmdletGetCommandCmdletCmdletProviderIntrinsicsScriptAsCmdletCmdletInfoParameterBinderBaseParameterBindingReflectionParameterBinderParameterBinderControllerParameterBindingExceptionScriptParameterBinderFormatViewBinding
Trace-Command -Name $names -Expression { list } –PSHostOr, if you want to be more terse with a one-liner,
Trace-Command -Name @(Limit-TraceSource -Name Cmdlet | % { $_.name }) -Expression { list } -PSHost
[array] $names =
style="font-family: Courier New; font-size: 12pt;">Limit-TraceSource -Name Console,parameter -Exclude | % { $_.name }which yields a much longer list...but, one free of any Console or Parameter TraceSources.
So, next time you want to research something and would rather not watch your console go nuts, use$namesSingleShellMshSnapinLoadUnloadPSSnapInInfoPSSnapInReaderRunspaceConfigurationEntryCollectionRunspaceConfigurationEntryCmdletConfigurationEntryAssemblyConfigurationEntryRunspaceConfigurationRunspaceInitCmdletProviderAttributeProviderConfigurationEntryResourceManagerCacheLocalRunspaceUniversalResourceNameExecutionContextAuthorizationManagerPSAuthorizationManagerInternalHostInternalHostRawUserInterfaceSessionStateSessionStateScopeRunspaceETSTypeConversionParserTokenizerDetailedCommandDiscoveryCommandDiscoveryTypeTableDeserializingTypeConverterTypeInfoDataBaseManagerTypeInfoDataBaseLoaderXmlLoaderBaseFormatFileLoadingStateCoreCommandProviderPSCredentialPSDriveInfoCmdletProviderClassesPSTransactionCmdletProviderContextMshLogEventLogLogProviderAliasProviderEnvironmentProviderFileSystemProviderVariableProviderRegistryProviderCertificateProviderX509StoreLocationDriveCommandAPILocationGlobberPathResolutionProviderCommandAPIWildcardPatternPathInfoCommandFactoryHistoryInitialSessionStateCommandMetadataCompiledCommandAttributeMemberResolutionPSSnapInLoadUnloadHostUtilitiesExecutorPipelineStateInfoPipelinePipelineBaseObjectStreamObjectWriterLocalPipelineInternalCommandScriptCommandProcessorCommandSearchCommandProcessorOutDefaultCommandCmdletPipelineProcessorCommandProcessorBaseTerminatingErrorContextWriteLineHelperformat_out_OutputManagerInnerformat_out_FrontEndCommandBaseformat_out_ImplementationCommandBaseSecuritySupportExternalScriptInfoWriteOutputCommandformat_out_CommandWrapperOutLineOutputCommandformat_out_OutCommandInnerFormatObjectDeserializerDeserializerPSVariableCommandAPIFormatInfoDataClassFactoryPathCommandAPISessionStateExceptionProcessCommandsNavigationCommandsGetCommandCmdletCmdletProviderIntrinsicsProviderIntrinsicsWriteVerboseCommandScriptAsCmdletCmdletInfoWriteOrThrowErrorCommandErrorRecordStreamingTextWriterErrorCategoryInfoCompareObjectSelectObjectOrderByPropertyObjectCommandComparerWriteDebugCommandFormatViewBindingDisplayDataQueryTypeMatchWrite-DebugNewObjectCommandFunctionInfoScriptBlockSessionStateProviderCredentialAttributeStartTranscriptCommandAliasCommandsCommandNotFoundExceptionCommandCompletion