Skip to content

Instantly share code, notes, and snippets.

@dfinke
Last active August 29, 2015 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfinke/c13549b2798ef1aaea2e to your computer and use it in GitHub Desktop.
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
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