The run on server functionality allows the tool to execute a script on the server hosting SoftwareCentral. VBScripts and PowerShell Scripts are supported.
You can read more about executing and debugging scripts from the Shops Custom Actions guide.
You can upload a new script or you can select an existing one. Scripts are stored in the “<SoftwareCentral-install-dir>\Uploads\CustomScripts\”-folder.
For this example, we want a script that refreshes the machine policy on a client. There is an example scripts in the CustomScripts folder named “RefreshMachinePolicyExample.ps1”.
This script needs to be modified. Follow the steps below:
1. Copy the script to a new location, your desktop for instance.
2. Rename the script. (The example scripts will be overwritten by SoftwareCentral)
3. Open the renamed script with an editor, e.g. Notepad.
4. Change the variables $SccmServerName and $SccmSiteCode to match your own SCCM server and site code. If you have multiple sites, use the CAS site.
5. Save the script.
Now go back to SoftwareCentral and click on the “Select”button next to the “Upload script”.
Browse to your script and select it.
Scripts does not automatically run in the context of the application pool user. For each script, you will have to select the user that runs the script.
Note that when debugging scripts or if you require that the script can write to the SoftwareCentral log, it must run as the application pool user. |
Make sure that the account has the proper permissions to execute the script. If the script interacts with databases or other resources, the account will also need the proper permissions to access those resources.
Accounts other than the application pool user must also have the "Log on as a batch job" permission, either from the Local Security Policy on the IIS server or via a group policy.
The application pool user must always have the "Replace a process level token", "Adjust memory quotas for a process" and "Act as part of the operating system" permissions.
Our Refresh Machine Policy script requires locale administrative permissions on the client computers and access to the SCCM. Therefore we will use the SoftwareCentral service account, which does already have these permissions.
As this is a PowerShell Script we will change the arguments to “Powershell.exe”.
The refresh machine policy script needs one parameter, a computer. Select the computers drop-down box. This will give the user the possibility to select a computer.
The drop-downs in this window are just an example of what the user will see.
You can choose 5 types of predefined parameters.
Computers- will add a drop-down box where the user can select a computer. The parameter passed to a
VBScript is /ResourceID:value
and
PowerShell Script is -ResourceID value
For SCCM devices, the value is an integer. For Intune devices, the value is a string and the ID is the Managed device ID.
Computers2- will add a drop-down box where the user can select a computer. The parameter passed to a
VBScript is /SecondResourceID:value
and
PowerShell Script is -SecondResourceID value
For SCCM devices, the value is an integer. For Intune devices, the value is a string and the ID is the Managed device ID.
Users - will add a drop-down box where the user can select a user. Note that the user list comes from the SCCM user discovery and not the Active Directory. The parameter passed to a
VBScript is /Username:value
and
PowerShell Script is -Username value
The value is a string in the format “domain\username” for on premise active directories. For Azure AD, it is the user principal name.
Packages - will add a drop-down box where the user can select a package or application. The parameter passed to a
VBScript is /PackageID:value
and
PowerShell Script is -PackageID value
The value is a string with the SCCM/Intune package id.
Text- will add a textbox where the user can type any parameter. Note that what the user writes in this textbox will be added directly to the parameters line. So the user can add his own parameter and send to the script, e.g.: “-ComputerName MyComputer”.
You can additionally add any Software Variable to your tool. The name and the value of the variable will be passed on to the script.
The order the Software Variables will appear to the user can be changed by dragging the variables in the listbox.
The parameters will be added to the script as follows:
[arguments] [“scriptPath\scriptName”] [parameters]
VBScript example:
“Cscript.exe //b “C:\inetpub\SoftwareCentral\Uploads\CustomScripts\YourScript.vbs”/ResourceID:123456 /Username:domain\username”
PowerShell Script example:
“PowerShell.exe -file “C:\inetpub\SoftwareCentral\Uploads\CustomScripts\YourScript.ps1”-ResourceID 123456 -Username domain\username”
See the guide “Custom Actions” for more information on how to execute scripts from SoftwareCentral.
Click on the “Save”button to save button to save the tool.
You will now see the Refresh Machine Policy function from the “Manage Tools”interface.
The new tool will also show from the Tools menu. See the chapter “Use Tools” in this guide.