seanmcne / Microsoft.Xrm.Data.PowerShell

This module uses the CRM connection from Microsoft.Xrm.Tooling.CrmConnector.Powershell and provides common functions to create, delete, query, and update data as well as functions for common tasks such as publishing, and manipulating System & CRM User Settings, etc. The module should function for both Dynamics CRM Online and On-Premise environment.
201 stars 64 forks source link

Check status of Async Import #501

Closed andrescolodrero closed 2 years ago

andrescolodrero commented 2 years ago

in a D365 cloud instance i do an import if solution:

Import-CrmSolutionAsync and i get and AsyncJobId.

is there a way to query the status of the import job? For on-prem import solution, i was using Get-CrmOperationStatus.

I have been trying with https://docs.microsoft.com/en-us/powershell/module/microsoft.powerapps.administration.powershell/get-adminpowerappoperationstatus?view=pa-ps-latest

But i cant find how to query an asyncjob (and if this is possible)

seanmcne commented 2 years ago

You can have the cmdlet/function poll for a max # of seconds and it will check the status. If you just want the async ID and do the polling yourself at some other interval you can reference this: https://github.com/seanmcne/Microsoft.Xrm.Data.PowerShell/blob/14fdaa768e44de034edc91249bcd8b49be71397f/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1#L2023 through line 2062. This block of code will query for the async job status, check the status, and return it while waiting until it's completed or failed.

If you just want this to work without coding for something - make sure you set the -BlockUntilImportComplete - this will run the command and make it poll for the job status until it's done or until -MaxWaitTimeInSeconds has elapsed.