- 27 Sep 2023
- 4 Minutes to read
Deploy PowerShell scripts using Scalefusion
- Updated on 27 Sep 2023
- 4 Minutes to read
Windows PowerShell is a powerful tool for automating tasks and simplifying configuration and can be used to automate almost any task in the Windows ecosystem. With a carefully designed script, you can automate the process of adding network drives, installing apps, updating security software, and granting a new user access to shared files. It is no wonder that it has become a popular tool among system admins and experienced Windows users.
Moving a step forward towards enhancing Windows Device Management, Scalefusion MDM enables uploading PowerShell script files and then executing those scripts remotely on Scalefusion managed Windows devices.
This document describes how PowerShell scripts can be uploaded and deployed on managed Windows devices.
- Create a Windows Device Profile
- Enroll a Windows 10 or above device with Scalefusion
- Supported OS Configurations:
- Windows 10 version 1809 and above, with Windows Pro, Business, Enterprise, Education, Home editions.
- Windows 7 and 8.1Windows OS 7 and 8.1 and Windows Home (10 & 11) devices should be enrolled with Scalefusion MDM agent
- Scalefusion MDM agent's latest version is installed on the enrolled Windows device.
- Make sure that you have required storage in Enterprise Store. To know more about space allocation, please visit here.
- Enterprise App package and the following details from the developer,
- Powershell script (.ps1) file
- File size should be less than 1GB
Uploading and Installing a Powershell script
Follow the steps below to upload and install a Powershell script,
- Sign In to Scalefusion Dashboard. Navigate to Application Management > Enterprise Store
- Click on Upload New App > Upload Windows App
- Choose PowerShell(PS1) to upload ps1 file that will execute the script.
- Selecting the PowerShellwould start the Upload Windows Powershell Scripts wizard. Follow the steps below to upload the file.
- Enter PowerShell Script Name: Used to identify in Device Profiles
- Upload Powershell Scripts File: Select how you want to upload the script file,
- Upload Local File: Use this option if you have the ps1 file available locally.
- PS Script file URL: Use this option if you have hosted/uploaded the file on your servers and have a link that is accessible publicly. Provide the URL to the externally hosted file. This URL should be publicly available.
- Execution Level: Select one from the following:
- Device: The script will be executed for all existing users on the device
- User: The script will be executed for the enrolled user or all users depending upon the execution context you select in the next drop-down.
- Execution Context: Select one from the following:
- Enrolled User (selected by default): Script will be executed only for enrolled user
- All Users: Script will be executed for all the users on device
- Execution Schedule: Configure a schedule when you want the script to be executed.
- Run Once on Publish: Script will run as soon as you publish it from Dashboard
- Run At Every Login: Script will run every time a user logs in to the device
- Run on Schedule: You can select on which days the script should be executed.
- Select Day: Select day(s) from Monday to Sunday.
- Configure Time(s): You can set a time for executing the script and can add multiple time periods.
- Click Save
- Once you click on SAVE, Scalefusion will process the script, and if the processing succeeds then the following dialog will be shown. Here you can select the Device Profiles where you want to publish the script and click Publish.
Checking Execution Status
After publishing, you can check the status whether the powershell script pushed from enterprise store has been executed or not, by using the View Status option.
A script that is well executed on the device, shows the status as Executed and if not then the status shows as Pending or Execution Failed.
The Powershell script executed will reflect on the device. For example, in the above step, we have uploaded a script to Enable Windows Update. After publishing, on the enrolled device, open the Services app.
You will find Windows Update in Automatic Trigger start mode enabling the detection, download, and installation of updates for Windows and other programs.
If you wish to disable Windows Update on the device, there is a Powershell script for the same. Simply upload the script file to disable Windows update following same steps and publish it. Once executed it will reflect on the managed device under Services app and disable the detection, download and installation of updates for Windows and other programs.
Uninstalling PowerShell Script
PowerShell scripts cannot be uninstalled from the devices remotely. However you can block the execution of the scripts on devices that are yet to enroll. Follow the steps below to Uninstall a previously deployed script,
- Navigate to Application Management > Enterprise Store
- Click on the PowerShell script that you uploaded earlier to see the script information wizard, Click on Uninstall
- Select the Device Profiles where you want to uninstall the application and click on Uninstall
- Once this step is done, the script will no longer be force installed and executed on the devices. However, the users need to Uninstall the application on the device.
Deleting PowerShell Script
- In the script information wizard, Click on the Delete button
- You will get a confirmation box. Click OK
The script file will get deleted from Enterprise Store on the Scalefusion dashboard.
The PowerShell scripts are static in nature that is the same script gets executed on all devices, however, in some cases, the admin may want to pass some dynamic values based on the device or user of the device where the script is executing. Scalefusion now extends the support of Custom Fields to allow for dynamic substitution using our agent. For example,
To know more about the Custom Fields feature and how to use it please refer to our guide here.