Here is the String in question, used in the Invoke PowerShell activity to make a PowerShell script: String.Format("wevtutil epl {0} {1}\Data\Output\{4}-eventviewer.evtx ""/q:*[System[TimeCreated[@SystemTime>='{2}{3}' and @SystemTime<'{4}{5}'] and (Level={6})]]""", in_Config("LogType").ToString, IO.Directory.GetCurrentDirectory.ToString, in_Config("StartDate").ToString, in_Config("StartTime").ToString, in_Config("EndDate").ToString, in_Config("EndTime").ToString,in_Config("LogLevel").ToString)
Here is an example of how this String should come out: wevtutil epl Application C:\Users\moranj\Downloads\WindowsLogExtract\Data\Output\2023-01-31-eventviewer.evtx "/q:*[System[TimeCreated[@SystemTime>='2023-01-29T00:00:00' and @SystemTime<'2023-01-29T00:00:00'] and (Level=2)]]"
However, once the program is running, both the String with Config values and the example String get backslashes added to them out of nowhere! Observe the Locals value below:
Using the Start Process activity instead yields the same result. The main problem is the backslash that gets added before the first set of double quotes, though it is worth noting that another backslash gets unexpectedly added at the end. What is causing this to happen?
In locas just for visibility or in the backend it adds that backslash as an escape character…it is not actually added…as you added double double wuotes to escape …when it saves to eacape it adds a balckshash…hope this is clear
If you are facing any issue then please check what is wrong with the details
The issue that occurs is that the wevtutil command fails to extract all of the logs specified. In the example I provided, the resulting evtx file should extract all three error logs that exist within that time frame… however, it only extracts one of them. What are your thoughts on this?
No, using Invoke PowerShell I am only getting one. But when I apply the same conditions in Event Viewer myself, I get 3. Does this mean the activity itself has an issue?
The activity does not have an issue but the power shell script you wrote might have a issue or may be we are filtering out the records some how…if in power shell you are getting 1 then in UiPath also you will get only one
Very true… looks like it wouldn’t be an issue with the properties after all. This likely confirms that my PowerShell script itself is erroneous in some unforeseen way. Thank you for helping me figure this out! I will take this issue to Stack Overflow since this has become a PowerShell specific problem.
If you have the knowledge for it, any script recommendations would be much appreciated! I will keep the topic open just in case you are able to come up with something.
With the help of @Anil_G I have found the answer: As he mentions below, the backslashes don’t actually do anything; they are just UiPath’s way of processing my String. The actual issue was the command itself: I had failed to account for time zones! This is why my extracted logs, and the logs I was seeing in Event Viewer for the same time period, did not match up. The above command is still correct, but you must specify to your end user that their input should be in UTC time, NOT your timezone.