My code looks like this:
Start-Transcript -Path "C:/test.txt" Write-Host (Get-Date).ToString("yyyy-MM-dd_HH:mm:ss") "Starting" $processes_using_oci_dll = Get-Process | ? { (get-process -id $_.id -module | ? {$_.filename -like "*\oci.dll"})} 2> $null Write-Host (Get-Date).ToString("yyyy-MM-dd_HH:mm:ss") "Ending" When watching its output through a powershell cli, it looks nice, the Get-Process ... 2> $null avoids the permission issues from being displayed on screen.
Nevertheless, when I open the file C:/test.txt, I can see a huge amount of entries such as
+ ... dll = Get-Process | ? { (get-process -id $_.id -module | ? {$_ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (System.Diagnost... (aesm_service):Process) [Get-Process], ProcessCommandException + FullyQualifiedErrorId : CouldnotEnumerateModules,Microsoft.PowerShell.Commands.GetProcessCommand get-process : No se pueden enumerar los módulos del proceso "REDACTED". My question is: How can I effectively keep these warnings from being Transcripted to the file C:/test.txt?
Thanks in advance!