how can i ADD a new pi-identity to example pimapping database existing databasesecurity with powershell
this is what i cooked up its a simple script to fix database security where i can ADD a new identity to the existing security string on a Database
# Here goes DB name and PIServer name
$DB = 'PIMapping'
$PIsrv = 'pisrvname'
$con = Connect-PIDataArchive -PIDataArchiveMachineName $PIsrv
$SecurityString = get-PIDatabaseSecurity -Name $DB1 -Connection $con
$sec = $SecurityString.Security.ToString()
$sec1 = "$sec | PI-Interfaces: A(r,w)"
$sec2 = [String]$sec1
#Here is a check of the datatype
#Write-Output = $Sec2
#Here is the new Security string to chosen DB set
Set-PIDatabaseSecurity -Name $DB -Security $Sec2 -Connection $con
Request you to check below url for additional information.
Add-PIMapping -Name "Domain Users Mapping" -Identity "DomainUsersReadOnly" -PrincipalName "exampledomain\domainusers" -Description "Mapping for all domain users" -Disabled -Connection $con
sorry for the confusion
pimapping = pi database
I believe what you are looking for is Set-PIDatabaseSecurity. I suggest you to do look at the return from Get-PIDatabaseSecurity first. This gives you a better understanding of the expected parameters.
i did that it returns the whole security string
with comma seperator and the string you have to send is seperated by |
it seems it wont work with putting it in a $SecString
it worked when you insert the correct security string in $SecString
Glad you figured it out!
Did you create a script? If so, how about obfuscating or generalizing the information specific to your PI System and sharing the script?
Thanks a lot for sharing!
Let me chose this as the [Correct Answer] after applying some syntax highlighting.
If you are adding a PI Mapping to a built in PI Identity, then you can use Add-PIMapping directly.
If you would like to add a PI Mapping to a custom PI Identity, then you will need to use Add-PIIdentity first before using Add-PIMapping.
Why don't you try C# with PI AF SDK to manupulate the PI Mapping?. If you are not familiar with C# programming, it will take some time for you to get started, but then you will be able to manipulate PI objects better than never!!
This is not exposed in the AFSDK
Retrieving data ...