I want to monitor python scripts in powershell. For that I am using Get-ProcessByName
. I want to monitor individual python and JAVA scripts running and store its processId in a csv file according to individual script running. Get-ProcessByName
lists all the the python or JAVA processes in the same row. How do I separate all the script names in different rows. What I am currently doing is-
$process = [System.Diagnostics.Process]
$outputTime = $process::GetProcessesByName($processName.ProcessName)[0].TotalProcessorTime.TotalMilliseconds
$name = ($process::GetProcessesByName($processName.ProcessName)[0]) | Select-Object -ExpandProperty ProcessName
$extra = Get-WmiObject -Class Win32_Process -Filter "name = '$name.exe'" | Select-Object -ExpandProperty CommandLine
Here in $extra
I am getting names of all the python scripts.How do I seperate all the scripts