Custom PowerShell plugin
Run user-created PowerShell scripts on Relay Agents.
Note: This plugin is an on-premises plugin.

An on-premises plugin connects a service running in your internal network to SquaredUp. They require an agent installed on a machine that has access to your internal network.
How to add the Custom PowerShell plugin
Configure and deploy an agent
If you have already created an agent in SquaredUp that you can use for this plugin, you can skip this step and choose the agent group you want to use while adding the plugin.

Create a unique API key for your agent and add the agent to an agent group in SquaredUp.
You create an API key by creating an agent in SquaredUp:
Go to Settings > Relay and add an Agent.
Give the new agent a name and a description that helps you identify where the agent is installed. For example:
Name: server1.domain.localDescription: Test server in production domain
Choose the Agent Group for this agent:
If you already have agent groups, assign it to an existing group and click create.
If you don't have any agent groups yet or want to assign the new agent to a new group, leave the Agent Groups field empty and click create. Then create the agent group by clicking on Add Agent Group and select the new agent in the Agents field for the new group.
After you created the agent, the API key for this agent will be shown to you. Copy the key and store it until you inserted the key into the configuration of the agent you want to deploy on your machine.
The API key will only be displayed to you once. If you lose this API key, you need to generate a new one (by creating a new agent) and any references to the old API key in the configuration of the agent you deployed on your machine will need to be updated.
- The Agent status will show as gray until the next stage of configuring the service is completed successfully.
Deploy the agent on a machine that has access to the service the plugin connects to.
Download the latest release of the SquaredUp Agent zip file, by clicking the download icon under Options next to the Agent you have just added.
Prerequisites for Agents
The Agent needs to run on a Windows machine that has access to the data source for the on-premises plugin
Make sure the Agent is able to make outbound connections on port 443 (no inbound required) to SquaredUp and Microsoft APIs (Azure Relay).
Optional DNS-based restrictions: *.servicebus.windows.net
On a Windows machine, with access to the data source your plugin needs to use, extract the downloaded zip file.
In the directory of the extracted zip file, open PowerShell as an administrator and run the following command:
Copy./Install-SQUPAgent.ps1 -ApiKey "key" -AsService -ServiceSuffix "name" -ServiceAccount domain\username
Parameters to replace:
-ApiKey "key"
Mandatory Replace key
with the API key you created for the Agent in SquaredUp-AsService
Recommended Run the Agent as a service on the machine -ServiceSuffix "name"
Optional To change the default service name of squpagent replace name
with your new service name.-ServiceAccount domain\username
Optional To run the Agent as a domain service account (for example, for the SCOM plugin), provide the username as domain\username
and it will prompt for the password when it sets up the serviceConfigure a domain service account using the installation script, for example:
./Install-SQUPAgent.ps1 -ApiKey "key" -AsService -ServiceAccount domain\username
where
key
is the API key, anddomain\username
is the domain service accountAlternatively, in Services > SquaredUp Cloud Agent > Properties select the account on the Log On tab.
Use a dedicated user account for the agent's service identity. Create a special service account for this domain service account, do not use an existing user account.
The account (typically a service account) needs to have the log on as a service permission.
Adjust any permissions for the service and start the service.
How to start the Agent service
You can start the agent service from Services > SquaredUp Cloud Agent, or using PowerShell using either:
Start-Service -Name <ServiceName>
Where
<ServiceName>
should be replaced with the service name shown in brackets in the upgrade script output (or Properties of the service).For example:
Start-Service -Name squpagent
or
Start-Service -DisplayName <DisplayName>
Where
<DisplayName>
should be replaced with the service name shown before the brackets in the upgrade script output (or Properties of the service).How to find the Agent folder location or Service name in Properties
Look at the Properties of the SquaredUp Cloud Agent service:
On the server running the Agent, open Services
Scroll down to the SquaredUp Cloud Agent in the list
Right-click on the SquaredUp Cloud Agent service and then Properties
Here you can see the Service name, Display name and Path to the Agent folder.
You can also start or stop the service from here.
- Check the Agent status in SquaredUp Settings > Relay
Running the Agent as a domain service account
By default, the SquaredUp agent service uses the local system identity, but this can be changed to a domain service account if required, for example for the SCOM plugin.
Create the PowerShell scripts and store the files on the machine in a folder readable by the agent.
Your PowerShell scripts can serve two different functions:
Import script: In case you need to import new objects into SquaredUp, you need an import script. This script contains the definitions for objects and their links in the Knowledge Graph. There can only be one import script per Custom PowerShell plugin. Tip: You can add more Custom PowerShell plugins to SquaredUp if you want to use different import scripts, and they can all use the same folder.
Data Stream script: All other scripts are Data Stream scripts. Those scripts contain the different Data Streams you want to use when you are creating tiles for a dashboard.

