PowerShellMafia / PowerSploit

PowerSploit - A PowerShell Post-Exploitation Framework
Other
11.93k stars 4.61k forks source link

Coding guidelines for out-null are sub-optimal #45

Closed lanatmwan closed 10 years ago

lanatmwan commented 10 years ago

"Use Out-Null to suppress unwanted/irrelevant output." Out-Null is the slowest way to dump unwanted output because it unnecessarily involves the pipeline. It is far faster to cast to [void] or assign the results to $null, which can make a noticeable difference when process things like like log files which may have a lot of output.

For example: [void]$PsBoundParameters.Remove('Foo') $null = $PsBoundParameters.Remove('Foo')

powercode commented 10 years ago

Agree. I think '$null = ...' should be preferred.

mattifestation commented 10 years ago

This was addressed in the new Get-PE - An on-disk, in-memory PE parser, and process dumper that was written from scratch. https://github.com/mattifestation/PowerShellArsenal/blob/master/Parsers/Get-PE.ps1

Thanks for your comment and sorry for the delay. I was planning on rewriting Get-PEHeader all along.

Cheers, Matt