Automating PI Tag Synchronization Across Multiple PI Historians with PowerShell
Synchronize and manage PI tag definitions across multiple PI Data Archives using PowerShell and the PowerShell Tools for the PI System. Learn how to automate differential queries and replicate tag configuration changes from production to development effortlessly.
Roshan Soni
Automating PI Tag Synchronization Across Multiple PI Historians Using PowerShell
Maintaining consistent PI tags across multiple PI Data Archives—especially development, test, and production environments—can be a daunting task. While PI to PI interfaces ensure replicated data flows, keeping tag definitions synchronized (i.e., PI Point creation, deletion, or updates) often requires additional attention. Traditionally, solutions like piconfig batch files handle bulk export/import, but with the advent of OSIsoft's PowerShell Tools for the PI System, streamlined and more flexible scripting solutions are within reach.
Why Automate PI Tag Synchronization?
As PI deployments grow in complexity, maintaining alignment between development and production environments is vital for accurate testing, validation, and minimizing configuration drift. Manually updating tags is error-prone and time-consuming. By leveraging PowerShell scripting, you can:
- Automate comparison and synchronization between source (production) and target (dev/test) PI servers
- Eliminate manual intervention and reduce outages due to missing or misconfigured tags
- Enable repeatable, scheduled, and scalable updates
Prerequisites
- PowerShell Tools for the PI System Version 2 (included with PI System Management Tools 2015 (3.5.1.7+) or later). Download from the OSIsoft Tech Support site.
- Sufficient privileges to connect and write to both source and destination PI Data Archives.
- PowerShell 5.1 or above recommended.
Basic Workflow
- Connect to both PI Data Archives
- Export PI Point lists and attributes
- Compare the sets (differential query) using
Compare-Object - Import/create/update PI Points as required on the target Data Archive
Sample PowerShell Script
Below is a simplified script that demonstrates the workflow for synchronizing tag (PI Point) definitions between production and development PI servers:
# Set up connections to both PI Data Archives
$prodServer = "yourProdPIServer"
$devServer = "yourDevPIServer"
# Requires PI PowerShell module
$prodConnection = Connect-PIDataArchive -PIDataArchiveMachineName $prodServer
$devConnection = Connect-PIDataArchive -PIDataArchiveMachineName $devServer
# Get all tags from both servers (use wildcards or filtering as needed)
$prodPoints = Get-PIPoint -Name '*' -Connection $prodConnection
$devPoints = Get-PIPoint -Name '*' -Connection $devConnection
# Compare tag names between servers
$comparisons = Compare-Object -ReferenceObject ($prodPoints.Point.Name) -DifferenceObject ($devPoints.Point.Name)
# Tags present in prod but not in dev (=> candidates to add)
$tagsToAdd = $comparisons | Where-Object {$_.SideIndicator -eq "<="} | Select-Object -ExpandProperty InputObject
foreach ($tag in $tagsToAdd) {
$pointConfig = $prodPoints | Where-Object { $_.Point.Name -eq $tag }
# Create tag in dev, duplicate attributes as needed
Add-PIPoint -Name $tag -PointType $pointConfig.PointType -Connection $devConnection
# Further properties can be set here (descriptor, engineering units, etc.)
}
# You might also compare and update attributes, or handle tag deletions in dev if required.
Going Beyond Tag Names
The PowerShell Tools not only allow you to compare just tag names but also compare and synchronize PI Point attributes (such as pointtype, descriptor, engineering units, etc.). You can retrieve and clone all relevant metadata using PowerShell objects and ensure your environment is an accurate mirror.
Useful Resources
- PowerShell Tools for the PI System
- Getting Started with the PowerShell Tools for the PI System – Daphne Ng
Final Thoughts
PowerShell scripting supercharges your ability to automate PI system management tasks—including synchronizing tag definitions across environments. With a little setup, you can save hours of repetitive work and ensure your development landscape evolves in step with production.
Have you automated your PI tag management processes? Share your experiences or questions below!
Tags
About Roshan Soni
Expert in PI System implementation, industrial automation, and data management. Passionate about helping organizations maximize the value of their process data through innovative solutions and best practices.
No comments yet
Be the first to share your thoughts on this article.
Related Articles
Enhancing PI ProcessBook Trends with Banding and Zones: User Needs, Workarounds, and the Road Ahead
A look at the user demand for trend banding/zoning in OSIsoft PI ProcessBook, current VBA workarounds, UI challenges, and how future PI Vision releases aim to address these visualization needs.
Roshan Soni
Migrating PIAdvCalcFilVal Uptime Calculations from PI DataLink to PI OLEDB
Learn how to translate PI DataLink's PIAdvCalcFilVal advanced calculations—like counting uptime based on conditions—into efficient PI OLEDB SQL queries. Explore three practical approaches using PIAVG, PIINTERP, and PICOunt tables, and get tips for validation and accuracy.
Roshan Soni
Understanding PI Web API WebID Encoding: Can You Generate WebIDs Client-Side?
Curious about how PI Web API generates WebIDs and whether you can encode them client-side using GUIDs or paths? This article explores the encoding mechanisms, current documentation, and best practices for handling WebIDs in your applications.
Roshan Soni