Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8121493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:30:20+00:00 2026-06-06T05:30:20+00:00

I need measure how time took a scriptblock (remote execution). This is my code:

  • 0

I need measure how time took a scriptblock (remote execution).

This is my code:

try
{

    Invoke-Command -credential $testCred -computer $ServerName -scriptblock { 
        param([String]$scriptDeploy, [String]$destino)  &"$scriptDeploy" 'parametro1' $destino
        $ScriptBlockOutput = $Error
    } -ArgumentList $RutaRemotaParaScriptDeInstalacion, "$dirRemotoDestino" 

    "`r`n`r`nOK para script de despliegue"
    exit 0;

}
catch
{
    "`r`n`r`nError en script de despliegue"
    "`r`nError in " + $_.InvocationInfo.ScriptName + " at line: " + $_.InvocationInfo.ScriptLineNumber + ", offset: " + $_.InvocationInfo.OffsetInLine + ".";

    exit -1
}

I would like something like this:
http://powershell.com/cs/blogs/tips/archive/2012/06/19/check-powershell-speed.aspx

 $timespan = Measure-Command $code
 "Your code took {0:0.000} seconds to run" -f $timespan.TotalSeconds

Any suggestions about it ?

UPDATE: my solution

    $timespan = Measure-Command -Expression {

        Invoke-Command -credential $testCred -computer $ServerName -scriptblock { 
            param([String]$scriptDeploy, [String]$destino)  &"$scriptDeploy" 'parametro1' $destino
            $ScriptBlockOutput = $Error
        } -ArgumentList $RutaRemotaParaScriptDeInstalacion, "$dirRemotoDestino" 

    }

"`r`n`r`nScript ha tardado {0:0.000} segundos en ejectuarse" -f $timespan.TotalSeconds
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:30:22+00:00Added an answer on June 6, 2026 at 5:30 am

    What is the problem? Everthing you wrote is good.

    $timespan = Measure-Command -Expression { <your code here> }
    

    Best Regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question Measure execution time... allows programmers to find good tools to evaluate execution
I need to measure the time between character events on a serial port, preferably
I need to measure DNS Lookup time out of a java application. My idea
For performance tests I need a way to measure the time needed for a
I am writing a program that will need to measure time in minutes. To
I need to measure the length of time requests are taking to be processed
I need to measure the time certain parts of my program take (not for
I have some mechanics to measure method execution time. Simply at start of method
i need to measure the time between 2 points. I can not use a
Possible Duplicate: Measure execution time for a Java method I have an application by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.