Organizations in all industries need to ensure the integrity, security, and timely delivery of online messages and emails to improve productivity and streamline workflow.
However, troubleshooting and optimizing email delivery can turn into a real challenge, especially in larger organizations, if you don’t know how to proceed.
In this guide, we’ll explore how to use Get-MessageTrace in PowerShell to ensure efficient email tracing.
Introduction
If you’re having network connectivity problems, you can run a traceroute to pinpoint exactly where your connection is failing. The traceroute command will provide you with information about your internet connection, website status, and more. Then you can give this information to your technical support representative to resolve your network connectivity issues. Here’s how to run a traceroute on Windows 10 or Ubuntu Linux and how to read your traceroute results.
Premature optimization may be the root of all evil, but that doesn’t mean you shouldn’t optimize your code where it matters.
Rather than guessing which code is slow and spending time optimizing code that doesn’t need it, you should profile your code to find the true bottlenecks.
At that point you can decide if the code is slow enough to warrant optimizing.
Jakub Jareš has created the amazing Profiler module GitHub repo for profiling PowerShell code to find which parts are the slowest.
Installing and using it is a breeze.
In this post I will walk through how I used Profiler to find a surprisingly slow part of a new PowerShell module I am developing, called tiPS.
I noticed that importing tiPS in my PowerShell profile was noticeably slowing down my PowerShell session startup time, so I decided to profile it to see if I could optimize it.
I want to log the SMTP
protocol of System.Net.Mail.SmtpClient
<system.diagnostics>
<sources>
<source name="System.Net">
<listeners>
<add name="TraceFile"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="TraceFile"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add
name="TraceFile"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="trace.log"
/>
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose"/>
<add name="System.Net.Sockets" value="Verbose"/>
</switches>
<trace autoflush="true" />
</system.diagnostics>
unfortunately, as I don’t have the opportunity to modify powershell.exe.config
, I looked for a way of starting the trace on the fly in my script and found this stackoverflow answer which gives a way,
$id = [Environment]::TickCount
$fileName = "${PSScriptRoot}\Powershell.log.${id}.txt"
$listener1 = [System.Diagnostics.TextWriterTraceListener]::New($fileName, "text_listener")
$listener2 = [System.Diagnostics.ConsoleTraceListener]::New()
$listener2.Name = "console_listener"
[System.Diagnostics.Trace]::AutoFlush = $true
[System.Diagnostics.Trace]::Listeners.Add($listener1) | out-null
[System.Diagnostics.Trace]::Listeners.Add($listener2) | out-null
# Use reflection to enable and hook up the TraceSource
$logging = [System.Net.Sockets.Socket].Assembly.GetType("System.Net.Logging")
$flags = [System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Static
$logging.GetField("s_LoggingEnabled", $flags).SetValue($null, $true)
$webTracing = $logging.GetProperty("Web", $flags)
$webTraceSource = [System.Diagnostics.Tracesource]$webTracing.GetValue($null, $null);
$webTraceSource.Switch.Level = [System.Diagnostics.SourceLevels]::Information
$webTracesource.Listeners.Add($listener1) | out-null
$webTracesource.Listeners.Add($listener2) | out-null
[System.Diagnostics.Trace]::TraceInformation("About to do net stuff")
[System.Net.FtpWebRequest]::Create("ftp://www.google.com") | out-null
[System.Diagnostics.Trace]::TraceInformation("Finished doing net stuff")
#get rid of the listeners
[System.Diagnostics.Trace]::Listeners.Clear()
$webTraceSource.Listeners.Clear()
$listener1.Dispose()
$listener2.Dispose()
but I am not able to adapt it to my needs.
I tried to replace Web
by Sockets
in
$webTracing = $logging.GetProperty("Web", $flags)
and do some system.net.mail
stuff in place of
[System.Net.FtpWebRequest]::Create("ftp://www.google.com") | out-null
but with no success.
can you teach me how to adapt the above example to make it start traces as described in the XML
.config
?
Table of Contents
Watch video
Watch this video that demonstrates step by step how to run Message Trace in Exchange Online.
What is Extended Message Trace (EMT)
An extended message trace is a detailed report that provides comprehensive information about the delivery path of an email message. It goes beyond the basic details shown in a standard message trace. A standard message trace offers basic details like sender, recipient, date, subject, and delivery status. An extended message trace dives deeper, revealing hops the email took between servers, timestamps for each stage, and potential reasons (NDR Error Codes) for delivery failures.
How to run Extended Message Trace in Exchange Admin Center


Specify the sender and recipient, or a Message ID, under Report type select Extended report, and click Next.

On the Prepare message trace report page, type a name for the report under Report title, add an email address to which the report will be sent once it is prepared, and click Prepare report.

Download message trace report
To download message trace report, on the Message trace page, click Downloadable reports, and click the report as shown below:

On the next page, click Download the report.

You will also receive an email on the email address provided while running Extended Message Trace report as shown below from where you can download the extended message trace report.

Extended Message Trace PowerShell commands
To run extended message trace using PowerShell, we will use Start-HistoricalSearch and Get-HistoricalSearch commands.
Run Extended Message Trace using Message ID
To run extended message trace report using Message ID, we will specify the ReportType, Message ID, StartDate, and EndDate parameters.
Important: The ReportType parameter of Start-HistoricalSearch PowerShell command has 2 parameters for message trace as MessageTrace and MessageTraceDetail. If you want to download an extended message trace report, use MessageTraceDetail, and if you want to download enhanced message trace report, use Messagetrace under ReportType.
Type message IDemail address to send report
The actual command will look like below:
The above command will start an extended message trace job as shown below. Initially the report status will show as Not Started.

To check extended message trace report status, run below PowerShell command:
The above command will list all the message trace reports as shown below:


Run Extended Message Trace using Sender and Recipient
In this example we will run extended message trace report using sender and recipient email address.
Run Extended Message Trace for all users in a specific domain
How to read Extended Message Trace (EMT)
To learn how to read extended message trace report, please watch this video on our YouTube channel.
Conclusion
In this article you will find Office 365 Message Trace PowerShell commands. How will learn how to run Exchange Online message trace using PowerShell. We will discuss all the possible scenarios in message trace and utilize the PowerShell commands for our scenarios.
Table of Contents
Office 365 Message Trace PowerShell commands
To run message trace using PowerShell for less than 10 days, we use below 2 PowerShell commands:
Get-MessageTrace: This command is used to trace emails as they pass through the cloud-based organization.
Get-MessageTraceDetail: view the message trace event details for a specific message. This command return detailed information of the message trace.
Connect to Exchange Online PowerShell
Run message trace for specific date range
In this example, we will run message trace for specific date range. To achieve this we will use StartDate and EndDate parameters as shown below:
Important: StartDate and EndDate parameters will have value in the format of MM/DD/YYYY.
Find emails from a specific IP address
In this example, we will find the emails those are sent from a specific IP address. To achieve this we will use date range along with FromIP parameter which is the public IP address of the SMTP email server that sent the email.
If you want to find emails those were sent to a particular IP address from your organization, run below PowerShell command:
Run message trace by subject of emails
In this example, we will run message trace using PowerShell and will find the emails with subject “Automatic Reply”.
Run message trace for a specific recipient of your organization
In this example we will run message trace for a specific recipient (internal). To achieve this we will use RecipientAddress parameter along with date range.
Run message trace for a specific sender of your organization
In this example we will run message trace for a specific sender (internal). To achieve this we will use SenderAddress parameter along with date range.
Run message trace for sender and recipient
In this example we will run message trace for a particular sender and recipient. To achieve this we will use RecipientAddress and SenderAddress parameters along with date range.
Run message trace for all users (recipients) of a domain
Run message trace for all users (senders) of a domain
Find emails with delivery status as Delivered
In this example, we will run message trace using PowerShell to find the emails in a date range those were successfully delivered.
Find emails with delivery status as Failed
In this example, we will run message trace using PowerShell to find the emails in a date range those were failed to deliver.
Find emails with delivery status as Getting Status
In this example, we will run message trace using PowerShell to find the emails in a date range whose delivery status is GettingStatus.
Find emails with delivery status as FilteredAsSpam
Find emails with delivery status as Expanded
The “Expanded” status in email tracking typically refers to a distribution group that has been expanded to show its individual members. When an email is sent to a distribution group, Exchange expands the group to display all the individual recipients who are members of that group. This expansion occurs before the email is delivered to the recipient’s mailboxes.
To find emails with status Expanded, run below PowerShell command:
Run message trace using Message ID of email
The Message ID (Message Identifier) is a unique identifier assigned to each email message. It serves as a unique reference for that particular email within the Exchange environment. The Message ID is crucial for tracking, managing, and troubleshooting email messages.
To find an email with Message ID, run below PowerShell command:
Find events information of an email using PowerShell
In this example, we will use PowerShell to find events information of an email. To achieve this we will use Get-MessageTraceDetail PowerShell command along with Message Trace ID and RecipientAddress parameters.
To find Message Trace ID and RecipientAddress of an email, run below PowerShell command:
Copy Message Trace ID and RecipientAddress and paste it in below PowerShell command and run it:
Conclusion
In this article you learnt about Office 365 Message Trace PowerShell commands. You might like our other articles on Run Extended Message Trace using PowerShell and EAC and How to analyze email header.
Join us on YouTube for the latest videos on Cloud technology and join our Newsletter for the early access of the articles and updates.
How to Run a Traceroute on Linux
Many flavors of Linux come with traceroute pre-installed, although some distributions opt for similar tools like mtr and tracepath. If you do not have trace route installed you may need to install it. For example in Ubuntu the command to install trace route is “sudo apt-get install traceroute”.
$ traceroute www.google.com Command 'traceroute' not found, but can be installed with: sudo apt install inetutils-traceroute # version 2:2.2-2, or sudo apt install traceroute # version 1:2.1.0-2
From there, the steps aren’t too dissimilar from Windows:
– Open your favorite Terminal Emulator. This step isn’t required if you’re running Linux without a window manager (GUI).
– Wait for the trace to complete and review the results.
How to Read Traceroute Results
– The first column is the hop count.
– The second column is the IP address and hostname of each hop. If the hostname cannot be resolved, only the IP address is displayed.
– The third, fourth, and fifth columns display the round-trip times for each packet. If a packet is lostor doesn’t reach its destination, an asterisk (*) is displayed.
Traceroute Command Variations
If you are looking for ways to run a traceroute, you can open the Command Prompt app and type traceroute –help to see variations you can use.
Traceroute FAQ
Ping and traceroute are both network diagnostic tools, but traceroute is a little more complex. Ping will test connectivity between two hosts but gives no information on the path between those two hosts. The traceroute tool, on the other hand, displays all of the intermediate hops between source and destination. This can be useful during intermittent connectivity episodes, for example, if only 50% of the pings between two points are successful.
The original traceroute tool, which dates all the way back to 1987, isn’t always able to produce accurate results. Load Balancing, Network Address Translation (NAT), firewalls, and other factors can result in inaccurate or incomplete results. A number of similar tools, such as mtr, and Paris Traceroute, implement the same basic idea as traceroute but attempt to address the classic tool’s shortcomings through various means. Some tools also sought to build on the output and streamline configuration vs the original.
Tracert and traceroute perform virtually identical functions, but the underlying code between the two tools is different. Tracert was created by Microsoft for Windows operating systems, while the earlier traceroute is for Unix-based systems. There are slight differences in the default parameters between the two tools, such as the type of packets used.
You’re in luck! The traceroute6 and tracert6 commands provide the same functionality as traceroute but for IPv6 networks. Many of the similar tools (see above) also have support for IPv6.
Viewing the profile trace information
Now that we have the trace information in the $trace
variable, you can inspect its properties to view the trace info.
The TotalDuration
property is the same TimeSpan that Measure-Command
would have given us:
The real value of the Profiler is in the Top50SelfDuration
and Top50Duration
properties, which is a list of the top 50 slowest commands in the trace.
The 2 properties show similar information, just sorted based on SelfDuration
or Duration
respectively.
SelfDuration
is the time spent in the command itself, not including any time spent in functions that it called.
This shows you the lines of code that are actually slow in the script.Duration
is the time spent in the command, including all other functions it called.
It shows the bigger pieces that are slow because they contain smaller slow pieces.
A good strategy is to look at the Top50SelfDuration
first to see which specific lines of code are the slowest.
You can then look at the Top50Duration
to see which larger parts of your script take the most time, and see if it matches your expectations.
Here is the output of the Top50SelfDuration
property:
In this screenshot we can see that the top offender (the first row) is a line in the tiPS
module’s Configuration.ps1
file on line 8
, which is called once and taking 693 milliseconds to execute.
tiPS
is a module that I am currently developing and have added to my profile to automatically import it on every new session.
By default the Top50SelfDuration
and Top50Duration
display their output in a table view.
Unfortunately the number of columns displayed is based on your console window width.
If we make the console window wider, we can see 2 more very useful columns: Function
and Text
, which is the actual line of code that was executed.
Even with the wider console window, much of the text is still cut off.
To see the full text we have a couple options.
We can pipe the output to Format-List
:
This is good for seeing details about each individual entry, but not great for viewing the entire list.
My preferred approach is to pipe the results to Out-GridView
:
This allows me to see all of the columns, reorder and hide columns I don’t care about, as well as sort and filter the results.
Now that we have the Text
column, we can see that the top offender is a call to Add-Type -Language CSharp
.
Since tiPS
is my module, I know that line is being used to compile and import some inline C# code.
The 3rd row shows the same operation for importing a different C# file.
Since it is a single line of code calling a library that I do not own, there’s not much I can do to optimize it outside of considering a different strategy for importing C# code or not using C# at all, which may be something to consider.
Moving on, the 2nd row shows a call to Set-PoshPrompt
taking 624 milliseconds.
I use this third party module to customize my prompt with oh-my-posh.
In fact, looking at the Module
column, you can see many of the slowest commands are coming from 3 third party modules that I import in my profile script: oh-my-posh
, posh-git
, and Terminal-Icons
.
Since it is third party code there’s not much I can do outside of not loading those modules automatically at startup, which I may decide to do if they impact my startup time enough.
With that in mind, let’s focus on the code that I can optimize.
The 6th row shows another top offending line in the tiPS
module.
Notice that this line has a total Duration
of 1054 milliseconds, due to it being called 15 times.
On initial inspection, it appears that this line of code is slowing the module load time even more than our initial top offender (we’ll come back to this).
This is made more apparent when we sort by Duration
:
Looking in my tiPS.psm1
file on line 25
, I see that it is looping over all of the files in the module directory and dot-sourcing them:
This dot-sourcing strategy allows for better code organization by keeping module functions in separate files, rather than having one giant .psm1 file with all of the module code.
A quick Google search shows me that others have come across this dot-sourcing performance issue as well.
Naively we may think that this is giving additional evidence that the dot-sourcing may be the main issue.
This highlights the difference between SelfDuration
and Duration
.
The Duration
of the dot-sourcing was including the time spent in all of the operations of the dot-sourced files, such as the Add-Type
operations.
In the screenshot we can see that the dot-sourcing Duration
is 1054ms, and the SelfDuration
is 129ms.
So the act of dot-sourcing the 15 files, regardless of what the files contain, is taking 129ms.
We know it takes 903ms to execute the two Add-Type
commands in the dot-sourced files, so that means the time it takes to execute the operations in the other 13 files being dot-sourced is 1054ms – 903ms = 151ms.
So dot-sourcing 15 files takes 129ms, which isn’t too bad.
I imagine (but did not test) the time will increase linearly with the number of files dot-sourced, so if you have a large project that dot-sources hundreds of files, you could be looking at several seconds of time spent just dot-sourcing the files; not executing the code in the files.
While dot-sourcing is a bit slow, it is not the main offender in my scenario.
The main performance issue is the Add-Type
commands to compile and import the C# code.
I never anticipated that one command would have such a drastic impact on the module load time!
Since the tiPS module is intended to be loaded on every new PowerShell session, I need to find a way to speed up the module load time.
This might mean not using C# code, or taking some other approach; I’m not sure yet.
The main point is that I now know where the bottleneck is and can focus my efforts on optimizing that code.
What is Get-MessageTrace in PowerShell?
Get-MessageTrace is a PowerShell command used in Microsoft Exchange Online Protection (EOP) and Office 365 environments to retrieve detailed information about the delivery and status of email messages.
This cmdlet is only available in the cloud-based service, which means it can only trace messages as they flow through organizations that use cloud-based infrastructure.
What Can You Use The Get-MessageTrace Command For?
- Email Delivery Tracking: Use Get-MessageTrace to track the delivery status and path of specific email messages;
- Security Threat Detection: Identify and investigate potential security threats, such as phishing attempts, through the analysis of message traces;
- Compliance and Auditing: Meet compliance requirements by auditing and tracking email communication within the organization using message trace data;
- Email Flow Monitoring: Monitor the overall health of your email system by reviewing message trace data and identifying patterns or anomalies in email traffic;
- Policy Enforcement and Optimization: Enforce email policies and optimize email delivery based on the analysis of message trace data, ensuring compliance and efficient communication.
How to Use Get-MessageTrace in PowerShell
Now that you know what Get-MessageTrace is for, it’s time to learn how to use it.
Before continuing, it is important to mention that the output of this command highly depends on its parameters.
Below, we’ll show you how to use Get-MessageTrace to retrieve emails for certain data ranges, allowing you more control over email workflows.
Step 1: Connect to Exchange Online PowerShell
Step 2: Run Get-MessageTrace to See Recent Message Trace Records
After accessing Exchange Online PowerShell and ensuring you have all the required permissions, it’s time to run the Get-MessageTrace cmdlet.
According to Microsoft, running this cmdlet without any parameters will only retrieve data from the last 48 hours.
The output of the cmdlet will look like this, depending on your organization’s size and the number of emails tracked:
Need a paper notebook? | ||||
How are you doing? | ||||
I’m here if you need something | ||||
Latest company report |
Step 3: Set a Specific Date Range with Message Trace in PowerShell
On the other hand, if you want to perform email tracing for certain dates or for specific addresses, then it’ll be necessary to modify the cmdlet a bit more.
Get-MessageTrace -StartDate <mm/dd/yyyy> -EndDate <mm/dd/yyyy> |
Of course, the aforementioned cmdlet could be modified to add more parameters based on the information you want to retrieve.
Installing the Profiler module
The Profiler module is available on the PowerShell Gallery here, so you can install it with:
What Is Traceroute?
Traceroute is a network diagnostic tool that tracks the path of a packet of data as it travels from your computer to a destination over the internet. Running a traceroute lets you see where your connection is slow or unresponsive.
You can think of the traceroute tool like a traffic map of your internet connection. When you run a traceroute, you will see all the “hops,” or routers that three separate packets are pushed through on their way to a destination. It will also show you your network’s latency, or how long it took for each packet to travel from one hop to the next.
1.Open the Windows search box. You can do this by clicking the magnifying glass icon in the bottom-left corner of your screen.
4.Finally, press Enter on your keyboard and wait for the traceroute to finish. You will see the words Trace complete when the process is finished. You can also stop a traceroute at any time by pressing the Control + C keys on your keyboard at the same time.
Note: Microsoft’s implementation of the traceroute tool is slightly different from what you’ll find on Mac/Linux/Unix platforms. The most glaring difference is in the command itself: On Windows PCs, you’ll use the “tracert” command instead of typing the whole word.
How to Read Traceroute Results
To read your traceroute results, look for the round trip time (RTT) in columns two through four. If you see any hops that took a long time or there is an error message in any of the rows, that might be where you have network connectivity problems.
Column 1: This represents the hop number, or the number of hops that the three data packets were pushed through to reach the destination.
Columns 2-4: These show the round trip time measured in milliseconds. RTT represents the time it took for a data packet to travel from the source to the destination and back again. To check for the consistency of the response times, the traceroute command sends three packets to each hop, which is why there are three time values listed per row. RTT values below 100 milliseconds are acceptable. However, if you see RTT values consistently increasing from the middle hop to the destination, it could be due to a network problem.
Column 5: This column shows the name or IP address of the routers on every hop from your computer to the destination. It will also list the domain name of the router, if that information is available.
Traceroute Command Variations
If you are looking for ways to run a traceroute, you can open the Command Prompt app and type tracert /? to see variations you can use.
Common Traceroute Error Messages
If there is an issue within the network, the traceroute results will also show error commands, which include Request timed out, Destination unreachable, * in RTT columns, and more.
– Destination net unreachable: This means that the data packets have stopped traveling within the network. Most of the time, this is because there is a problem with the router or that the website or IP address you are trying to reach is down.
– * in RTT columns: It means the router did not respond to the request within the maximum allotted time of two seconds. It could also mean that the router in the hop was not set up to provide a response to a traceroute request. However, it does not necessarily mean that the packet was dropped. To verify if there was a packet loss, you can ping the IP address of the router where you see the asterisk.
Get-MessageTrace Errors, Limitations, & How to Fix Them
- It is not possible to set the start date on Get-Message Trace older than 10 days, meaning it can’t trace email data greater than 10 days old. Otherwise, the output will return an error message. If you want to see the processing of email messages greater than ten days old, Microsoft recommends using the Start-HistoricalSearch and Get-HistoricalSearch cmdlets;
- Running the Get-MessageTrace cmdlet without specific parameters will oftentimes return irrelevant information, as it can cause it to timeout after 1,000 results. To prevent this from happening, make sure to modify the Get-MessageTrace parameters to get a clean output, also referred to as “Get-MessageTrace clean results;”
- In case the cmdlet is not running properly or returning the expected results, try using smaller StartDate and EndDate intervals, opt for a broader time window, check if you have the necessary permissions to run the command, and ask for further help from your organization administrator.
Prerequisites to Run Get-MessageTrace in PowerShell
According to Microsoft Resources, these are the prerequisites to comply with before being able to run this command:
- Connect to Exchange Online: Use a valid Microsoft Account with admin credentials to connect to Exchange Online PowerShell. Then, move on to the following step.
- Run the Get-ManagementRole Command: Once you have logged into your Microsoft Account, run the following command: Get-ManagementRole -Cmdlet <Cmdlet>. Replace <Cmdlet> with Get-MessageTrace, and press enter.
- Check the Required Permissions: After running the command, PowerShell will return the list of roles necessary to run Get-MessageTrace. If you need additional roles or permissions, you’ll need to contact your organization administrator for further assistance.
How to Obtain Get-MessageTrace Data in PowerShell
- Get-MessageTrace allows us to trace emails in cloud-based organizations by returning in-detail email information from senders and recipient email addresses as instructed in the command;
- It is advisable to set specific date ranges to retrieve email tracing information. Otherwise, the command’s output will return lists of irrelevant information to your query, mainly if you work at a large organization;
- Keep in mind that the Get-MessageTrace cmdlet has some limitations, such as the impossibility of tracking emails older than 10 days, and a maximum return of only 1,000 results.
Get-MessageTrace Cmdlet Syntax & Meaning
Depending on the parameters, the cmdlet input and output types will change based on your needs.
Each one of these switches and parameters has a meaning. This is a complete list and breakdown of this cmdlet’s full meaning:
- EndDate <DateTime>: Specifies the end date and time for the message trace query, indicating the upper limit for the time range of messages to be included in the results;
- FromIP <String>: Filters messages based on the source IP address from which the emails originated;
- MessageId <MultiValuedProperty>: Allows you to specify one or more message IDs to retrieve details about specific email messages;
- MessageTraceId <Guid>: Specifies the unique identifier (GUID) of a specific message trace. Useful for retrieving details about a particular message trace;
- Page <Int32>: Specifies the page number when retrieving a large set of results. Helps in navigating through the pages of the result set;
- PageSize <Int32>: Sets the number of entries to be displayed on each page of the result set. Useful for controlling the granularity and precision of the output;
- ProbeTag <String>: Filters messages based on the probe tag. A probe tag is associated with messages used for testing or monitoring purposes.
- RecipientAddress <MultiValuedProperty>: Filters messages based on the email addresses of the recipients, useful if you want to generate a report by recipient address;
- SenderAddress <MultiValuedProperty>: Filters messages based on the email addresses of the senders;
- StartDate <DateTime>: Specifies the start date and time for the message trace query, indicating the lower limit for the time range of messages to be included in the results;
- Status <MultiValuedProperty>: Filters messages based on their delivery status, allowing you to focus on messages with specific statuses;
- ToIP <String>: Filters messages based on the destination IP address to which the emails were delivered.
TL;DR
If you don’t want to read this entire post, just run these commands and thank me (and Jakub) later:
Tracing code with the Profiler module
You profile code by tracing it, which is done with the Trace-Script
command.
This works similarly to the Measure-Command
cmdlet, but provides more detailed information.
Trace some code inline:
# Code to profile goes here
Trace some code in a script file:
Trace some code in a script file that takes parameters:
Trace the code in your $Profile
script that is run on every new session:
Let’s walk through tracing the code I have in my profile script to see if I can reduce my PowerShell session startup time.
You will notice some summary information is output to the console when you run the Trace-Script
command, including the total Duration
, which is the same info that the Measure-Command
cmdlet would have given us.
Conclusion
You now understand a little bit more about how to use traceroute. Traceroute is a must-have tool if you want to stop network troubleshooting and identify network connection bottlenecks.
Traceroute is a vital tool for network troubleshooting. It allows you to visualize the path your data takes to its destination, helping you identify where problems might be occurring. Whether you’re using Windows or Linux, understanding how to use and interpret traceroute can be incredibly useful for diagnosing network issues.
Conclusion
By using the Profiler module for less than 2 minutes I was able to identify a major performance issue that I would not have otherwise known about.
Without it, I likely would have spent time optimizing other parts of my code that would not have as much impact.
Profiling your code is as easy as:
I hope you’ve found this post helpful.