Skip to content

Commit 8244eea

Browse files
committed
Added more advanced samples to inspire
1 parent f90e8fe commit 8244eea

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

documentation/Get-PnPTraceLog.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ Get-PnPTraceLog [-Verbose]
2626
```
2727

2828
## DESCRIPTION
29-
This cmdlet returns the logged messages during the execution of PnP PowerShell cmdlets. It can return the messages from an in memory log stream or from a file. You can use [Start-PnPTraceLog](Start-PnPTraceLog.md) to start logging to a file and/or to an in memory stream.
29+
This cmdlet returns the logged messages during the execution of PnP PowerShell cmdlets. It can return the messages from an in memory log stream or from a file. Note that you cannot read from a log file if it is currently in use to write to. In this case, you would first have to stop logging to it using [Stop-PnPTraceLog](Stop-PnPTraceLog.md) and then read the log file. The in memory log stream is always available.
30+
31+
You can use [Start-PnPTraceLog](Start-PnPTraceLog.md) to start logging to a file and/or to an in memory stream.
3032

3133
## EXAMPLES
3234

@@ -42,7 +44,7 @@ This returns all items in the in memory stored log stream
4244
Get-PnPTraceLog -Path "C:\temp\log.txt"
4345
```
4446

45-
This returns all items from the log file stored at the provided location
47+
This returns all items from the log file stored at the provided location. Note that you cannot read from a log file if it is currently in use to write to. In this case, you would first have to stop logging to it using [Stop-PnPTraceLog](Stop-PnPTraceLog.md) and then read the log file.
4648

4749
### EXAMPLE 3
4850
```powershell
@@ -58,11 +60,27 @@ Get-PnPTraceLog | Where-Object { $_.CorrelationId -eq "5a6206a0-6c83-4446-9d1b-3
5860

5961
This returns only logged items from the in memory stored log stream that happened during the execution of a PnP PowerShell cmdlet with the provided correlation id. This is useful to find out what happened during the execution of a specific cmdlet. Mind that the correlation id is an unique identifier for the cmdlet execution assigned by PnP PowerShell and is not the same as the correlation id of a SharePoint operation.
6062

63+
### EXAMPLE 5
64+
```powershell
65+
Get-PnPTraceLog | Sort-Object -Property EllapsedMilliseconds -Descending -Top 10 | Select EllapsedMilliseconds, Source, Message
66+
```
67+
68+
Returns the 10 longest running operations from the in memory stored log stream. The output is sorted by the EllapsedMilliseconds property in descending order. The output is limited to the properties EllapsedMilliseconds, Source and Message.
69+
70+
### EXAMPLE 6
71+
```powershell
72+
Get-PnPTraceLog | Group-Object -Property CorrelationId | ForEach-Object { [pscustomobject]@{ Started = $_.Group[0].TimeStamp; Ended = ($_.Group | Select -Last 1).TimeStamp; Cmdlet = $_.Group[0].Source; TimeTaken = ($_.Group | Measure-Object -Property EllapsedMilliseconds -Sum).Sum; Logs = $_.Group }} | Sort-Object -Property TimeTaken -Descending -Top 5
73+
```
74+
75+
Returns the top 5 longest running cmdlets from the in memory stored log stream. The output is sorted by the TimeTaken property in descending order. The output is limited to the properties Started, Ended, Cmdlet, TimeTaken and Logs. The Logs property contains all logged items for the specific cmdlet
76+
6177
## PARAMETERS
6278

6379
### -Path
6480
The path to the log file. If not provided, the cmdlet will return the in memory log stream.
6581

82+
Note that you cannot read from a log file if it is currently in use to write to. In this case, you would first have to stop logging to it using [Stop-PnPTraceLog](Stop-PnPTraceLog.md) and then read the log file.
83+
6684
```yaml
6785
Type: String
6886
Parameter Sets: Log from file

0 commit comments

Comments
 (0)