param( [string]$HostName = "localhost", [int]$Port = 32568 ) $ErrorActionPreference = "Stop" $repoRoot = Split-Path -Parent $PSScriptRoot function Convert-SecureStringToPlainText { param([Parameter(Mandatory = $true)][securestring]$SecureString) $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString) try { [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) } finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) } } Push-Location $repoRoot try { $suggestedUserName = "$env:COMPUTERNAME\$env:USERNAME" $userName = Read-Host "Historian user [$suggestedUserName]" if ([string]::IsNullOrWhiteSpace($userName)) { $userName = $suggestedUserName } $securePassword = Read-Host "Historian password" -AsSecureString $plainPassword = Convert-SecureStringToPlainText $securePassword $env:HISTORIAN_USER = $userName $env:HISTORIAN_PASSWORD = $plainPassword Write-Host "" Write-Host "Building latest harness..." dotnet build .\Histsdk.slnx Write-Host "" Write-Host "Running managed Open2 probe against $HostName`:$Port..." dotnet run --no-build --project tools\AVEVA.Historian.ReverseEngineering -- wcf-open2 $HostName $Port } finally { Remove-Item Env:HISTORIAN_USER -ErrorAction SilentlyContinue Remove-Item Env:HISTORIAN_PASSWORD -ErrorAction SilentlyContinue if (Get-Variable -Name plainPassword -Scope Local -ErrorAction SilentlyContinue) { $plainPassword = $null } Pop-Location }