Skip to content

How to deploy scripts to remote devices with PowerShell, VBScript, batch files

brock profile
Brock Bingham|Updated June 27, 2024
Product 1
Product 1

Scripts have become an essential part of a sysadmin’s device management toolkit. While scripts are useful, executing them against a remote machine isn’t always as easy as it should be. In this walkthrough, we’ll show you how a computer imaging tool with the right features can simplify remote script execution across your fleet.

With SmartDeploy, you can run your PowerShell, VBScript, and batch files against your Windows devices, no matter where they’re located. From simple one-liners to complex automation novellas with enough commands to make the host of the PowerShell Podcast blush, if you can imagine it, you can probably script it.

Important: In SmartDeploy, all Application Pack scripts are executed as the LOCALSYSTEM account and must be fully unattended — no user interaction required.

Download prebuilt script packages

SmartDeploy provides a selection of prebuilt script packages downloadable from the Application Pack Library. The packs are built and maintained by the SmartDeploy team and provide functionality such as shutting down computers, updating Group Policy, and activating Windows.

To download prebuilt script Application Packs:

  1. In the SmartDeploy Console, click Applications & Tasks.

  2. Click the + button, then click Download an Application Pack.

    Click Download an Application Pack

  3. Enter script into the search bar, and press Enter on your keyboard to return only the script Application Packs.

    Enter Script into the search bar to narrow down the results

  4. Select the Application Pack you wish to download, then click Download. You can download as many Application Packs as you need. When finished, click Close.

Once you’ve downloaded the Application Packs, you will find them in your Applications & Tasks workspace.

Viewing scripts in the applications and tasks workspace

How to create custom, automated PowerShell tasks

As its name implies, PowerShell is a very powerful and robust scripting language used to automate many IT management tasks. With PowerShell, sysadmins can interact with and manage almost every aspect of a Windows system. In the example below, we’ll show you how to create an Application Pack to deploy a prebuilt PowerShell Script (.ps1 file) called stop_chrome.ps1.

To build a custom PowerShell task in SmartDeploy:

  1. In the SmartDeploy console, click Applications & Tasks.

  2. Click the + button, then click Create an Application Pack.

    Creating an application pack

  3. At the welcome screen, click Next.

  4. In the Folder Path field, enter the path or browse out to the folder containing the PowerShell script.

  5. In the Executable Path field, enter the path or browse to the PowerShell script.

    Enter the path to the script

  6. Click Next.

  7. Enter your Application Pack details.

  8. Change your Pack Type to Script, then click Next.

    Enter the application pack details

  9. At the Installation Task window, a Command Preview is automatically generated, showing you the command as it'll actually be executed, passing it through powershell.exe with the -ExecutionPolicy Bypassargument added automatically. Review the command, add additional arguments if needed, then click Next.

    Review the generated command

  10. A warning prompt will inform you that the Arguments field is empty if you do not add additional arguments. This is because most silent/unattended commands require additional arguments. In this case, because we are running a PowerShell script that we know will run silently, we don't need to add any arguments. Click Yes to proceed.

    A warning prompt will appear. Click Yes.

  11. Review or set the installed product display name. Ensure Version check is unselected. The Version check setting is designed to limit applications from installing on endpoints that already have the application installed. Since we are deploying a PowerShell script and not installing an application, this setting is not applicable. Click Next.

    Review or set the product display name and unselect version check

  12. Review the summary details, then click Next.

    Review the summary then click next

  13. Click Finish.

  14. Enter a file name for the Application Pack file, then click Save.

    Name and save the application pack

With the Application Pack saved, you'll find it in the Applications & Tasks workspace in the SmartDeploy console. This pack is now ready to be deployed and run against your remote endpoints, which we’ll cover in a later section.

How to create batch and VBScript tasks

If you prefer your scripts a little more old school, SmartDeploy has you covered as well. SmartDeploy can remotely execute your favorite batch and Visual Basic scripts on a remote machine as long as it runs fully unattended. The process is almost identical to creating a custom PowerShell Application Pack. Here’s how it works:

  1. In the SmartDeploy console, click Applications & Tasks.

  2. Click the + button, then click Create an Application Pack.

  3. At the welcome screen, click Next.

  4. In the Folder Path field, enter the path or browse out to the folder containing the batch or Visual Basic script.

  5. In the Executable Path field, enter the path or browse to and select the script.

  6. Click Next.

  7. Enter your Application Pack details.

  8. Change your Pack Type to Script, then click Next.

  9. At the Installation Task window, a Command Preview is automatically generated, which shows you the command as it'll be executed.

    1. Batch file commands should follow this command structure:

      cmd.exe /c “[ApplicationsFolder]\Application Pack\Files\YourBatchScript.bat”
      Batch file generated command

    2. Visual Basic script commands should follow this command structure:

      cscript.exe /b “[ApplicationsFolder]\Application Pack\Files\MyScript.vbs”
      Visual Basic script generated command

  10. A warning prompt will inform you that the Arguments field is empty if you don't add additional arguments. This is because most silent/unattended commands do require additional arguments. In this case, because we are running a script that we know will run silently, we don't need to add any arguments. Click Yes to proceed.

    A warning prompt will appear. Click Yes.

  11. Review or set the installed product display name. Ensure Version check is unselected. The Version check setting is designed to limit applications from installing on endpoints that already have the application installed. Since we are deploying a script and not installing an application, this setting is not applicable. Click Next.

  12. Review the summary details, then click Next.

  13. Click Finish.

  14. Enter a file name for the Application Pack file, then click Save.

