# encoding: ascii
# api: powershell
# title: PowerShell Template
# description: I created this function to generate a new PowerShell Script template. I’ve modified it to prompt for the file name, eMail, and finally you can add a comment. The tricky part was trimmimg the comment so it would wrap properly. I use this all the time. Enjoy.
# version: 1.0
# type: function
# author: gmagerr
# license: CC0
# function: New-Script
# x-poshcode-id: 2093
# x-archived: 2011-02-07T01:01:06
#
#
Function New-Script
{
$strName = $env:username
$date = get-date -format d
$name = Read-Host "Filename"
if ($name -eq "") { $name="NewTemplate" }
$email = Read-Host "eMail Address"
if ($email -eq "") { $email="email@mycompany.com" }
$comment=@();
while($s = (Read-Host "Comment").Trim()){$comment+="$s`r`n#"}
$file = New-Item -type file "$name.ps1" -force
$template=@"
###########################################################################
#
# NAME: $name.ps1
#
# AUTHOR: $strName
# EMAIL: $email
#
# COMMENT: $comment
#
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the creator, owner above has no warranty, obligations,
# or liability for such use.
#
# VERSION HISTORY:
# 1.0 $date - Initial release
#
###########################################################################
"@ | out-file $file
ii $file
}
 
Set-Alias new New-Script
