Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Write-Verbose is quick or Get-Member is slow?

$
0
0

Hello

I have some trouble with Write-Verbose.

When I use Write-Verbose with Get-Member. I see something like this:

PS C:\Users\masalov\Desktop> Get-Content .\temp.ps1
[CmdletBinding()]
Param
(
)

Write-Verbose "Get-Process Output"
Get-Process | Get-Member | Select-Object -First 3
Write-Verbose "Get-Module output"
Get-Module | Format-Wide Name

PS C:\Users\masalov\Desktop> .\temp.ps1 -Verbose
VERBOSE: Get-Process Output

VERBOSE: Get-Module output

   TypeName: System.Diagnostics.Process

Name    MemberType    Definition                    
----    ----------    ----------                    
Handles AliasProperty Handles = Handlecount         
Name    AliasProperty Name = ProcessName            
NPM     AliasProperty NPM = NonpagedSystemMemorySize




ISE                                 Microsoft.PowerShell.Management     Microsoft.PowerShell.Security      
Microsoft.PowerShell.Utility        Microsoft.WSMan.Management                                             


I see two verbose output and then result of two command. This is not correct.

When i don't use Get-Member. I see one verbose output then result of command then verbose output then result of command. This is correct.

PS C:\Users\masalov\Desktop> Get-Content .\temp2.ps1
[CmdletBinding()]
Param
(
)

Write-Verbose "Get-Process Output"
Get-Process | Select-Object -First 3
Write-Verbose "Get-Module output"
Get-Module | Format-Wide Name

PS C:\Users\masalov\Desktop> .\temp2.ps1 -Verbose
VERBOSE: Get-Process Output

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName                                      
-------  ------    -----      ----- -----   ------     -- -----------                                      
     83       7     1196       3980    46     0,03   1616 armsvc                                           
    891      46    13728      38600   143     9,69   2128 CcmExec                                          
    189      16    23196       8428    89     0,11   2496 CmRcService                                      
VERBOSE: Get-Module output




ISE                                                   Microsoft.PowerShell.Management                      
Microsoft.PowerShell.Security                         Microsoft.PowerShell.Utility                         
Microsoft.WSMan.Management                                 

What should I do to correct this?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>