Skip to content

Commit 409f1b6

Browse files
committed
Fix broken examples
1 parent 2dc6dda commit 409f1b6

4 files changed

Lines changed: 73 additions & 60 deletions

File tree

reference/5.1/Microsoft.PowerShell.Diagnostics/Get-WinEvent.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -556,23 +556,25 @@ $xmlQuery = @'
556556
<QueryList>
557557
<Query Id="0" Path="Windows PowerShell">
558558
<Select Path="System">*[System[(Level=3) and
559-
TimeCreated[timediff(@SystemTime) &amp;lt;= 86400000]]]</Select>
559+
TimeCreated[timediff(@SystemTime) >= 86400000]]]</Select>
560560
</Query>
561561
</QueryList>
562562
'@
563563
Get-WinEvent -FilterXML $xmlQuery
564564
565565
# Using the FilterXPath parameter:
566-
$XPath = '*[System[Level=3 and TimeCreated[timediff(@SystemTime) &amp;lt;= 86400000]]]'
566+
$XPath = '*[System[Level=3 and TimeCreated[timediff(@SystemTime) >= 86400000]]]'
567567
Get-WinEvent -LogName 'Windows PowerShell' -FilterXPath $XPath
568568
```
569569

570570
### Example 17: Use FilterHashtable to get events from the Application log
571571

572572
This example uses the **FilterHashtable** parameter to get events from the **Application** log. The
573573
hash table uses **key/value** pairs. For more information about the **FilterHashtable** parameter,
574-
see [Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable).
575-
For more information about hash tables, see [about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md).
574+
see
575+
[Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable).
576+
For more information about hash tables, see
577+
[about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md).
576578

577579
```powershell
578580
$Date = (Get-Date).AddDays(-2)
@@ -715,8 +717,9 @@ Help.
715717

716718
Use an XML query to create a complex query that contains several XPath statements. The XML format
717719
also allows you to use a **Suppress XML** element that excludes events from the query. For more
718-
information about the XML schema for event log queries, see [Query Schema](/windows/win32/wes/queryschema-schema)
719-
and the XML Event Queries section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
720+
information about the XML schema for event log queries, see
721+
[Query Schema](/windows/win32/wes/queryschema-schema) and the XML Event Queries section of
722+
[Event Selection](/previous-versions/aa385231(v=vs.85)).
720723

721724
```yaml
722725
Type: System.Xml.XmlDocument
@@ -734,8 +737,9 @@ Accept wildcard characters: False
734737

735738
Specifies an XPath query that this cmdlet select events from one or more logs.
736739

737-
For more information about the XPath language, see [XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100))
738-
and the Selection Filters section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
740+
For more information about the XPath language, see
741+
[XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100)) and the
742+
_Selection Filters_ section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
739743

740744
```yaml
741745
Type: System.String
@@ -815,8 +819,8 @@ cmdlet.
815819
> [!NOTE]
816820
> PowerShell does not limit the amount of logs you can request. However, the `Get-WinEvent` cmdlet
817821
> queries the Windows API which has a limit of 256. This can make it difficult to filter through all
818-
> of your logs at one time. You can work around this by using a `foreach` loop to iterate through each
819-
> log like this: `Get-WinEvent -ListLog * | ForEach-Object{ Get-WinEvent -LogName $_.LogName }`
822+
> of your logs at one time. You can work around this by using a `foreach` loop to iterate through
823+
> each log like this: `Get-WinEvent -ListLog * | ForEach-Object{ Get-WinEvent -LogName $_.LogName }`
820824

821825
```yaml
822826
Type: System.String[]
@@ -913,7 +917,8 @@ Accept wildcard characters: True
913917

914918
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
915919
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
916-
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
920+
-WarningAction, and -WarningVariable. For more information, see
921+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
917922

918923
## INPUTS
919924

reference/7.4/Microsoft.PowerShell.Diagnostics/Get-WinEvent.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -558,23 +558,25 @@ $xmlQuery = @'
558558
<QueryList>
559559
<Query Id="0" Path="Windows PowerShell">
560560
<Select Path="System">*[System[(Level=3) and
561-
TimeCreated[timediff(@SystemTime) &amp;lt;= 86400000]]]</Select>
561+
TimeCreated[timediff(@SystemTime) >= 86400000]]]</Select>
562562
</Query>
563563
</QueryList>
564564
'@
565565
Get-WinEvent -FilterXML $xmlQuery
566566
567567
# Using the FilterXPath parameter:
568-
$XPath = '*[System[Level=3 and TimeCreated[timediff(@SystemTime) &amp;lt;= 86400000]]]'
568+
$XPath = '*[System[Level=3 and TimeCreated[timediff(@SystemTime) >= 86400000]]]'
569569
Get-WinEvent -LogName 'Windows PowerShell' -FilterXPath $XPath
570570
```
571571

