Creating an Asset with PowerShell
You can build an asset and its properties entirely from PowerShell using the Assets module (IcoAssetCatalogPowershell). This is useful when you are setting up a new piece of equipment as part of a repeatable routine rather than clicking through the configuration in Workbench. This topic walks you through creating an asset and giving it the properties that a discrete manufacturing line typically needs; it is one example illustrating the broader create-and-verify pattern that works the same way for every provider's entities.
The example builds a generic stamping-press station with a machine-state property, a part-counter property, and a writable speed setpoint. The names and data sources are illustrative—substitute the asset name, properties, and real point references that match your own project.
Before you begin, confirm that you are connected to the correct server and that you understand the entity and key model the commands use.
To create an asset and its properties:
-
Confirm which server the commands will configure:
Get-WbHostThe result is the host whose configuration your commands will change. It is
localhostunless you have retargeted it. -
Create the asset, capturing the returned entity in a variable so you can reuse it:
$press = New-AcEquipment -Name 'StampingPress01' -DisplayName 'Stamping Press 01' -Description 'Line A stamping press' -Enabled $true<ul><li>
-Name—Unique entity name used to reference the asset in other commands.</li><li>-DisplayName—The label shown to operators in displays.</li><li>-Enabled—Set to$trueto make the asset active.</li></ul>To place the asset beneath an existing parent such as a production line, add
-ParentName 'Line A'. Omitting-ParentNamecreates the asset at the root of the asset tree. -
Add a property that reflects the machine's running state, pointing it at a real-time data source:
New-AcEquipmentProperty -Name 'MachineState' -ParentName 'StampingPress01' -Description 'Current run state' -RealtimePointType 'Point' -RealtimePointName 'svrsim:ramp int slow 0 5'-
-ParentName—the asset the property belongs to, identified here by name. -
-RealtimePointName—the data source the property reads from. The example uses a point from the built-in GENESIS Simulator (svrsim); substitute the real device or OPC point for your equipment. -
-RealtimePointType—set toPointso the property treats the data source as a real-time point.
-
-
Add a part-counter property the same way, pointing at the counter point for the press:
New-AcEquipmentProperty -Name 'PartCount' -ParentName 'StampingPress01' -Description 'Parts produced this shift' -RealtimePointType 'Point' -RealtimePointName 'svrsim:ramp int slow 0 1000' -
Add a setpoint property so operators can command the press speed, pointing it at a writable data source:
New-AcEquipmentProperty -Name 'SpeedSetpoint' -ParentName 'StampingPress01' -Description 'Target strokes per minute' -RealtimePointType 'Point' -RealtimePointName 'svrsim:register double' -RangeMinimum '0' -RangeMaximum '120'-
-RangeMinimum/-RangeMaximum—the valid range for the value.
-
-
Verify that the asset was created with the expected properties:
Get-AcEquipment 'StampingPress01' | Select-Object Name, DisplayName, Enabled Get-AcEquipmentPropertiesByParent (Get-AcEquipment 'StampingPress01').Key | Select-Object Name, Description, RealtimePointNameYou should see the asset and its three properties listed. The new asset is now part of the configuration and is picked up by the running system as described in How Configuration Changes Synchronize.
To create many similar assets, wrap the commands above in a loop. The following creates ten numbered presses: