Tag Archives: Invoke-Item

Quicktip: PowerShell command history on Windows 10 using PSReadline

In Windows 10 PowerShell 5.0 comes bundled with PSReadline. This module allows for a number of useful features and today we will focus on getting access to the command history. A very useful feature of PSReadline is that it writes the history of PowerShell commands to a text file and this text file is easily accessible. The path where this file is stored can be found by executing the following command:

1
(Get-PSReadlineOption).HistorySavePath

PSReadLine

To view the list of previously executed commands you can type the following:

1
Get-Content -Path (Get-PSReadlineOption).HistorySavePath

This will output the contents of the history file to your PowerShell console. Alternatively the file can be opened by your favorite editor by using the Invoke-Item cmdlet:

1
Invoke-Item -Path (Get-PSReadlineOption).HistorySavePath

A very useful feature if you accidentally closed your console without saving your command history.

Share

Windows 10: Using the Get-WindowsUpdateLog cmdlet

This post is part of the Windows 10 blog series in which I will look at a number of new functionalities in Windows 10 as well as new functionality in PowerShell 5.0. In every article I will highlight a specific cmdlet or technology and provide additional information about the cmdlet

The recently introduced Get-WindowsUpdateLog cmdlet merges the Windows Update logs that are stored in ETL files together into a single plain text log file. The following command can be used to convert these log to a log file:

1
Get-WindowsUpdateLog -LogPath $env:temp\UpdateLog.log

Get-WindowsUpdateLog

Unfortunately the output from this cmdlet is send directly to the host, so it is not possible to store this information in a variable or to interact with it in a meaningful way. I hope this will be corrected before release as it makes it a bit cumbersome to interact with this cmdlet.

The cmdlet works by a three steps process:

  1. Read Information from the .etl files
  2. Convert to intermediate format, either CSV or XML
  3. Convert the intermediate to text and output to the specified logpath

To view the information stored in the intermediate file, which is in a nice structured format the following code can be used:

1
Import-Csv -Path C:\Users\JAAPBR~1\...\wuetl.CSV.tmp.00000

The converted log is available in the specified path, to open the log file in the default text editor, usually notepad, the Invoke-Item can be used:

1
Invoke-Item -Path $env:temp\UpdateLog.log

NotepadWindowsUpdateLog

Get-WindowsUpdateLog
Get-WindowsUpdateLog
Share