572572
### Example 17: Use FilterHashtable to get events from the Application log
573573

574574
This example uses the **FilterHashtable** parameter to get events from the **Application** log. The
575575
hash table uses **key/value** pairs. For more information about the **FilterHashtable** parameter,
576-
see [Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable).
577-
For more information about hash tables, see [about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md).
576+
see
577+
[Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable).
578+
For more information about hash tables, see
579+
[about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md).
578580

579581
```powershell
580582
$Date = (Get-Date).AddDays(-2)
@@ -739,8 +741,9 @@ Help.
739741

740742
Use an XML query to create a complex query that contains several XPath statements. The XML format
741743
also allows you to use a **Suppress XML** element that excludes events from the query. For more
742-
information about the XML schema for event log queries, see [Query Schema](/windows/win32/wes/queryschema-schema)
743-
and the XML Event Queries section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
744+
information about the XML schema for event log queries, see
745+
[Query Schema](/windows/win32/wes/queryschema-schema) and the XML Event Queries section of
746+
[Event Selection](/previous-versions/aa385231(v=vs.85)).
744747

745748
You may also create a **Suppress** element using the **FilterHashtable** parameter.
746749

@@ -760,8 +763,9 @@ Accept wildcard characters: False
760763

761764
Specifies an XPath query that this cmdlet select events from one or more logs.
762765

763-
For more information about the XPath language, see [XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100))
764-
and the Selection Filters section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
766+
For more information about the XPath language, see
767+
[XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100)) and the
768+
_Selection Filters_ section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
765769

766770
```yaml
767771
Type: System.String
@@ -841,8 +845,8 @@ cmdlet.
841845
> [!NOTE]
842846
> PowerShell does not limit the amount of logs you can request. However, the `Get-WinEvent` cmdlet
843847
> queries the Windows API which has a limit of 256. This can make it difficult to filter through all
844-
> of your logs at one time. You can work around this by using a `foreach` loop to iterate through each
845-
> log like this: `Get-WinEvent -ListLog * | ForEach-Object{ Get-WinEvent -LogName $_.LogName }`
848+
> of your logs at one time. You can work around this by using a `foreach` loop to iterate through
849+
> each log like this: `Get-WinEvent -ListLog * | ForEach-Object{ Get-WinEvent -LogName $_.LogName }`
846850

847851
```yaml
848852
Type: System.String[]
@@ -939,7 +943,8 @@ Accept wildcard characters: True
939943

940944
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
941945
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
942-
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
946+
-WarningAction, and -WarningVariable. For more information, see
947+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
943948

944949
## INPUTS
945950

reference/7.5/Microsoft.PowerShell.Diagnostics/Get-WinEvent.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ with the asterisk (`*`) wildcard to display each property.
151151

152152
### Example 3: Configure the classic Security log
153153

154-
This command gets an **EventLogConfiguration** object that represents the classic **Security** log.
155-
The object is then used to configure settings for the log, such as max file size, file path, and
156-
whether the log is enabled.
154+
This command gets an **EventLogConfiguration** object that represents the classic **Security** log. The
155+
object is then used to configure settings for the log, such as max file size, file path, and whether the
156+
log is enabled.
157157

158158
```powershell
159159
$log = Get-WinEvent -ListLog Security
@@ -196,18 +196,17 @@ ProviderLatency : 1000
196196
ProviderControlGuid :
197197
```
198198

199-
The `Get-WinEvent` cmdlet uses the **ListLog** parameter to specify the **Security** log. The object
200-
is saved to a variable. The **MaximumSizeInBytes** property is set to 1 gigabyte on the object. The
199+
The `Get-WinEvent` cmdlet uses the **ListLog** parameter to specify the **Security** log. The object is
200+
saved to a variable. The **MaximumSizeInBytes** property is set to 1 gigabyte on the object. The
201201
**SaveChanges** method is called to push the change to the system inside of a try block to handle
202-
access violations. The `Get-WinEvent` cmdlet is called again on the **Security** log and piped to
203-
the `Format-List` cmdlet to verify that the **MaximumSizeInBytes** property has been saved on the
204-
machine.
202+
access violations. The `Get-WinEvent` cmdlet is called again on the **Security** log and piped to the
203+
`Format-List` cmdlet to verify that the **MaximumSizeInBytes** property has been saved on the machine.
205204

206205
### Example 4: Get event logs from a server
207206

208207
This command only gets event logs on the local computer that contain events. It's possible for a
209208
log's **RecordCount** to be null or zero. The example uses the `$_` variable. For more information,
210-
see [about_Automatic_Variables](../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).
209+
see [about_Automatic_Variables](../Microsoft.PowerShell.Core/about/about_automatic_variables.md).
211210

212211
```powershell
213212
Get-WinEvent -ListLog * -ComputerName localhost | Where-Object { $_.RecordCount }
@@ -234,8 +233,7 @@ is a property of the object with a non-null value.
234233

