locked
Same Request, Different result of Measure-command RRS feed

  • Question

  • Hi,

    I run this command twice.

    PS C:\windows\system32> Measure-Command {
      $SearchBase = @(
        'OU=HumanRessources,XXXXX', 
      'OU=Users,XXXXX')
    
      #Get disabled users
      foreach($Item in $SearchBase)
      {
        $ArrayUsers += Get-ADUser -Filter { Enabled -eq $False } -SearchBase $Item -SearchScope Subtree -Server srvad04
      }
    }
    
    
    Days              : 0
    Hours             : 0
    Minutes           : 0
    Seconds           : 11
    Milliseconds      : 647
    Ticks             : 116473459
    TotalDays         : 0,000134807244212963
    TotalHours        : 0,00323537386111111
    TotalMinutes      : 0,194122431666667
    TotalSeconds      : 11,6473459
    TotalMilliseconds : 11647,3459
    
    
    
    
    PS C:\windows\system32> Measure-Command {
      $SearchBase = @(
        'OU=HumanRessources,XXXXX', 
      'OU=Users,XXXXX')
    
      #Get disabled users
      foreach($Item in $SearchBase)
      {
        $ArrayUsers += Get-ADUser -Filter { Enabled -eq $False } -SearchBase $Item -SearchScope Subtree -Server srvad04
      }
    }
    
    
    Days              : 0
    Hours             : 0
    Minutes           : 0
    Seconds           : 0
    Milliseconds      : 362
    Ticks             : 3622937
    TotalDays         : 4,19321412037037E-06
    TotalHours        : 0,000100637138888889
    TotalMinutes      : 0,00603822833333333
    TotalSeconds      : 0,3622937
    TotalMilliseconds : 362,2937

    As you can see there a VERY big difference. I remark that if I wait 1 minute (approximetly), the time is ~11 seconds again. But if I re-run directly the command it is ~320 milliseconds again.

     

    Do you have any idea for this behavior ?

    Monday, August 21, 2017 8:48 AM

Answers

  • This is expected behavior and is dependent on network and cpu conditions.  Allowing a program to suspend can cause it to have to re-acquire resources.

    \_(ツ)_/

    • Marked as answer by arnaud.helin Monday, August 21, 2017 9:41 AM
    Monday, August 21, 2017 9:14 AM

All replies

  • This is expected behavior and is dependent on network and cpu conditions.  Allowing a program to suspend can cause it to have to re-acquire resources.

    \_(ツ)_/

    • Marked as answer by arnaud.helin Monday, August 21, 2017 9:41 AM
    Monday, August 21, 2017 9:14 AM
  • Thank you for explanation.
    Monday, August 21, 2017 9:41 AM