Skip to content

Instantly share code, notes, and snippets.

@jdhitsolutions
Created December 6, 2016 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdhitsolutions/8e7e2f344808865d07a1fe77a3f90065 to your computer and use it in GitHub Desktop.
Save jdhitsolutions/8e7e2f344808865d07a1fe77a3f90065 to your computer and use it in GitHub Desktop.
A PowerShell function to get the most recent used list. Note that this list isn't updated until you close the ISE.
Function Get-ISEMRU {
[cmdletbinding()]
Param()
<#
Path will be something like:
C:\Users\Jeff\AppData\Local\microsoft_corporation\powershell_ise.exe_StrongName_lw2v2vm3wmtzzpebq33gybmeoxukb04w
#>
$ISEPath = "$env:localappdata\microsoft_corporation\powershell_ise*\3.0.0.0"
Try {
$folder = (Resolve-Path -Path $ISEPath -ErrorAction Stop).Path
}
Catch {
Write-Warning "Failed to get ISE folder from $ISEPath"
Write-Warning $_.exception.message
#Bail out
Return
}
If ($folder) {
#construct the path to user.config
$path = Join-Path -Path $folder -ChildPath "user.config"
#verify the file exists just in case
if (Test-Path -path $path) {
#using -Raw sends everything at once as a huge string
#and boosts performance a bit.
[xml]$xml = Get-Content -Path $path -Raw
#get the MRU setting as a string using an XPath filter
$xml.SelectNodes('//setting[@name="MRU"]').Value.ArrayOfString.string
}
else {
Write-Warning "Can't find $path"
}
} #if $folder
} #end Get-ISEMRU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment