PoshCode Archive  Artifact [209b18d475]

Artifact 209b18d47518224e8bd81b14468785b84d0e6d4c4c4ec2c2049a9a939c7c8c8c:

  • File PowerShell-Template.ps1 — part of check-in [3863b5ca93] at 2018-06-10 13:25:12 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: Thijs Dirk size: 1690)

# 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
# author: Thijs Dirk
# license: CC0
# function: new-script
# x-poshcode-id: 3406
# x-archived: 2012-05-13T17:00:05
# x-published: 2012-05-09T04:35:00
#
#
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
}