2 of 2 people found this helpful
You will need to compile the script into an executable using PS2EXE. You can then name your executable as whatever you want.
That is certainly one way of doing it.
I was however looking into something that would not require compilation - just some scripts I would run and edit on a daily basis.I though that there might be an AFSDK function that would camouflage the SDK connection name but I guess that is inherited from the executable that runs the script - Powershell.exe in this case.
1 of 1 people found this helpful
I find the answer provided by Eugene Lee helpful but my impression is that this is not what you've been asking for. I however must admit that I am uncertain what exactly you are asking for.
In case you like to know how you would connect to a PI Data Archive host specified by name using OSIsoft.Powershell, please see the snippet below.
$PIServerHost = "<YourPIDataArchiveHostName>" $piConnection = Connect-PIDataArchive -PIDataArchiveMachineName $PIServerHost -AuthenticationMethod Windows $piConnection
Are you possibly intending to use one of OSIsoft's Developer Technologies like AF SDK or PI API instead?
If this is the case, we will be able to support you with some snippet on how to use AF SDK within PowerShell but we do not support programming against PI API because it's deprecated technology.
Your impression was right - I thought we could have some function in AFSDK that could specify the connection name (for both SDK and API) when connecting to PI.
I suppose the SDK connection initiated to PI inherits the executable name (Powershell.exe in my case) so I would have to compile the script as Eugene suggested.
Is there no way of emulating an API connection behavior from AFSDK ? (I am already using PI AFSDK inside Powershell).
My use case: We have some interfaces that connect to remote systems we cannot control nor access (other that the interface restricted access).
In one particular case we have a PItoPI interface that pushes some data to remote PIServer and we have lost the list of the tags the interface is loading.
It was impossible to get a list of all host tags from the logs of the PItoPI (with debug max) because PItoPI truncates the longer tag names before printing them out. And even if I got a destination tag list, there is no way to get the mapping to the source tag. I do not want to go the extra hustle to try narrowing down which pointIDs the specific PItoE connection is reading from our PI Server.
Since the PItoPI connection is allowed to read its host tags, if I could just run a Powershell script to connect to the remote PI exactly as the PItoPI API connection, I could query the list of tags and check their mappings.
Hope this sheds some light into my question.
So in other words you are trying to spoof the API application name (PItoE) to gain access to an existing trust . The application name of SDK applications cannot be set manually by the user, it is always inherited from the executable name. For that matter, it probably won't work out anyway if you use the PS2EXE method, since your application name will end in '.exe', whereas the trust for PItoPI will be for 'PItoE'. You could theoretically write an API application and do this, but spoofing the name to gain access to a trust seems kind of dubious; could you just ask the admins for the remote server for the point list again? Or an alternative authentication method for your script?
On a side note, the PowerShell tools which target the PI Data Archive are actually MDA based (tools which target the PI AF server are AFSDK based).
That was my initial intent, to "trick" the PI trust into granting the PItoPI rights to my Powershell script. I see your point as allowing this could be considered a security hole.
I suppose my only option here is to compile the script into some custom exe name. I won't go into developing an API application for this - seems too much effort for something that is already deprecated
Thank you all for your answers