Last active
August 29, 2015 14:05
-
-
Save dfinke/c13549b2798ef1aaea2e to your computer and use it in GitHub Desktop.
Create a new PowerShell script, with correct encoding and edit it in ISE
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
function Edit-NewIseFile { | |
param( | |
[Parameter(ValueFromPipeline=$true)] | |
$Filename, | |
[Switch]$AddFunction | |
) | |
Process { | |
$content="" | |
if($AddFunction) { | |
$content = @" | |
function $FileName { | |
<# | |
.Synopsis | |
A Quick Description of what the command does | |
.Description | |
A Detailed Description of what the command does | |
.Example | |
An example of using the command | |
#> | |
} | |
"@ | |
} | |
if(!$Filename.EndsWith(".ps1")) { | |
$Filename+=".ps1" | |
} | |
if(-not(Test-Path $Filename)) { | |
$content | Set-Content -Encoding Ascii $Filename | |
} | |
if($Host.Name -eq 'ConsoleHost') { | |
ise $Filename | |
} else { | |
psedit $Filename | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment