Hi Guys :)
with the class InformationRecord wee can add source to our log information
PS C:\> $a = [System.Management.Automation.InformationRecord]::new('log me','please')
PS C:\> $a | Select-Object *
MessageData : log me
Source : please
TimeGenerated : 5/4/2020
Tags : {}
User : xxx\xxxx
Computer : xxx
ProcessId : xxxx
NativeThreadId : xxxx
ManagedThreadId : xxx
with this parameter and tags parameter we can filter easily by source or/and by category _(tags)_...for example
$infoRecord | Where { $_.tags -contains 'power' -and $_.source -eq 'shell' }
Since the information is somewhat hidden in the issue's title, let me spell out what you're proposing:
You want to add a new, [string]-typed -Source parameter to Write-Information that allows setting the Source property of the resulting System.Management.Automation.InformationRecord instance _explicitly_.
Currently, Write-Information _implicitly_ sets this property, namely to the full path of the enclosing script (*.ps1 or *.psm1). (If you call Write-Information directly from the command prompt, Source is set to 'Write-Information').
Most helpful comment
Since the information is somewhat hidden in the issue's title, let me spell out what you're proposing:
You want to add a new,
[string]-typed-Sourceparameter toWrite-Informationthat allows setting theSourceproperty of the resultingSystem.Management.Automation.InformationRecordinstance _explicitly_.Currently,
Write-Information_implicitly_ sets this property, namely to the full path of the enclosing script (*.ps1or*.psm1). (If you callWrite-Informationdirectly from the command prompt,Sourceis set to'Write-Information').