Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum PWPS_DAB Version Check
    • Sign In

    • State Verified Answer
    • Replies 6 replies
    • Subscribers 66 subscribers
    • Views 1632 views
    • Users 0 members are here

    PWPS_DAB Version Check

    Dave Cole
    Offline Dave Cole over 3 years ago

    I am using this to check the version of PWPS_DAB before running a script.  Is there a better way to do this?

    $LocalDabModuleVersion = Get-Module -Name PWPS_DAB -ListAvailable
    $LocalVersionString = $LocalDabModuleVersion.Version.ToString().Replace(".","")
    
    If($LocalVersionString -lt "12110")
    {
        Write-Host "PWPS_DAB 1.21.1.0 or newer required to run this script." -ForegroundColor Cyan
        Write-Host
    }else{
        
        Write-Host "PWPS_DAB" $LocalDabModuleVersion.Version "found. Script will run." -ForegroundColor Cyan
        Write-Host
    }

    I can see potential issues with this method.  For example, when PWPS_DAB 2.0.0.0 is released.

    Thanks.

    • Sign in to reply
    • Cancel

    Top Replies

    • Dan Williams
      Offline Dan Williams Wed, Apr 22 2020 3:08 PM +1 verified
      You might want to check out the #Requires statement documented here: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires?view=powershell-5.1 I tried it with…
    • Dave Cole
      Offline Dave Cole Wed, Apr 22 2020 3:47 PM in reply to Dan Williams +1
      Thanks! Tweaking it a bit, this will work in ISE #Requires -Modules PWPS_DAB, @{ModuleName="PWPS_DAB";ModuleVersion="1.21.1.0"} Adding ModuleVersion specifies the minimum version needed to run.

    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