235234
This example gets objects that represent the **Application** event logs on three computers:
236235
Server01, Server02, and Server03. The `foreach` keyword is used because the **ComputerName**
237-
parameter accepts only one value. For more information, see
238-
[about_Foreach](../Microsoft.PowerShell.Core/About/about_Foreach.md).
236+
parameter accepts only one value. For more information, see [about_Foreach](../Microsoft.PowerShell.Core/about/about_Foreach.md).
239237

240238
```powershell
241239
$S = 'Server01', 'Server02', 'Server03'
@@ -347,8 +345,7 @@ This command lists the Event Ids that the **Microsoft-Windows-GroupPolicy** even
347345
along with the event description.
348346

349347
```powershell
350-
(Get-WinEvent -ListProvider Microsoft-Windows-GroupPolicy).Events |
351-
Format-Table Id, Description
348+
(Get-WinEvent -ListProvider Microsoft-Windows-GroupPolicy).Events | Format-Table Id, Description
352349
```
353350

354351
```Output
@@ -508,7 +505,7 @@ is required.
508505

509506
```powershell
510507
Get-WinEvent -Path 'C:\Tracing\TraceLog.etl' -Oldest |
511-
Sort-Object -Property TimeCreated -Descending |
508+
Sort-Object -Property TimeCreated -Descending |
512509
Select-Object -First 100
513510
```
514511

@@ -529,7 +526,7 @@ reading from an `.etl` file, but the **Oldest** parameter applies to each file.
529526

530527
```powershell
531528
Get-WinEvent -Path 'C:\Tracing\TraceLog.etl', 'C:\Test\Windows PowerShell.evtx' -Oldest |
532-
Where-Object { $_.Id -eq '403' }
529+
Where-Object { $_.Id -eq '403' }
533530
```
534531

535532
The `Get-WinEvent` cmdlet gets log information from the archived files. The **Path** parameter uses
@@ -561,24 +558,25 @@ $xmlQuery = @'
561558
<QueryList>
562559
<Query Id="0" Path="Windows PowerShell">
563560
<Select Path="System">*[System[(Level=3) and
564-
TimeCreated[timediff(@SystemTime) &amp;lt;= 86400000]]]</Select>
561+
TimeCreated[timediff(@SystemTime) >= 86400000]]]</Select>
565562
</Query>
566563
</QueryList>
567564
'@
568565
Get-WinEvent -FilterXML $xmlQuery
569566
570567
# Using the FilterXPath parameter:
571-
$XPath = '*[System[Level=3 and TimeCreated[timediff(@SystemTime) &amp;lt;= 86400000]]]'
568+
$XPath = '*[System[Level=3 and TimeCreated[timediff(@SystemTime) >= 86400000]]]'
572569
Get-WinEvent -LogName 'Windows PowerShell' -FilterXPath $XPath
573570
```
574571

575572
### Example 17: Use FilterHashtable to get events from the Application log
576573

577574
This example uses the **FilterHashtable** parameter to get events from the **Application** log. The
578575
hash table uses **key/value** pairs. For more information about the **FilterHashtable** parameter,
579-
see [Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/creating-get-winevent-queries-with-filterhashtable).
576+
see
577+
[Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable).
580578
For more information about hash tables, see
581-
[about_Hash_Tables](../Microsoft.PowerShell.Core/About/about_Hash_Tables.md).
579+
[about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md).
582580

583581
```powershell
584582
$Date = (Get-Date).AddDays(-2)
@@ -600,7 +598,7 @@ that occurred within the last week.
600598
```powershell
601599
$StartTime = (Get-Date).AddDays(-7)
602600
Get-WinEvent -FilterHashtable @{
603-
LogName='Application'
601+
Logname='Application'
604602
ProviderName='Application Error'
605603
Data='iexplore.exe'
606604
StartTime=$StartTime
@@ -766,8 +764,8 @@ Accept wildcard characters: False
766764
Specifies an XPath query that this cmdlet select events from one or more logs.
767765

768766
For more information about the XPath language, see
769-
[XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100))
770-
and the Selection Filters section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
767+
[XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100)) and the
768+
_Selection Filters_ section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
771769

772770
```yaml
773771
Type: System.String
@@ -987,13 +985,13 @@ Environment (Windows PE).
987985

988986
## RELATED LINKS
989987

