web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Check if Project exists from PowerShell

(0) ShareShare
ReportReport
Posted on by 4,073

As a part of my deployment Power-Shell script, I need to check if an Development Project exists in AX.

Does anyone know how to do that?

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    48,938 User Group Leader on at
    RE: Check if Project exists from PowerShell

    A way i can imagine is to call .net code from PowerShell and .Net code should be responsible to read AX using AIF web services.

  • Suggested answer
    Martin Dráb Profile Picture
    236,519 Most Valuable Professional on at
    RE: Check if Project exists from PowerShell

    You can also use Business Connector from Powershell. This is a solution if you can't make custom web services.

    Of course, Business Connector doesn't exist in newer versions of AX, but no solution will be upgradable and therefore it doesn't matter.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Check if Project exists from PowerShell

    If you have database access to the model database you could also use an SQL script such as:

    SELECT ISNULL((select top 1 1  

     FROM [YOUR_MODEL_DATABASE].[dbo].[ModelElement]

     where ElementType = 37 AND Name = 'YOUR_PROJECT_NAME'),0)

    To use this from powershell you can use the Invoke-SqlCmd scriptlet

  • Suggested answer
    Daniel Weichsel Profile Picture
    on at
    RE: Check if Project exists from PowerShell

    Assuming you have the AX2012 model management cmdlets at your disposal:

    @('USR Model', 'VAR Model') | % { Get-AxModel -Model $_ -Details | Select -ExpandProperty Elements } | ? { $_.ElementType -eq 'SharedProject' -and $_.Name -eq 'MyProjectName' }

    This starts with a list of models you want to search within, gets the model content for each, then filters that down to only shared projects with a matching name.  Adjust as needed.

  • Sohaib Cheema Profile Picture
    48,938 User Group Leader on at
    RE: Check if Project exists from PowerShell

    @Daniel Weichsel,

    This is great command. I wonder how this will behave with search of private project. I assume we need to pass Creator_PrivateProjectName instead of just PrivateProjectName, whereas for SharedProjects this works great.

    We cannot trust Like operator in that case for powershell by saying

    -and $._Name -Like '*NameOfMyPrivateProject'

  • Daniel Weichsel Profile Picture
    on at
    RE: Check if Project exists from PowerShell

    @Sohaib Cheema, you've got it.  AxUserId_PrivateProjectName.  If you need to avoid wildcards, you'll have to know the AX user ID ahead of time, or you might use the Get-AxUser cmdlet to help get the AX user ID matching a Windows identity.  Get-AxUser does establish a Business Connector session behind the scenes though, so the target environment would have to be running.

  • Rudi Hansen Profile Picture
    4,073 on at
    RE: Check if Project exists from PowerShell

    [quote user="Daniel Weichsel"]

    @('USR Model', 'VAR Model') | % { Get-AxModel -Model $_ -Details | Select -ExpandProperty Elements } | ? { $_.ElementType -eq 'SharedProject' -and $_.Name -eq 'MyProjectName' }

    [/quote]

    This looks like it does what i need thanks for the tip.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans