Once I get an AF Element assigned to a PowerShell variable how do I assign an AF Element Template to it?
Once I get an AF Element assigned to a PowerShell variable how do I assign an AF Element Template to it?
I continued my research and was able to find a solution to my question. I am adding it here in case someone else hits this roadblock:
# LOAD AFSDK ASSEMBLY: $AFSDKAssembly = [Reflection.Assembly]::LoadWithPartialName("OSIsoft.AFSDK") # CONNECT TO THE AF SERVER: $afServers = New-Object OSIsoft.AF.PISystems $afServer = $afServers["PIAF-QA"] $afConn = Connect-AFServer -AFServer $afServer # CONNECT TO TARGET AF DATABASE: $afDB = $afServer.Databases["TNA_State_Estimator"] $afTemplates = $afDB.ElementTemplates $template = $afTemplates["Feeder_Element"] Write-Host $template $Element = $afDB.Elements["00KV_Testing"].Elements["Element01"].Elements["ChildElement01"] Add-AFElement -AFElementTemplate $template -Name "ChildElement02" -AFElement $Element # CHECK-IN CHANGES: $afDB.CheckIn()
I continued my research and was able to find a solution to my question. I am adding it here in case someone else hits this roadblock:
# LOAD AFSDK ASSEMBLY: $AFSDKAssembly = [Reflection.Assembly]::LoadWithPartialName("OSIsoft.AFSDK") # CONNECT TO THE AF SERVER: $afServers = New-Object OSIsoft.AF.PISystems $afServer = $afServers["PIAF-QA"] $afConn = Connect-AFServer -AFServer $afServer # CONNECT TO TARGET AF DATABASE: $afDB = $afServer.Databases["TNA_State_Estimator"] $afTemplates = $afDB.ElementTemplates $template = $afTemplates["Feeder_Element"] Write-Host $template $Element = $afDB.Elements["00KV_Testing"].Elements["Element01"].Elements["ChildElement01"] Add-AFElement -AFElementTemplate $template -Name "ChildElement02" -AFElement $Element # CHECK-IN CHANGES: $afDB.CheckIn()