PoshCode Logo PowerShell Code Repository

PowerShell Template (modification of post by Gene Magerr view diff)
View followups from Gene Magerr | diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/778"></script>download | new post

I’ve modified the original function. I like this one better.

  1. Function New-Script
  2. {
  3. $strName = $env:username
  4. $date = get-date -format d
  5. $name = Read-Host "Filename"
  6. if ($name -eq "") { $name="NewTemplate" }
  7. $email = Read-Host "eMail Address"
  8. if ($email -eq "") { $email="youremail@yourhost.com" }
  9. $file = New-Item -type file "$name.ps1" -force
  10. $template=@"
  11. ###########################################################################"
  12. #
  13. # NAME: $name.ps1
  14. #
  15. # AUTHOR: $strName
  16. # EMAIL: $email
  17. #
  18. # COMMENT:
  19. #
  20. # You have a royalty-free right to use, modify, reproduce, and
  21. # distribute this script file in any way you find useful, provided that
  22. # you agree that the creator, owner above has no warranty, obligations,
  23. # or liability for such use.
  24. #
  25. # VERSION HISTORY:
  26. # 1.0 $date - Initial release
  27. #
  28. ###########################################################################"
  29. "@ | out-file $file
  30. ii $file
  31. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me