{"id":13648,"date":"2017-06-14T08:00:55","date_gmt":"2017-06-14T15:00:55","guid":{"rendered":"https:\/\/www.sapien.com\/blog\/?p=13648"},"modified":"2017-06-12T10:32:17","modified_gmt":"2017-06-12T17:32:17","slug":"new-script-engines-for-windows-powershell","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2017\/06\/14\/new-script-engines-for-windows-powershell\/","title":{"rendered":"New Script engines for Windows PowerShell"},"content":{"rendered":"<p>One of the more common tasks for an administrator is to write a script for a helpdesk employee or a fellow admin who is maybe not so PowerShell savvy (yet). Many of you like to package that script as an executable file to prevent the user from \u201cexperimenting\u201d with your code and messing things up in the process.<br \/>\nFrom what we hear, it is quite common for these users to come back and say they only see a flashing window when they try to run your script. Now you have to go and explain that this is a console window flashing and they need to open a console to run that exe or script from there.<br \/>\nAfter wasting this perfectly good explanation you most likely have to go in person and set up a shortcut for the user to do all you just explained.<br \/>\nLet\u2019s face it, PowerShell is a console language, but not everyone is familiar or comfortable with using a console.<\/p>\n<p>So here you are, trying to make your life easier by writing a script only to have to go into either development mode and make that script a GUI application or to go into teaching mode and lecture helpdesk employees on the use of consoles.<br \/>\nIf only there was an easier way \u2026<\/p>\n<p>I did what many do today, I searched the internet for a script and modified it to suit my purpose. So here is my shoutout to Martin Pugh at <a title=\"https:\/\/thesurlyadmin.com\/\" href=\"https:\/\/thesurlyadmin.com\/\">https:\/\/thesurlyadmin.com\/<\/a>, thanks for the network speed script!<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/image.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/image_thumb.png\" alt=\"image\" width=\"640\" height=\"413\" border=\"0\" \/><\/a><\/p>\n<p>Here is what it looks like when you run the script. Pretty simple. The seasoned admins among you know that it gets squirrely when there are many more servers and content scrolls. Consoles have buffer limits and, for some reason, those more inclined to use a mouse, have an inexplicable dislike for anything in a console.<br \/>\nBut wait, Notepad, everyone knows how to use Notepad, right?<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/image-1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/image_thumb-1.png\" alt=\"image\" width=\"640\" height=\"435\" border=\"0\" \/><\/a><\/p>\n<p>Now lets package that script with the Windows Application engine and see what happens.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/image-2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/image_thumb-2.png\" alt=\"image\" width=\"640\" height=\"373\" border=\"0\" \/><\/a><\/p>\n<p>Much better. Anyone familiar with Notepad can handle that.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/SNAGHTML1f7e73f9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"SNAGHTML1f7e73f9\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/SNAGHTML1f7e73f9_thumb.png\" alt=\"SNAGHTML1f7e73f9\" width=\"504\" height=\"270\" border=\"0\" \/><\/a><\/p>\n<p>The File and Edit menus provide the usual functions, you can save the output of your script as a text file, the edit menu can find and copy specific text, so if things go wrong it is quite easy for the user to provide you with actual feedback and error messages.<br \/>\nAdditionally, there is an automatically generated About box in the Help menu which contains all the information you specified in the version resource while packaging.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/image-3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2017\/05\/image_thumb-3.png\" alt=\"image\" width=\"640\" height=\"368\" border=\"0\" \/><\/a><\/p>\n<p>Now you can actually determine what version your users run by asking them to simply go to the about box.<\/p>\n<p>&nbsp;<\/p>\n<p>It took about ten minutes and some minor modifications to make a simple command line script into a Windows Notepad style application.<br \/>\nThere are some limitations of course but we here at SAPIEN think you will find this very useful in enabling others to use your scripts.<\/p>\n<p>As always, if you have any ideas, comments, feedback, please use our feedback forum and reference this post.<br \/>\n<a title=\"https:\/\/www.sapien.com\/forums\/viewforum.php?f=23\" href=\"https:\/\/www.sapien.com\/forums\/viewforum.php?f=23\">https:\/\/www.sapien.com\/forums\/viewforum.php?f=23<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the more common tasks for an administrator is to write a script for a helpdesk employee or a fellow admin who is maybe not so PowerShell savvy (yet). Many of you like to package that script as an executable file to prevent the user from \u201cexperimenting\u201d with your code and messing things up [&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":[1143,703,410,624,21,25],"tags":[1201,581,437,28,1016,37,447,62],"class_list":["post-13648","post","type-post","status-publish","format-standard","hentry","category-powershell","category-powershell-studio","category-primalscript-software-news","category-service-build","category-software-news","category-windows-powershell","tag-engine","tag-notepad","tag-packager","tag-powershell","tag-powershell-studio","tag-primalscript","tag-script","tag-windows"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/13648","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=13648"}],"version-history":[{"count":8,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/13648\/revisions"}],"predecessor-version":[{"id":13670,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/13648\/revisions\/13670"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=13648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=13648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=13648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}