990-
[about_Automatic_Variables](../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md)
988+
[about_Automatic_Variables](../Microsoft.PowerShell.Core/about/about_automatic_variables.md)
991989

992-
[about_Foreach](../Microsoft.PowerShell.Core/About/about_Foreach.md)
990+
[about_Foreach](../Microsoft.PowerShell.Core/about/about_Foreach.md)
993991

994-
[about_Hash_Tables](../Microsoft.PowerShell.Core/About/about_Hash_Tables.md)
992+
[about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md)
995993

996-
[Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/creating-get-winevent-queries-with-filterhashtable)
994+
[Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable)
997995

998996
[Format-Table](../Microsoft.PowerShell.Utility/Format-Table.md)
999997

reference/7.6/Microsoft.PowerShell.Diagnostics/Get-WinEvent.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -558,23 +558,25 @@ $xmlQuery = @'
558558
<QueryList>
559559
<Query Id="0" Path="Windows PowerShell">
560560
<Select Path="System">*[System[(Level=3) and
561-
TimeCreated[timediff(@SystemTime) &amp;lt;= 86400000]]]</Select>
561+
TimeCreated[timediff(@SystemTime) >= 86400000]]]</Select>
562562
</Query>
563563
</QueryList>
564564
'@
565565
Get-WinEvent -FilterXML $xmlQuery
566566
567567
# Using the FilterXPath parameter:
568-
$XPath = '*[System[Level=3 and TimeCreated[timediff(@SystemTime) &amp;lt;= 86400000]]]'
568+
$XPath = '*[System[Level=3 and TimeCreated[timediff(@SystemTime) >= 86400000]]]'
569569
Get-WinEvent -LogName 'Windows PowerShell' -FilterXPath $XPath
570570
```
571571

572572
### Example 17: Use FilterHashtable to get events from the Application log
573573

574574
This example uses the **FilterHashtable** parameter to get events from the **Application** log. The
575575
hash table uses **key/value** pairs. For more information about the **FilterHashtable** parameter,
576-
see [Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable).
577-
For more information about hash tables, see [about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md).
576+
see
577+
[Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable).
578+
For more information about hash tables, see
579+
[about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md).
578580

579581
```powershell
580582
$Date = (Get-Date).AddDays(-2)
@@ -596,7 +598,7 @@ that occurred within the last week.
596598
```powershell
597599
$StartTime = (Get-Date).AddDays(-7)
598600
Get-WinEvent -FilterHashtable @{
599-
LogName='Application'
601+
Logname='Application'
600602
ProviderName='Application Error'
601603
Data='iexplore.exe'
602604
StartTime=$StartTime
@@ -739,8 +741,9 @@ Help.
739741

740742
Use an XML query to create a complex query that contains several XPath statements. The XML format
741743
also allows you to use a **Suppress XML** element that excludes events from the query. For more
742-
information about the XML schema for event log queries, see [Query Schema](/windows/win32/wes/queryschema-schema)
743-
and the XML Event Queries section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
744+
information about the XML schema for event log queries, see
745+
[Query Schema](/windows/win32/wes/queryschema-schema) and the XML Event Queries section of
746+
[Event Selection](/previous-versions/aa385231(v=vs.85)).
744747

745748
You may also create a **Suppress** element using the **FilterHashtable** parameter.
746749

@@ -760,8 +763,9 @@ Accept wildcard characters: False
760763

761764
Specifies an XPath query that this cmdlet select events from one or more logs.
762765

763-
For more information about the XPath language, see [XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100))
764-
and the Selection Filters section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
766+
For more information about the XPath language, see
767+
[XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100)) and the
768+
_Selection Filters_ section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
765769

766770
```yaml
767771
Type: System.String
@@ -841,8 +845,8 @@ cmdlet.
841845
> [!NOTE]
842846
> PowerShell does not limit the amount of logs you can request. However, the `Get-WinEvent` cmdlet
843847
> queries the Windows API which has a limit of 256. This can make it difficult to filter through all
844-
> of your logs at one time. You can work around this by using a `foreach` loop to iterate through each
845-
> log like this: `Get-WinEvent -ListLog * | ForEach-Object{ Get-WinEvent -LogName $_.LogName }`
848+
> of your logs at one time. You can work around this by using a `foreach` loop to iterate through
849+
> each log like this: `Get-WinEvent -ListLog * | ForEach-Object{ Get-WinEvent -LogName $_.LogName }`
846850

847851
```yaml
848852
Type: System.String[]
@@ -939,7 +943,8 @@ Accept wildcard characters: True
939943

940944
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
941945
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
942-
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
946+
-WarningAction, and -WarningVariable. For more information, see
947+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
943948

944949
## INPUTS
945950

0 commit comments

Comments
 (0)