Import scripts return objects to SquaredUp using the following format:
Import scripts write objects to SquaredUp in the following format:
@{
vertices = @()
edges = @()
}
Example import script
Information about parameters in the script:
Vertex (vertices create objects in SquaredUp)
name | string – the name of the vertex |
sourceId | string – a unique ID identifying the vertex |
type | string – the high-level type of the vertex Note: A lot of types are already pre-defined in SquaredUp, which means they will be displayed properly with an icon etc. To make sure the type you're using matches with a pre-defined one, use lowercase only, one word without hypens, and the singular form (for example loadbalancer, apidomain, dnsrecord). If your type isn't recognized, you can add it as a custom type, see Types and Custom Types. |
sourceType | string – a type for the vertex pertinent to your specific use-case |
other properties | You can use any other properties of use in your specific use-case |
Edges (edges create links between objects in SquaredUp):
label | string – the type of edge |
inV | string – the sourceId value of the vertex the edge enters |
outV | string – the sourceId value of the vertex the edge leaves |
get-objects.ps1:
@{
vertices = @(Get-CimInstance -Class Win32_LogicalDisk |
? { $_.DriveType -eq 3 } |
%{
[PSCustomObject]@{
name = ('{0} {1}' -f $_.SystemName,$_.Name)
sourceId = ('\\{0}\root\cimv2:Win32_LogicalDisk.DeviceID="{1}" ({2})' -f $_.SystemName,$_.Name,$_.VolumeSerialNumber)
type="storage"
sourceType="volume"
FileSystem = $_.FileSystem
Compressed = $_.Compressed
Size = $_.Size
}
})
edges = @()
}

Data Stream scripts return objects to SquaredUp using the following format:
Data Stream scripts return data as a simple array of objects:
@()
Example Data Stream script
Note: To be able to use the Data Stream script you also need to create a custom Data Stream that calls your Data Stream script. This is done in the SquaredUp UI via Settings > Data Streams. The format of the result objects of your script needs to match the columns you've defined in the custom Data Stream.
get-diskFreeSpace.ps1:
Param(
[Parameter(Mandatory=$true)]
$scope
)
$targetObjectsBySourceId = @{}
foreach ($targetObject in $scope) {
$targetObjectsBySourceId[$targetObject.sourceId[0]] = $targetObject
}
$results = (Get-CimInstance -Class Win32_LogicalDisk |
? { $_.DriveType -eq 3 } |
%{
$sourceId = '\\{0}\root\cimv2:Win32_LogicalDisk.DeviceID="{1}" ({2})' -f
$_.SystemName,$_.Name,$_.VolumeSerialNumber
if ($targetObjectsBySourceId.ContainsKey($sourceId)) {
[PSCustomObject]@{
name = ('{0} {1}' -f $_.SystemName,$_.Name)
Size = $_.Size
FreeSpace = $_.FreeSpace
}
}
})
return $results
Add the custom PowerShell plugin in SquaredUp.
In SquaredUp browse to Settings > Plugins > Add plugin and search for the plugin.
Display Name:
Enter a name for your plugin. This helps you to identify this plugin in the list of your plugins.
Scripts Directory:
Enter the path to the directory where you store the PowerShell scripts on the machine you deployed the agent on.
Note: The path must be written as an absolute path, for examplec:\Scripts\SquaredUp Cloud
or, if you are using a network share,\\fs01\Scripts\SquaredUp Cloud
Import Script:
Optional. If you want to use a script for importing objects into SquaredUp, you can specify that script here by entering its full file name, for exampleget-objects.ps
.
Note: The import script must be stored in the same directory you defined above.“Only allow signed scripts” check-box:
If you check this box, no unsigned PowerShell scripts will be executed. This applies to all scripts run by the plugin, not just the import script.
Agent Group:
Select the Agent Group that contains the agent(s) you want to use.
Leave the checkbox for Automatically create a workspace ticked, this will create a new workspace for this plugin containing out of the box dashboards and scopes.
Optionally, select whether you would like to restrict access to this plugin instance. By default, restricted access is set to off.
Restrict access to this plugin?
The term plugin here really means plugin instance. For example, a user may configure two instances of the AWS plugin, one for their development environment and one for production. In that case, each plugin instance has its own access control settings.
By default, Restrict access to this plugin? is set to off. The plugin can be viewed, edited and administered by anyone. If you would like to control who has access to this plugin, switch Restrict access to this plugin? to on.
Use the Restrict access to this plugin? dropdown to control who has access to the workspace:
By default, the user setting the permissions for the plugin will be given Full Control and the Everyone group will be given Link to workspace permissions.
Tailor access to the plugin, as required, by selecting individual users or user groups from the dropdown and giving them Link to workspace or Full Control permissions.
If the user is not available from the dropdown, you are able to invite them to the plugin by typing in their email address and then clicking Add. The new user will then receive an email inviting them to create an account on SquaredUp Cloud. Once the account has been created, they will gain access to the tenant.
At least one user or group must be given Full Control.
Admin users can edit the configuration, modify the Access Control List (ACL) and delete the plugin, regardless of the ACL chosen.
Plugin access levels
Access Level:
Link to workspace
- User can link the plugin to any workspace they have at least Editor permissions for.
- Data from the plugin can then be viewed by anyone with any access to the workspace.
User can share the plugin data with anyone they want.
User cannot configure the plugin in any way, or delete it.
Full Control - User can change the plugin configuration, ACL, and delete the plugin.
See Access control for more information.
Click Save.
If you defined an import script, it will run shortly and the objects will subsequently appear in the dashboard in the new workspace.
4. Add one or more custom Data Streams in SquaredUp.
To be able to use the return data from your PowerShell Data Stream scripts in tiles on dashboards, you need to create custom Data Streams.

