在 PowerShell 中连接到 CRM 2016 IFD
Connecting to CRM 2016 IFD in PowerShell
我想使用 SDK 中包含的 PowerShell cmdlet Get-CrmConnection
连接到 CRM 2016 服务器。
我找不到正确的连接字符串。
连接到本地网络中的服务器正常:
Get-CrmConnection -ConnectionString "Url=http://<server>/OrganizationName;"
但是连接到为 IFD 配置的服务器失败:
Get-CrmConnection -ConnectionString "Url=https://crm.ourdomain.com/"
Get-CrmConnection : Organization cannot be null or empty.
Parameter name: Organization Name
At line:1 char:1
+ Get-CrmConnection -ConnectionString "Url=https://crm.ourdomain.com/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SyntaxError: (:) [Get-CrmConnection], ArgumentNullException
+ FullyQualifiedErrorId : -9,Microsoft.Xrm.Tooling.CrmConnector.Powershell.Commands.GetCrmConnectionCommand
我尝试在连接字符串中添加 AuthType 参数,提供组织名称,但没有成功。重要的是我可以使用交互模式连接:
Get-CrmConnection -InteractiveMode
此returns以下连接:
IsReady : True
IsBatchOperationsAvailable : True
Authority :
OAuthUserId :
ActiveAuthenticationType : AD
OrganizationServiceProxy : Microsoft.Xrm.Tooling.Connector.CrmWebSvc+ManagedTokenOrganizationServiceProxy
OrganizationWebProxyClient :
LastCrmError : OrganizationWebProxyClient is null
LastCrmException :
CrmConnectOrgUriActual : https://crm.ourdomain.com/XRMServices/2011/Organization.svc
ConnectedOrgFriendlyName : OrganizationName
ConnectedOrgUniqueName : OrganizationName
ConnectedOrgPublishedEndpoints : {[WebApplication, https://crm.ourdomain.com/], [OrganizationService,
https://crm.ourdomain.com/XRMServices/2011/Organization.svc],
[OrganizationDataService,
https://crm.ourdomain.com/XRMServices/2011/OrganizationData.svc]}
ConnectionLockObject : System.Object
ConnectedOrgVersion : 8.0.1.79
microsoft.xrm.tooling.connector
CrmConnection
有一些大陷阱,可能会让您用头撞墙。
引用自http://crmtipoftheday.com/2016/01/14/rumors-about-microsoft-xrm-client-death-are-exaggerated/
Note the following:
- Url must be in the form of https://orgname.contoso.com/orgname. For on-premises and IFD deployments the connector expects orgname to be
at the end and looks like it does not make any attempt to deduce
orgname from the server url.
- Domain name must be specified but it’s not passed via claims, so it can be anything. Really any non-empty string o__O
- Username must be UPN. If it’s not, then, since domain name is not passed it, ADFS 3.0 throws a fit (ADFS 2.0 assumes the domain)
以下对我有效
get-crmconnection -ConnectionString "Server=https://{orgname}.{domain}.com/{orgname}; Domain=this_isnt_used_but_must_be_provided; UserName={domain}\{user}; Password={password}"
用户名稍微修改为 UPN
get-crmconnection -ConnectionString "Server=https://{orgname}.{domain}.com/{orgname}; Domain=this_isnt_used_but_must_be_provided; UserName={user}@{domain}; Password={password}"
我想使用 SDK 中包含的 PowerShell cmdlet Get-CrmConnection
连接到 CRM 2016 服务器。
我找不到正确的连接字符串。
连接到本地网络中的服务器正常:
Get-CrmConnection -ConnectionString "Url=http://<server>/OrganizationName;"
但是连接到为 IFD 配置的服务器失败:
Get-CrmConnection -ConnectionString "Url=https://crm.ourdomain.com/"
Get-CrmConnection : Organization cannot be null or empty.
Parameter name: Organization Name
At line:1 char:1
+ Get-CrmConnection -ConnectionString "Url=https://crm.ourdomain.com/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SyntaxError: (:) [Get-CrmConnection], ArgumentNullException
+ FullyQualifiedErrorId : -9,Microsoft.Xrm.Tooling.CrmConnector.Powershell.Commands.GetCrmConnectionCommand
我尝试在连接字符串中添加 AuthType 参数,提供组织名称,但没有成功。重要的是我可以使用交互模式连接:
Get-CrmConnection -InteractiveMode
此returns以下连接:
IsReady : True
IsBatchOperationsAvailable : True
Authority :
OAuthUserId :
ActiveAuthenticationType : AD
OrganizationServiceProxy : Microsoft.Xrm.Tooling.Connector.CrmWebSvc+ManagedTokenOrganizationServiceProxy
OrganizationWebProxyClient :
LastCrmError : OrganizationWebProxyClient is null
LastCrmException :
CrmConnectOrgUriActual : https://crm.ourdomain.com/XRMServices/2011/Organization.svc
ConnectedOrgFriendlyName : OrganizationName
ConnectedOrgUniqueName : OrganizationName
ConnectedOrgPublishedEndpoints : {[WebApplication, https://crm.ourdomain.com/], [OrganizationService,
https://crm.ourdomain.com/XRMServices/2011/Organization.svc],
[OrganizationDataService,
https://crm.ourdomain.com/XRMServices/2011/OrganizationData.svc]}
ConnectionLockObject : System.Object
ConnectedOrgVersion : 8.0.1.79
microsoft.xrm.tooling.connector
CrmConnection
有一些大陷阱,可能会让您用头撞墙。
引用自http://crmtipoftheday.com/2016/01/14/rumors-about-microsoft-xrm-client-death-are-exaggerated/
Note the following:
- Url must be in the form of https://orgname.contoso.com/orgname. For on-premises and IFD deployments the connector expects orgname to be
at the end and looks like it does not make any attempt to deduce
orgname from the server url.- Domain name must be specified but it’s not passed via claims, so it can be anything. Really any non-empty string o__O
- Username must be UPN. If it’s not, then, since domain name is not passed it, ADFS 3.0 throws a fit (ADFS 2.0 assumes the domain)
以下对我有效
get-crmconnection -ConnectionString "Server=https://{orgname}.{domain}.com/{orgname}; Domain=this_isnt_used_but_must_be_provided; UserName={domain}\{user}; Password={password}"
用户名稍微修改为 UPN
get-crmconnection -ConnectionString "Server=https://{orgname}.{domain}.com/{orgname}; Domain=this_isnt_used_but_must_be_provided; UserName={user}@{domain}; Password={password}"