Question Analysis
On a Windows endpoint, commands are no longer being logged to PowerShell history, suggesting PSReadLine settings were altered. Using process execution logs, determine the exact command that was run to set the history save style to 'SaveNothing'.
2f898b81-3e97-4abb-bc3f-a95138988370
Question ID
19/23
Models Correct
1
Valid Answer
83%
Success Rate
Reference Answer
Human-validated correct answer for this question
Set-PSReadlineOption -HistorySaveStyle SaveNothing
Model Performance Comparison
See how different AI models performed on this question
Model | Answer | KQL Query | Status | Attempts | Time | Cost |
---|---|---|---|---|---|---|
gemini-2.5-flash-preview-04-17 | Set-PSReadlineOption -HistorySaveStyle SaveNothing | DeviceProcessEvents
| where FileName in ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine has "Set-PSReadLineOption"
| where ProcessCommandLine has "HistorySaveStyle"
| where ProcessCommandLine has "SaveNothing"
| project Timestamp, DeviceName, AccountName, ProcessCommandLine
| order by Timestamp desc | Correct | 1 | 8.44s | 0.0032 |
gpt-35-turbo | Set-PSReadlineOption -HistorySaveStyle SaveNothing | DeviceProcessEvents
| where ProcessCommandLine has 'Set-PSReadLineOption -HistorySaveStyle SaveNothing' | Correct | 1 | 3.08s | 0.0030 |
gpt-4-turbo-2024-04-09 | Set-PSReadlineOption -HistorySaveStyle SaveNothing | DeviceProcessEvents
| where ProcessCommandLine contains 'Set-PSReadLineOption' and ProcessCommandLine contains 'SaveNothing'
| project DeviceName, AccountName, ProcessCommandLine, ProcessCreationTime | Correct | 1 | 10.06s | 0.0518 |
gpt-4.1 | Set-PSReadlineOption -HistorySaveStyle SaveNothing | DeviceProcessEvents
| where (FileName =~ "powershell.exe" or FileName =~ "pwsh.exe")
| where ProcessCommandLine has "Set-PSReadLineOption" and ProcessCommandLine has "-HistorySaveStyle" and ProcessCommandLine has "SaveNothing"
| project TimeGenerated, DeviceName, AccountName, ProcessCommandLine, FileName, FolderPath
| sort by TimeGenerated desc | Correct | 1 | 7.34s | 0.0112 |
gpt-4.1-finetuned | powershell.exe & {Set-PSReadlineOption -HistorySaveStyle SaveNothing} | DeviceProcessEvents
| where ProcessCommandLine contains "Set-PSReadlineOption"
| where ProcessCommandLine contains "HistorySaveStyle"
| where ProcessCommandLine contains "SaveNothing"
| sort by Timestamp desc
| project-reorder Timestamp, DeviceName, InitiatingProcessAccountName, ProcessCommandLine, InitiatingProcessParentFileName, FileName, InitiatingProcessId, ProcessId
| Correct | 1 | 7.70s | 0.0130 |
gpt-4.1-mini | Set-PSReadlineOption -HistorySaveStyle SaveNothing | DeviceProcessEvents
| where ProcessCommandLine contains "HistorySaveStyle" and ProcessCommandLine contains "SaveNothing"
| project TimeGenerated, DeviceName, AccountDomain, AccountName, InitiatingProcessFileName, ProcessName = FileName, ProcessCommandLine
| order by TimeGenerated desc | Correct | 2 | 5.03s | 0.0041 |
gpt-4.1-nano | Set-PSReadlineOption -HistorySaveStyle SaveNothing | DeviceProcessEvents
| where TimeGenerated >= ago(7d)
| where FileName in ('powershell.exe', 'pwsh.exe')
| extend CommandLineLower = tolower(ProcessCommandLine)
| where CommandLineLower contains 'set-psreadlineoption' and CommandLineLower contains 'historysavestyle' and CommandLineLower contains 'savenothing'
| project TimeGenerated, DeviceName, ProcessId, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessId | Correct | 3 | 23.00s | 0.0012 |
gpt-4o | No answer provided | No query generated | Incorrect | 5 | 0.00s | 0.0468 |
gpt-5-high | No answer provided | No query generated | Incorrect | 5 | 0.00s | 0.3618 |
gpt-5-mini-high | "powershell.exe" & {Set-PSReadlineOption -HistorySaveStyle SaveNothing} | let src_proc = DeviceProcessEvents
| where isnotempty(ProcessCommandLine)
| extend CmdLower = tolower(ProcessCommandLine), SourceTable = "DeviceProcessEvents";
let src_evt = DeviceEvents
| where isnotempty(ProcessCommandLine)
| extend CmdLower = tolower(ProcessCommandLine), SourceTable = "DeviceEvents";
union src_proc, src_evt
| where (CmdLower contains "savenothing" and CmdLower contains "historysavestyle")
or (CmdLower contains "set-psreadlineoption" and CmdLower contains "savenothing")
or (CmdLower contains "$psreadlineoptions" and CmdLower contains "savenothing")
| project TimeGenerated, Timestamp, SourceTable, DeviceName, DeviceId,
AccountName = coalesce(AccountName, InitiatingProcessAccountName),
AccountDomain = coalesce(AccountDomain, InitiatingProcessAccountDomain),
AccountUpn = coalesce(AccountUpn, InitiatingProcessAccountUpn),
InitiatingProcessFileName, InitiatingProcessId, InitiatingProcessCommandLine,
ProcessFileName = FileName, ProcessId, OriginalCommandLine = ProcessCommandLine
| sort by TimeGenerated desc
| take 200 | Correct | 4 | 54.59s | 0.0156 |
gpt-5-mini-low | Set-PSReadlineOption -HistorySaveStyle SaveNothing | (
DeviceProcessEvents
| where (
ProcessCommandLine has "HistorySaveStyle"
or InitiatingProcessCommandLine has "HistorySaveStyle"
or ProcessCommandLine has "SaveNothing"
or InitiatingProcessCommandLine has "SaveNothing"
or ProcessCommandLine has "Set-PSReadLine"
or InitiatingProcessCommandLine has "Set-PSReadLine"
or ProcessCommandLine has "Set-PSReadLineOption"
or InitiatingProcessCommandLine has "Set-PSReadLineOption"
or ProcessCommandLine has "PSReadLine"
or InitiatingProcessCommandLine has "PSReadLine"
or ProcessCommandLine has "$Options.HistorySaveStyle"
or InitiatingProcessCommandLine has "$Options.HistorySaveStyle"
or ProcessCommandLine has "PSReadlineOptions"
or InitiatingProcessCommandLine has "PSReadlineOptions"
)
| extend PC = tostring(ProcessCommandLine), IPC = tostring(InitiatingProcessCommandLine)
| extend MatchedCommand = coalesce(
extract("(?i)(Set-PSReadLineOption[^;|&]*)", 1, PC),
extract("(?i)(Set-PSReadLineOption[^;|&]*)", 1, IPC),
extract("(?i)(Set-PSReadLine[^;|&]*)", 1, PC),
extract("(?i)(Set-PSReadLine[^;|&]*)", 1, IPC),
extract("(?i)([^;|&]*HistorySaveStyle[^;|&]*)", 1, PC),
extract("(?i)([^;|&]*HistorySaveStyle[^;|&]*)", 1, IPC),
extract("(?i)([^;|&]*SaveNothing[^;|&]*)", 1, PC),
extract("(?i)([^;|&]*SaveNothing[^;|&]*)", 1, IPC),
PC, IPC
)
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessId, InitiatingProcessId, MatchedCommand, ProcessCommandLine=PC, InitiatingProcessCommandLine=IPC, ReportId
)
| union (
DeviceEvents
| where (
ProcessCommandLine has "HistorySaveStyle"
or InitiatingProcessCommandLine has "HistorySaveStyle"
or ProcessCommandLine has "SaveNothing"
or InitiatingProcessCommandLine has "SaveNothing"
or ProcessCommandLine has "Set-PSReadLine"
or InitiatingProcessCommandLine has "Set-PSReadLine"
or ProcessCommandLine has "Set-PSReadLineOption"
or InitiatingProcessCommandLine has "Set-PSReadLineOption"
or ProcessCommandLine has "PSReadLine"
or InitiatingProcessCommandLine has "PSReadLine"
or ProcessCommandLine has "$Options.HistorySaveStyle"
or InitiatingProcessCommandLine has "$Options.HistorySaveStyle"
or ProcessCommandLine has "PSReadlineOptions"
or InitiatingProcessCommandLine has "PSReadlineOptions"
)
| extend PC = tostring(ProcessCommandLine), IPC = tostring(InitiatingProcessCommandLine)
| extend MatchedCommand = coalesce(
extract("(?i)(Set-PSReadLineOption[^;|&]*)", 1, PC),
extract("(?i)(Set-PSReadLineOption[^;|&]*)", 1, IPC),
extract("(?i)(Set-PSReadLine[^;|&]*)", 1, PC),
extract("(?i)(Set-PSReadLine[^;|&]*)", 1, IPC),
extract("(?i)([^;|&]*HistorySaveStyle[^;|&]*)", 1, PC),
extract("(?i)([^;|&]*HistorySaveStyle[^;|&]*)", 1, IPC),
extract("(?i)([^;|&]*SaveNothing[^;|&]*)", 1, PC),
extract("(?i)([^;|&]*SaveNothing[^;|&]*)", 1, IPC),
PC, IPC
)
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessId, InitiatingProcessId, MatchedCommand, ProcessCommandLine=PC, InitiatingProcessCommandLine=IPC, ReportId
)
| sort by TimeGenerated desc
| take 100 | Correct | 2 | 73.51s | 0.0152 |
gpt-5-mini-medium | Set-PSReadlineOption -HistorySaveStyle SaveNothing | // Find process events where a command sets PSReadLine history to SaveNothing
DeviceProcessEvents
| where Timestamp between (startofday(ago(7d)) .. now())
| where tolower(FileName) in ("powershell.exe", "pwsh.exe", "powershell_ise.exe", "pwsh", "powershell")
or tolower(ProcessCommandLine) contains "set-psreadline" or tolower(ProcessCommandLine) contains "psreadline" or tolower(ProcessCommandLine) contains "HistorySaveStyle"
| where
// match common patterns that set history save style
tolower(ProcessCommandLine) has "set-psreadlineoption" or
tolower(ProcessCommandLine) has "historysavestyle" or
tolower(ProcessCommandLine) has "set-psreadline" or
tolower(ProcessCommandLine) has "psconsolehost" or
tolower(ProcessCommandLine) has "setoptions"
| extend MatchedCommand = ProcessCommandLine
| project Timestamp, DeviceName, AccountName, FileName, ProcessId, InitiatingProcessFileName, InitiatingProcessCommandLine, MatchedCommand
| order by Timestamp desc
| take 100 | Correct | 1 | 19.45s | 0.0046 |
gpt-5-nano-high | Set-PSReadlineOption -HistorySaveStyle SaveNothing | let TimeWindow = 7d;
DeviceProcessEvents
| where TimeGenerated >= ago(TimeWindow)
| where ProcessCommandLine has "Set-PSReadLineOption"
| where ProcessCommandLine has "HistorySaveStyle"
| where ProcessCommandLine has "SaveNothing"
| project TimeGenerated, DeviceName, DeviceId, AccountDomain, AccountName, InitiatingProcessAccountDomain, InitiatingProcessAccountName, InitiatingProcessCommandLine, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCreationTime | Correct | 1 | 40.08s | 0.0025 |
gpt-5-nano-medium | No answer provided | No query generated | Incorrect | 5 | 0.00s | 0.0069 |
grok-3-beta | SaveNothing | DeviceProcessEvents
| where ProcessCommandLine contains "Set-PSReadLineOption" and ProcessCommandLine contains "-HistorySaveStyle SaveNothing"
| project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName
| order by Timestamp desc | Correct | 1 | 8.53s | 0.0200 |
grok-3-mini-beta | "powershell.exe" & {Set-PSReadlineOption -HistorySaveStyle SaveNothing} | DeviceProcessEvents
| where ProcessCommandLine contains "Set-PSReadLineOption -HistorySaveStyle SaveNothing"
| project TimeGenerated, DeviceName, AccountName, ProcessCommandLine
| order by TimeGenerated desc | Correct | 1 | 14.41s | 0.0016 |
o1-high | Set-PSReadlineOption | DeviceProcessEvents
| where FileName in~ ("powershell.exe", "pwsh.exe", "powershell_ise.exe")
| where ProcessCommandLine has_all ("Set-PSReadLineOption", "SaveNothing")
| project TimeGenerated, DeviceName, AccountName, ProcessCommandLine
| order by TimeGenerated desc | Incorrect | 1 | 32.82s | 0.2576 |
o1-low | Set-PSReadLineOption -HistorySaveStyle SaveNothing | DeviceProcessEvents
| where ProcessCommandLine has_all ("Set-PSReadLineOption", "SaveNothing")
| project TimeGenerated, DeviceName, AccountName, ProcessCommandLine
| order by TimeGenerated desc | Correct | 1 | 50.22s | 0.3668 |
o3-high | Set-PSReadlineOption -HistorySaveStyle SaveNothing | // -------------------------------------------------------------
// Detect PowerShell command that disabled history recording
// (Set-PSReadLineOption -HistorySaveStyle SaveNothing)
// -------------------------------------------------------------
let powershell_binaries = dynamic(["powershell.exe","pwsh.exe","powershell_ise.exe"]);
DeviceProcessEvents
| where FileName has_cs "powershell" // only PowerShell interpreters
| where FileName in~ (powershell_binaries)
// ---- Pull out any base-64 encoded payload so we can inspect the real command ----
| extend EncodedCommand = extract(@"(?i)(?:-|/)e(?:ncodedcommand|n|nc)?\s+([A-Za-z0-9+/=]+)", 1, ProcessCommandLine)
| extend DecodedCommand = iff(isnotempty(EncodedCommand), base64_decode_tostring(EncodedCommand), "")
| extend CommandText = iff(isnotempty(DecodedCommand), strcat(ProcessCommandLine, " <<<DECODED>>> ", DecodedCommand), ProcessCommandLine)
// ---- Keep only executions that attempt to change the history save style ----
| where CommandText has "Set-PSReadLineOption" and CommandText has "HistorySaveStyle" and CommandText has "SaveNothing"
// ---- Extract the option-setting statement for quick readability ----
| extend PSReadLineOptionCall = extract(@"(Set-PSReadLineOption[^`r`n;]*)", 1, CommandText)
// ---- Present the evidence ----
| project TimeGenerated,
DeviceName,
AccountName,
FileName,
ExecutedCommand = coalesce(PSReadLineOptionCall, CommandText),
FullProcessCommandLine = CommandText,
FolderPath,
InitiatingProcessAccountName,
InitiatingProcessCommandLine
| sort by TimeGenerated asc | Correct | 2 | 66.32s | 0.0371 |
o3-mini-high | SaveNothing | DeviceProcessEvents
| where (ProcessCommandLine has "SaveNothing" or InitiatingProcessCommandLine has "SaveNothing")
and (ProcessCommandLine has "Set-PSReadlineOption" or InitiatingProcessCommandLine has "Set-PSReadlineOption")
| project TimeGenerated, DeviceName, ProcessCommandLine, InitiatingProcessCommandLine
| order by TimeGenerated desc | Correct | 2 | 30.21s | 0.0233 |
o3-mini-low | SaveNothing | DeviceProcessEvents
| where ProcessCommandLine contains "SaveNothing" or InitiatingProcessCommandLine contains "SaveNothing"
| project TimeGenerated, DeviceName, FileName, FolderPath, ProcessCommandLine, InitiatingProcessCommandLine
| sort by TimeGenerated desc | Correct | 1 | 17.00s | 0.0115 |
o4-mini-high | Set-PSReadlineOption -HistorySaveStyle SaveNothing | DeviceProcessEvents
// Look for PowerShell or PowerShell Core processes
| where FileName in~ ("powershell.exe", "pwsh.exe")
// Identify invocations that disable PSReadLine history logging
| where ProcessCommandLine has "-HistorySaveStyle" and ProcessCommandLine has "SaveNothing"
// Show relevant details
| project TimeGenerated, DeviceName, User = InitiatingProcessAccountName, ProcessCommandLine
| sort by TimeGenerated desc | Correct | 1 | 38.63s | 0.0141 |
o4-mini-low | Set-PSReadlineOption -HistorySaveStyle SaveNothing | DeviceProcessEvents
| where TimeGenerated between (startofday(ago(7d)) .. now()) // adjust time filter as needed or rely on external time picker
| where FileName in ("powershell.exe", "pwsh.exe") // include Windows PowerShell and PowerShell Core
| where ProcessCommandLine has "Set-PSReadLineOption" and ProcessCommandLine has "SaveNothing"
| project TimeGenerated, DeviceName, InitiatingProcessAccountDomain, InitiatingProcessAccountName, InitiatingProcessFileName, ProcessCommandLine | Correct | 1 | 20.80s | 0.0094 |