Skip to content

Instantly share code, notes, and snippets.

@avishnyakov
Created March 10, 2016 01:02
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 avishnyakov/43d30ffacba7523385b8 to your computer and use it in GitHub Desktop.
Save avishnyakov/43d30ffacba7523385b8 to your computer and use it in GitHub Desktop.
Bootstrap PowerShell ISE environment with files from the current folder
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
cd "$here"
cls
if($psISE -ne $null)
{
Write-Host "Bootstrapping ISE environment..." -fore Green
$files = [System.IO.Directory]::GetFiles($here)
foreach($file in $files | Sort-Object) {
$fileName = [System.IO.Path]::GetFileName($file)
$existingTab = $psISE.PowerShellTabs | where-object { $_.DisplayName -eq $fileName }
if(!$existingTab) {
Write-Host "`tOpening up : [$fileName]" -fore Green
$tab = $psISE.PowerShellTabs.Add()
$tab.ExpandedScript = $true
$tab.DisplayName = $fileName
$tab.Files.Clear()
$tab.Files.Add($file) | out-null
} else {
Write-Host "`tAlready opened : [$fileName]" -fore Yellow
}
}
Write-Host "Bootstrapping ISE environment finished" -fore Green
} else {
Write-Host "Running outside of IDE environment" -fore red
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment