{"id":6964,"date":"2014-04-28T05:00:00","date_gmt":"2014-04-28T13:00:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=6964"},"modified":"2014-03-14T15:16:18","modified_gmt":"2014-03-14T23:16:18","slug":"dont-always-start-from-scratch","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2014\/04\/28\/dont-always-start-from-scratch\/","title":{"rendered":"Don&rsquo;t always start from scratch"},"content":{"rendered":"<p>We use scripting to automate tasks that would otherwise be very repetitive. However, when it comes to creating a script most users start with a blank slate, an empty file. Then they hunt for copy and paste sources to start and the script fills with bits and pieces from other places. Next time a new script needs to be created, the same process starts all over again.<\/p>\n<p>We have added a tiny little improvement to PrimalScript 2014 that might just make it easier for you to get started on a new script. You can save any file you have as a template with the content you want and need and the encoding your environment requires.<\/p>\n<p>Let\u2019s demonstrate.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/03\/image12.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/03\/image_thumb4.png\" width=\"640\" height=\"347\" border=\"0\" \/><\/a><\/p>\n<p>We create a new PowerShell file from our default templates.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/03\/image13.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/03\/image_thumb5.png\" width=\"640\" height=\"227\" border=\"0\" \/><\/a><\/p>\n<p>Maybe you don\u2019t like our header, maybe you need some functions in there that you always use. Just modify as desired.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/03\/image14.png\" width=\"471\" height=\"287\" border=\"0\" \/><\/p>\n<p>Now select \u201cSave as template\u201d from the backstage menu and give a fancy name. Make sure you use the correct extension, because that will determine the syntax coloring when you create a new file with that template.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/03\/image15.png\" width=\"271\" height=\"314\" border=\"0\" \/><\/p>\n<p>In our example here we will name the file \u201cMy own PowerShell Template.ps1\u201d<\/p>\n<p>You can then close the file, or use it as a base for further templates you want to create. That\u2019s up to you.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" alt=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/03\/image16.png\" width=\"554\" height=\"237\" border=\"0\" \/><\/p>\n<p>We used a list style control rather than big icons so you have more room for many templates and it also allows you to use longer, more descriptive names.<\/p>\n<p>Questions? Comments? Suggestions? Head on over to our <a href=\"http:\/\/www.sapien.com\/forums\/viewforum.php?f=5\" target=\"_blank\">support forum<\/a> and and let\u2019s hear it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We use scripting to automate tasks that would otherwise be very repetitive. However, when it comes to creating a script most users start with a blank slate, an empty file. Then they hunt for copy and paste sources to start and the script fills with bits and pieces from other places. Next time a new [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[410,21,25],"tags":[28,800,81],"class_list":["post-6964","post","type-post","status-publish","format-standard","hentry","category-primalscript-software-news","category-software-news","category-windows-powershell","tag-powershell","tag-primalscript-2014","tag-templates"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/6964","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=6964"}],"version-history":[{"count":3,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/6964\/revisions"}],"predecessor-version":[{"id":6979,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/6964\/revisions\/6979"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=6964"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=6964"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=6964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}