PoshCode Archive  Artifact [000b2f1940]

Artifact 000b2f1940495021e4dee06ab59b31be68712df02a070fbb11c8b553bee4a379:

  • File PowerShell-Template.ps1 — part of check-in [8249cddfcc] at 2018-06-10 13:08:03 on branch trunk — I created this function to generate a new PowerShell Script template. It will prompt for the name of the script you want to create (don’t need to add the .ps1 extension) and the email (don’t need to add email) then it will create the template in the C:\Scripts directory (Dir should already exist) (user: unknown size: 1632)

# encoding: ascii
# api: powershell
# title: PowerShell Template
# description: I created this function to generate a new PowerShell Script template. It will prompt for the name of the script you want to create (don’t need to add the .ps1 extension) and the email (don’t need to add email) then it will create the template in the C:\Scripts directory (Dir should already exist)
# version: 1.0
# type: function
# license: CC0
# function: new-script
# x-poshcode-id: 2272
# x-archived: 2011-02-07T00:59:27
#
#
Function new-script
{
$strName = $env:username
$date = get-date -format d
$name = Read-Host "Filename"
$email = Read-Host "eMail Address"
$file = New-Item -type file "c:\Scripts\$name.ps1" -force
add-content $file "#=========================================================================="
add-content $file "#"
add-content $file "# NAME: $name.ps1"
add-content $file "#"
add-content $file "# AUTHOR: $strName"
add-content $file "# EMAIL: $email"
add-content $file "#"
add-content $file "# COMMENT: "
add-content $file "#"
add-content $file "# You have a royalty-free right to use, modify, reproduce, and"
add-content $file "# distribute this script file in any way you find useful, provided that"
add-content $file "# you agree that the creator, owner above has no warranty, obligations,"
add-content $file "# or liability for such use."
add-content $file "#"
add-content $file "# VERSION HISTORY:"
add-content $file "# 1.0 $date - Initial release"
add-content $file "#"
add-content $file "#=========================================================================="
ii $file
}