Hello,
We need to delete particular values appearing at 00:00:01 every day for a tag. Rest of the values must remain. We created attached PowerShell script to achieve the same, but getting a prompt for 'Connection:' while executing.
cmdlet Get-PIPoint at command pipeline position 1 Supply values for the following parameters: (Type !? for Help.) Connection:
Could you please suggest what do we need to enter against this prompt? Or could there be some other issue?
Thanks,
Sujoy Halder
PowerShell code:
# Load the OSIsoft PowerShell Extensions Import-Module OSIsoft.PowerShell # Connect to the PI Data Archive by specifying its name $piDataArchiveName = "PI-Global" Connect-PIDataArchive -PIDataArchiveMachineName $piDataArchiveName # Define the start and end dates $startDate = Get-Date "10 June 2024 00:00:01" $endDate = Get-Date "11 June 2024 00:00:01" # Define the tag name $tagName = 'ESUM_NV_all_Vorhersage_1D' # Retrieve the PIPoint object for the tag name $piPoint = Get-PIPoint -Name $tagName # Loop through each day in the range and remove the value at 00:00:01 while ($startDate -le $endDate) { # Define the specific time for the value to be deleted $specificTime = $startDate.Date.AddSeconds(1) # This ensures the time is 00:00:01 # Get the PI value for the tag at the specified timestamp using the PIPoint object $piValue = Get-PIValue -PIPoint $piPoint -Time $specificTime # Check if the value exists before attempting to remove it if ($piValue -ne $null) { # Remove the PI value Remove-PIValue -PIValue $piValue Write-Host "Deleted value for $tagName on $($specificTime)" } else { Write-Host "No value found for $tagName on $($specificTime)" } # Move to the next day $startDate = $startDate.AddDays(1) } Write-Host "Completed deletion of values for the specified date range."