Hello.
I made the suggested changes, and the error message continues to appear.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello.
I am trying to export the contents of a Custom View from the Event Viewer to a csv file. The first part of the process, for now, involves my interactively outputting to an xml file. The file is sent to the C:\Logs folder.
The next part is a Powershell script designed to output the contents of the xml file to csv format. The name of the script is mghroswl3loginsoutput.ps1, and the code is the following:
# Path to your exported Custom View XML
$xmlPath = "C:\Logs\mghroswl3logins.xml"
# Load the XML filter
[xml]$xmlFilter = Get-Content $xmlPath
# Get events matching the filter
$events = Get-WinEvent -FilterXml $xmlFilter
# Output to CSV
$events |
Select-Object TimeCreated, Id, LevelDisplayName, ProviderName, Message |
Export-Csv "C:\Logs\mghroswl3logins.csv" -NoTypeInformation -Encoding UTF8
The script is located in the C:\Logs folder. The command syntaxes that I have tried are the following:
.\mghroswl3loginsoutput.ps1
.\mghroswl3loginsoutput.ps1 mghroswl3logins.xml
The error message that I am getting is shown below:
Get-Content : Cannot find path 'C:\Logs\C\Logs\mghroswl3logins.xml' because it does not exist.
At C:\Logs\mghroswl3loginsoutput.ps1:5 char:19
+ [xml]$xmlFilter = Get-Content $xmlPath
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Logs\C\Logs\mghroswl3logins.xml:String) [Get-Content], ItemNotFoundE
xception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
Get-WinEvent : Cannot bind argument to parameter 'FilterXml' because it is null.
At C:\Logs\mghroswl3loginsoutput.ps1:8 char:35
+ $events = Get-WinEvent -FilterXml $xmlFilter
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-WinEvent], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetWinEvent
Command
The path in the error message shows a wrong path. How can I correct it?
Hello.
I made the suggested changes, and the error message continues to appear.