Sonntag, 14. Februar 2010

Which files are loaded in PowerShell ISE

Here is a small function to give you information about the state of the files you have loaded into the different tabs and editors of ISE:

function Get-ISELoadedFiles () {            
$tabcount = 0
foreach ($Tab in $psise.PowerShellTabs)
{
if ($Tab -eq $psise.CurrentPowerShellTab) { $currentTab = '*' } else { $currentTab = ' ' }
$filecount = 0
if ($tab.CanInvoke) { $tabmarker = " $tabcount "} else { $tabmarker = "($tabcount)"}
"{0} -----{1} {2} ----- {3}" -f $currentTab, $tabmarker, $Tab.DisplayName, $tab.Prompt
$Tab.Files | %{
if ($_ -eq $psIse.CurrentFile) { $currentFile = '*' } else { $currentFile = ' ' }
if ($_.IsSaved) {$filemarker = "$filecount " } else {$filemarker = "$filecount*" }
"{0} {1} {2}" -f $currentFile, $filemarker, $_.fullpath
$filecount++
}
$tabcount++
}

}



It seems to be a little difficult to find out whether a tab is local or remote and if remote to which machine it is connected. Please drop a coment, if you have hints.

Thanks

Bernd
(or on twitter @bernd_k)

Keine Kommentare:

Kommentar veröffentlichen