Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise Design Integration Forum Testing a ProjectWise connection with PowerShell
    • Sign In

    • State Not Answered
    • Replies 2 replies
    • Subscribers 61 subscribers
    • Views 2286 views
    • Users 0 members are here

    Testing a ProjectWise connection with PowerShell

    Kevin van Haaren
    Offline Kevin van Haaren over 7 years ago

    I thought some might find this useful. It's a PowerShell function to quickly test if the ProjectWise port on a server is responding. Note that it is not as comprehensive as pwping, but it can be useful for testing an endpoint quickly. The test is effectively the same as doing:
    telnet server 5800

    So why not use pwping?
    * The function returns true/false and lends it self to testing lots of server in a batch.
    * Depending on your configuration it may load significantly faster than pwping (pwping processes everything in your PW Network Control panel, if you have connections in there to slow responding servers ProjectWise will take longer to load.)
    * This function does NOT require ProjectWise be installed on the local computer. It does NOT use the ProjectWise PowerShell add-on, it's written in pure PowerShell (and .NET)

    If you want some more PowerShell tips come to the Mid-America CADD Community conference in Kansas City on August 2nd and 3rd. I'm teaching a session on Why you should be using PowerShell.
    More details at http://midamericacadd.org

    # Test-PWPort based on TestPort function from www.travisgan.com/.../use-powershell-to-test-port.html
    # Place function in your profile.ps1 file to have available at all times.
    # ProjectWise default port of 5800 is hardcoded.
    # Usage:
    # Test-PWPort <servername>
    # Test-PWPort <ip_address>
    # Returns:
    # True if port is listening
    # False if can not connect to port

    function Test-PWPort {
    Param(
    [parameter(ParameterSetName='ComputerName', Position=0)]
    [string]
    $ComputerName,
    [parameter(ParameterSetName='IP', Position=0)]
    [System.Net.IPAddress]
    $IPAddress
    )
    $Port = 5800
    $RemoteServer = If ([string]::IsNullOrEmpty($ComputerName)) {$IPAddress} Else {$ComputerName};
    $test = New-Object System.Net.Sockets.TcpClient;
    $result = $false
    Try
    {
    $test.Connect($RemoteServer, $Port);
    $result = $true
    }
    Catch
    {
    $result = $false
    }
    Finally
    {
    $test.Dispose();
    }
    return $result
    }

    • Sign in to reply
    • Cancel
    Parents
    • Kevin van Haaren
      0 Offline Kevin van Haaren Mon, Jun 13 2016 12:12 PM
      well that's horrible to read so I setup my first github repository to hold my public ProjectWise stuff. You can see/download this from:
      github.com/.../Test-PWPort.ps1

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Reply
    • Kevin van Haaren
      0 Offline Kevin van Haaren Mon, Jun 13 2016 12:12 PM
      well that's horrible to read so I setup my first github repository to hold my public ProjectWise stuff. You can see/download this from:
      github.com/.../Test-PWPort.ps1

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Children
    • Stephen Herrick
      0 Offline Stephen Herrick Tue, Jun 14 2016 10:26 AM in reply to Kevin van Haaren
      Thanks for the Share,,,,
      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies