Hello, I’m in the process of migrating our code base to be at least compatible with PowerShell 7 (7.0.3 to be exact). Some of our Powershell code collects perfmon counters via logman and I’m running into an issue converting that to be PS7 friendly.
The code flow is:
[Start Counter Collection as a Job] --> [Do a task] --> [End Counter Collection] --> [Process Counters]
The problem is this:
We were using logman.exe to start/stop the task. This creates a BLG file that can be imported via Import-Counter. However, the Import-Counter cmdlet appears to have been deprecated in PS7. I wrote code to use Get-Counter to start the counter collection, but unfortunately, when you start/stop it via Start-Job scriptblock, the return data gets de-serialized and useless.
I’ve also tried using the PSCompatSession PSSession via Invoke-Command, but it also de-serialized the return data.
The only solutions I’ve read about involves writing the data to disk in CSV format and then importing the data back. However, that does not seem really efficient… especially when dealing with large data sets.