How to get information about PI SDK

Discussion created by Gregor on Jul 8, 2014

Dear PowerShell & PI Geeks,


Here's an example showing how to check if PI SDK is installed on the local box and in case it is installed, retrieving some additional information.  

$GetPISDKInfo = 
        $sdkType = [System.Type]::GetTypeFromProgID("PISDK.PISDK")
        $mySDK = [System.Activator]::CreateInstance($sdkType)
        Write-Host "PI SDK Version:      " $mySDK.PISDKVersion.Version -Foregroundcolor Green
        Write-Host "Build Number:        " $mySDK.PISDKVersion.BuildID -Foregroundcolor Green
        Write-Host "Build Date:          " $mySDK.PISDKVersion.BuildDate -ForegroundColor Green
        Write-Host "Installation path:   " $mySDK.PISDKVersion.Path -Foregroundcolor Green
        Write-Host "Default Server:      " $mySDK.Servers.DefaultServer.Name -Foregroundcolor Green
        Write-Host "Connect Timeout:     " $mySDK.ConnectTimeout "s" -Foregroundcolor Green
        Write-Host "Data Access Timeout: " $mySDK.Timeout.ToString() "s" -Foregroundcolor Green
    Catch [System.Management.Automation.MethodException]
        Write-Host "PI SDK is not installed" -ForegroundColor Yellow
        Write-Host "Unexpected exception of type" $_.Exception.GetType().FullName "occured:" -foreground Red
        Write-Host $_.Exception.Message -foreground Red
Invoke-Command $GetPISDKInfo 

 The cool thing with this solution is that you can also check remote nodes. 

Invoke-Command -ComputerName MyOtherPIClient $GetPISDKInfo 

 Have fun!