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
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.
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.
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
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.
@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'
@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.
[quote user="Daniel Weichsel"]
[/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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Tocauer 4
Community Member 2
Nayyar Siddiqi 2