Created
March 10, 2016 01:02
-
-
Save avishnyakov/43d30ffacba7523385b8 to your computer and use it in GitHub Desktop.
Bootstrap PowerShell ISE environment with files from the current folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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