08 Apr

Remote IT Automation with computer scripts: PowerShell, VBScripts, Batch files

With SmartDeploy’s remote IT automation capability, techs can run computer scripts, tasks, and commands on any device, anywhere – whether connected to your corporate network or simply connected to the internet without a VPN connection. Now more than ever, IT has more motivation to find ways to efficiently manage remote devices and keep end users productive, no matter where they are. SmartDeploy enables IT to automate computer scripts to remote devices just as they would if they were in the office or over a remote desktop session, increasing IT efficiency and reach.

In this video, Jeff will show you how to download and execute pre-built computer script packages from the SmartDeploy library. Looking to run a custom computer script or task? Jeff will also guide you through the creation of a custom batch scripts, VBScripts, and PowerShell scripts that you can deploy zero-touch to any endpoint. Tip: Keep scrolling to grab the computer script commands Jeff uses in the video so you can try these on your own.

IMPORTANT: Because computer scripts in an Application Pack are executed as the LOCALSYSTEM account, they must be fully unattended – no user interaction required. This goes for all three script types below.

Deploying computer scripts using Tasks or Application Packs

These tasks can be deployed independently or included in your Answer File to automatically run as a post-deployment task after deploying your Windows golden image. For more information on this visit our knowledgebase article here. SmartDeploy provides pre-built task packs that you can download in the Application & Tasks library within SmartDeploy.

SmartDeploy offers you the ability to remotely deploy your own custom tasks to any endpoint. Follow these steps from the SmartDeploy Console to create your own custom task packs then follow along in the video for specifics about batch scripts, PowerShell, and VBScripts.

Create a custom task using a batch script (.bat)

A batch script (.bat) is a list of commands in a text file that you would type into a standard command prompt. When you execute a batch script, it runs the content of the script in the order they are written. Batch scripts can be good for simple tasks that are required to run on every machine.

  1. In the SmartDeploy Console, visit the Application & Tasks folder, click the +, and click Create an Application Pack.
  2. Pick a location to save your .spk file by clicking File, New, and Save.
  3. In the Application Manager, in the left pane, click the arrow to expand Files and Tasks. Then click Application Pack. Add the Application Pack details (title, publisher, etc.).
  4. Right-click Files and click Add File. Browse to your .bat file and add it to the pack.
  5. To add a task to run the batch script, visit the navigation pane, right-click Tasks, then click Add ‘Run Command’ Task.
  6. In the left pane, click Run Command. In the center pane click Select and then select the .bat file that you just added, and click OK. Note that the executable location has been filled in for you. In order to run your batch script, you’ll need to append cmd /c to the beginning of of the command:

cmd /c [ApplicationsFolder]\Application Pack\Files\BatchScript.bat

  1. Then save and close your pack.

Create a custom task using a PowerShell Script (.ps1)

PowerShell scripts allow users to automate many tasks in Windows and other software, but they are more robust and customizable than other script types. Running PowerShell scripts via the command line or in an Application Pack can be more complicated due to the execution policy on the target machine or the target domain. Luckily it is possible to pass through the execution policy via the command line, and then execute a pre-written PowerShell script stored as a ps1 file.

  1. In the SmartDeploy Console, visit the Application & Tasks folder, click the +, and click Create an Application Pack.
  2. Pick a location to save your .spk file by clicking File, New, and Save.
  3. In the Application Manager, in the left pane, click the arrow to expand Files and Tasks. Then click Application Pack. Add the Application Pack details (title, publisher, etc.).
  4. Right-click Files and click Add File. Browse to your .ps1 file and add it to the pack.
  5. To add a task to run the PowerShell script, visit the navigation pane, right-click Tasks, then click Add ‘Run Command’ Task.
  6. In the left pane, click Run Command. In the center pane click Select and then select the .ps1 file that you just added, and click OK. Note that the executable location has been filled in for you. In order to run your PowerShell script, you’ll need to call the PowerShell executable and specify an execution policy in the command.

Here is a sample command line for script MyScript.ps1 which has been added to the Application Pack:

PowerShell.exe -NoProfile -NonInteractive -ExecutionPolicy bypass -File [ApplicationsFolder]\AppPackName\Files\MyScript.ps1

  1. Then save and close your pack.

Create a custom task using a VBScript (.vbs)

VBScripts allow users to automate many tasks in Windows and other software.

  1. In the SmartDeploy Console, visit the Application & Tasks folder, click the +, and click Create an Application Pack.
  2. Pick a location to save your .spk file by clicking File, New, and Save.
  3. In the Application Manager, in the left pane, click the arrow to expand Files and Tasks. Then click Application Pack. Add the Application Pack details (title, publisher, etc.).
  4. Right-click Files and click Add File. Browse to your .vbs file and add it to the pack.
  5. To add a task to run the VBScript, visit the navigation pane, right-click Tasks, then click Add ‘Run Command’ Task.
  6. In the left pane, click Run Command. In the center pane click Select and then select the .vbs file that you just added, and click OK. Note that the executable location has been filled in for you. In order to run your VBScript, you’ll need to call the Windows script host at the start of the command.

Here is a sample command line for script MyScript.vbs, which has been added to the Application Pack:

wscript.exe [ApplicationsFolder]\Application Pack\Files\MyScript.vbs

  1. Then save and close your pack.

Remote IT automation from SmartDeploy helps you accomplish your IT tasks will less effort and more reliability. If there are scripts of tasks that you wish were pre-built in the library please send your requests to feedback@smartdeploy.com.

Not a SmartDeploy customer yet? Request a customized demo with one of our product specialists. Or, take a self-guided video tour. Then, start your test drive with the fully-functioning SmartDeploy trial.

About the Author

Heidi Flaig
Heidi Flaig has overseen the marketing department for SmartDeploy since 2011 and thrives on engaging with IT professionals to better understand how SmartDeploy products can improve their world. She has over 500 contributions in the Spiceworks community. When she’s not in the office, you can find Heidi hiking with her husband, two sons, and silver lab, Miles.