使用 PS 从 CRM Dynamics365 提取数据

发布于 2025-01-09 08:12:35 字数 736 浏览 4 评论 0原文

我做了一些研究,但很难找到有关该主题的任何明确答案。所以我来这里是为了看看是否有人有使用 PowerShell 从 CRM 中获取数据的经验。我对 Shell 半熟练,所以我可以理解大多数事情。话虽如此,请不要认为我来这里只是为了接受填鸭式的教育,我需要的是朝着正确的方向推动。

我知道有一些模块可以使这成为可能(可能?),以及 XRM 工具包之类的东西,但很难找到坚如磐石的答案。

我需要做的是提取“联系人”、“地址”等内容的列表,基本上只是系统中存储的人员的帐户详细信息。这听起来超级简单,做这个是AD,AAD,交换很容易完成......但这个CRM Dynamics正在逃避我。

考虑这样开始:

Import-Module Microsoft.Xrm.Data.Powershell
$conn = Get-CrmConnection -InteractiveMode
$result = Get-CrmRecordsByFetch @"

然后可能使用 Fetch 查询吗? 总结如下:

$result.CrmRecords | Select -Property lastname, firstname, AccountID, Address | Export-Csv -
Encoding UTF8 -Path C:\export.csv -Delimiter ";"

不幸的是,当涉及到 CRM cmdlet 和命令时,我的知识就到此为止了。

任何帮助将不胜感激。

I've done a bit of research but am having trouble finding any definitive answer on the topic. So I'm here to see if anyone has any experience with getting data out of CRM using PowerShell. I am semi-proficient with Shell so I can make sense of most things. With that said, please don't think I'm here just to be spoon-fed, a nudge in the right direction is what I need.

I am aware there is modules that make this possible (possibly?), and things like XRM toolkit, but a rock-solid answer has been extremely difficult to find.

What I need to do is pull a list of things like "contacts" , "addresses" etc, basically just account details for people stored in the system. It sounds super simple, and doing this is AD, AAD, Exchange is easily done.... but this CRM Dynamics is escaping me.

Thinking of starting off like this:

Import-Module Microsoft.Xrm.Data.Powershell
$conn = Get-CrmConnection -InteractiveMode
$result = Get-CrmRecordsByFetch @"

Then possibly use a Fetch Query?
And wrap it up like this:

$result.CrmRecords | Select -Property lastname, firstname, AccountID, Address | Export-Csv -
Encoding UTF8 -Path C:\export.csv -Delimiter ";"

Unfortunately, when it comes to the CRM cmdlets and commands, that's where my knowledge stops.

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云淡月浅 2025-01-16 08:12:35

我对 PowerShell 不太熟悉,但通常你有两个选择:

如果您需要使用 Microsoft.Xrm.Data.PowerShell 检索记录,您可以使用 Get-CrmRecords 或 Get-CrmRecordsByFetch,对于第二个,您可以指定 FetchXML 查询,您可以使用 FetchXML Builder 来帮助您创建此类查询,但我不使用这个

库Invoke-RestMethod 更标准,一旦您有了 OData 查询,您就可以执行它,但您需要首先提供一个 Bearer Token,为了生成它,您通常需要一个 clientid 和来自天蓝色应用程序注册的 clientsecret。

我创建了一个名为 Dataverse REST Builder 的工具,可以帮助您创建 OData 请求,但它不提供您可以使用 PowerShell 语法,但您可以将集合导出到 Thunder Client 集合。将其导入 Thunder 客户端后,您可以生成 PowerShell 的代码。

I am not too much familiar with PowerShell but usually you have two options:

If you need to retrieve records using the Microsoft.Xrm.Data.PowerShell you can use Get-CrmRecords or Get-CrmRecordsByFetch, with the second one you can specify a FetchXML query, you can use FetchXML Builder to assist you on creating such query, but I don't use this library

The Invoke-RestMethod is more standard, once you have your OData Query you can execute it but you need to provide a Bearer Token first, in order to generate it you usually need a clientid & clientsecret from an azure app registration.

I have created a tool called Dataverse REST Builder that can assist you creating OData requests, it doesn't provide you with a PowerShell syntax, but you can export your collection to a Thunder Client collection. Once you import it inside Thunder Client you can generate the code for PowerShell.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文