PowerShell script for reading and writing tags
Triggered by the ScriptExecute command, PowerShell scripts can read tags' values and write values to tags.
TIP:
Tag reading and writing speed may decrease when accessing a large number of tags.
To access tags, some essential variables must be defined in PowerShell scripts, and they must follow specific formats. For the entire sample script for reading and writing tags, see Example: PowerShell script for reading tags and Example: PowerShell script for writing tags.
If you use the reserved parameters to specify the directory type, application name, and area name, executing the ScriptExecute command will automatically parse them. The parameters must be in the following format:
param( [int]$Directory = $(throw "Parameter missing: -Directory Directory"), [string]$SEAppName = $(throw "Parameter missing: -SEAppName ApplicationName"), [string]$AreaName = $(throw "Parameter missing: -AreaName AreaName") )
$Directory
, $SEAppName
, and $AreaName
are reserved parameters for directory type, application name, and area name.If you do not use the reserved parameters, define the GetScriptExecutor variable in the following format:
$scriptexecutor = $scriptmanager.GetScriptExecutor(1, "Station", "Area");
1
means network directory type (that is, network distributed or network station application) while 2
means local directory type (that is, local station application). Station
is the application name. Area
is the area name. The area name can be empty, for example, (1, "AppName", "")
or (1, "AppName")
, which means it's the root area or the application is a local station.Provide Feedback