Forum Discussion
johnmsch
Feb 07, 2023Copper Contributor
Write array values to Event Viewer?
Trying to debug an old PowerShell script that contains a small array, containing 5 -7 entries, each about 10-15 bytes long). I'm trying to write the contents of the array ($activeNode) to the Event ...
Feb 08, 2023
Tested this with a [array]$activenode=get-content d:\temp\test.txt variable which give me an Event with this as Event Data
<Data>Active Node List:********************** PowerShell transcript start Start time: 20220129124958 Username: T14\HarmV RunAs User: T14\HarmV Configuration Name: Machine: T14 (Microsoft Windows NT 10.0.22000.0) Host Application: C:\Program Files\PowerShell\7\pwsh.dll -file c:\temp\x2.ps1 Process ID: 24136 PSVersion: 7.2.1 PSEdition: Core GitCommitId: 7.2.1 OS: Microsoft Windows 10.0.22000 Platform: Win32NT PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.10032.0, 6.0.0, 6.1.0, 6.2.0, 7.0.0, 7.1.0, 7.2.1 PSRemotingProtocolVersion: 2.3 SerializationVersion: 1.1.0.1 WSManStackVersion: 3.0 ********************** Transcript started, output file is c:\temp\x.txt ********************** PowerShell transcript end End time: 20220129124958 **********************</Data>
If you do a $activenode.gettype(), what does that give you?
<Data>Active Node List:********************** PowerShell transcript start Start time: 20220129124958 Username: T14\HarmV RunAs User: T14\HarmV Configuration Name: Machine: T14 (Microsoft Windows NT 10.0.22000.0) Host Application: C:\Program Files\PowerShell\7\pwsh.dll -file c:\temp\x2.ps1 Process ID: 24136 PSVersion: 7.2.1 PSEdition: Core GitCommitId: 7.2.1 OS: Microsoft Windows 10.0.22000 Platform: Win32NT PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.10032.0, 6.0.0, 6.1.0, 6.2.0, 7.0.0, 7.1.0, 7.2.1 PSRemotingProtocolVersion: 2.3 SerializationVersion: 1.1.0.1 WSManStackVersion: 3.0 ********************** Transcript started, output file is c:\temp\x.txt ********************** PowerShell transcript end End time: 20220129124958 **********************</Data>
If you do a $activenode.gettype(), what does that give you?
johnmsch
Feb 08, 2023Copper Contributor
PS C:\Users\jschneider> $activenode.gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False DataRow System.Object
- Feb 08, 2023Ok... And what does $activenode.tostring() give you? (If possible?)
- johnmschFeb 08, 2023Copper Contributor
PS C:\Users\jschneider> $activenode.tostring() System.Data.DataRow
This is driving me nuts! It makes no sense.
- Feb 09, 2023
Did that work out for you?