How to deploy script packs with SmartDeploy

Now that you've created your script packs, you can easily distribute them with SmartDeploy. Deploying script packs with SmartDeploy follows the same procedure as deploying an Application Pack. Here’s how it works:

  1. In the SmartDeploy console window, click on the Computer Management link.

    Click the Computer Management link

  2. Click All Computers.

    Click All Computers

  3. Select the remote computer you want to execute the script against, then click Deploy Application.

    Select the computer to deploy the script to

  4. Select either Local Network or Cloud Network depending on the location of your device, then click Next.

    Select either local network or cloud network depending on the location of your device

  5. Select the Application Packs or scripts you want to deploy, then use the arrow button to add them to the deployment.

    Select the application pack to deploy

  6. Optionally, you can enable the user to defer the deployment and schedule it for a future date and time.

  7. Click Next.

  8. Enter the credentials necessary to access the selected file location, then click Finish.

    Enter the credentials to access the selected file location then click finish

  9. Click OK when asked to confirm the application deployment.

You can monitor the deployment status by clicking on the computer name of the remote device you deployed to.

Click on the device to monitor the deployment

Inside the computer details windows, scroll down and expand Message History. Here, you’ll find the deployment status.

Click message history to view deployment messages

How to incorporate scripts into your image deployments

Scripts aren’t just great for devices already in production; they’re also handy when imaging computers. SmartDeploy can automate your script deployments during the imaging process, which gives you one less thing to worry about.

SmartDeploy offers two different ways to apply scripts to your image: Application Packs and postdeployment steps.

Let’s look at how to configure each option.

Application Packs

Adding existing Application Packs to an answer file is quick and easy with SmartDeploy. Just use the Answer File Wizard.

  1. In the SmartDeploy console, click on the Activities link.

  2. Click Reimage Devices.

  3. Click Create Answer File to launch the Answer File Wizard.

    Click Create Answer File

  4. With the Answer File Wizard open, advance through each screen, clicking Next to proceed until you reach the Application Packs window.

    Select the applications packs to add to the answer file

  5. Select the app and script packs you want to add, then click the arrow (->) to add them to the answer file.

    Use the arrow to add application packs to the answer file

  6. Click Next, and finishcreating the answer file.

Application and script packs that you include in this section of the answer file install and run after the Sysprep completes.

Postdeployment step

The next option is to save your scripts to your reference VM and then automate your scripts as a postdeployment step during the imaging process. This method gives you precise control over when your scripts execute during the imaging process.

  1. Launch the Answer File Wizard by clicking on Activities > Reimage Devices > Create Answer File.

  2. At the Answer File Wizard welcome window, click Advanced.

    Click advanced

  3. Click the Tasks tab.

  4. Click Add.

    Click Add to add a task

  5. Click the Phase drop-down menu, and select when you want the script to run. For help understanding the different phases, refer to the Answer File Tasks knowledge base.

  6. In the Command line field, enter the command to run your script. It should resemble the commands we used earlier in this article. Here's the command I would use to run a PowerShell script saved on the reference VM at C:\Scripts:

    powershell.exe -ExecutionPolicy Bypass -file "C:\Scripts\MyScript.ps1"
    Remote script command line

  7. Click OK when finished.

With your tasks added, finish running through the Answer File Wizard to complete the process. The resulting answer file is ready to automate your script executions during your future image deployments.


Running scripts gives sysadmins the flexibility and ability to carry out many administrative tasks more effectively. But running scripts against a remote computer (and during imaging no less) can be challenging — especially when users are spread across multiple locations. SmartDeploy can help clear your roadblocks, allowing you to execute scripts on endpoints wherever they are. Take SmartDeploy for a test drive today, and see how it can simplify your device management workflows.

brock profile
Brock Bingham

Born in the '80s and raised by his NES, Brock quickly fell in love with everything tech. With over 15 years of IT experience, Brock now enjoys the life of luxury as a renowned tech blogger and receiver of many Dundie Awards. In his free time, Brock enjoys adventuring with his wife, kids, and dogs, while dreaming of retirement.

Related articles

Ready to get started?

See how easy device management can be. Try SmartDeployfree for 15 days — no credit card required.