A data stream brings you data to answer a specific question like "What's the health state of the objects?", "What kind of alerts are coming from this plugin for my servers?", "What's the average memory usage of this app?"
The magic of data streams is that they standardize data from all the different shapes and formats your tools use into a straightforward tabular format. While creating a tile you can tweak data streams by grouping or aggregating specific columns. Depending on the kind of data, SquaredUp will automatically suggest how to visualize the result, for example as a table or line graph.
Go to Settings > Data Streams.
Add a new Data Stream with the following settings:
Display Name This name will be displayed when you are creating tiles on a dashboard and can pick Data Streams. Plugin Choose the Custom PowerShell plugin. Data Source You can either use a scope of objects (list scope) or not limit the scope to specific objects (no scope).
If you use the list scope, the Data Stream will only be visible when creating a tile that has those objects in its scope. Which objects are included is defined by the
matches
parameter in the Data Stream JSON.You can use all parameters you used for defining vertices in the import script as criteria for which objects to include (e.g. a specific type of object).
Enter the JSON for the Data Stream in the code box.
Format of the JSON for the Data Stream
Information about parameters in the script:
dataSourceConfig.scriptPath
Defines which script is run by this Data Stream matches
If you selected the data source "list scope", here you define for which objects the Data Stream will be visible when creating a tile.
You can use all parameters you used for defining vertices in the import script as criteria for which objects to include (e.g. a specific type of object).
metadata
Allows you to customize how the results are displayed in SquaredUp. You can modify which columns are shown as well as their format, for example currencies, dates, and storage units. You can also specify which columns are the label and which are the value for the visualization.
Copy{
"name": "diskSpace",
"dataSourceConfig": {
"scriptPath": "get-diskFreeSpace.ps1"
},
"matches": {
"sourceType.0": {
"type": "equals",
"value": "volume"
}
},
"rowPath": [
"results"
],
"metadata": [
{
"name": "results.name",
"displayName": "Name",
"shape": "string"
},
{
"name": "results.size",
"displayName": "Disk Size",
"shape": "bytes"
},
{
"name": "results.freeSpace",
"displayName": "Free Space",
"shape": "bytes"
}
]
}
Comments
0 comments
Please sign in to leave a comment.