Git Product home page Git Product logo

microsoft.xrm.data.powershell.samples's Introduction

Microsoft.Xrm.Data.PowerShell.Samples

Overview

This is samples repositry for Microsoft.Xrm.Data.PowerShell

This code repo is managed by Sean McNellis and Kenichiro Nakamura, however we accept community input and PR's (especially for samples).

We'd like each sample to contain a README.md for light documentation and notes but some samples are documented in PS comments. If you see the need for a readme in one of the samples please send us a PR.

About Authors

Sean McNellis Twitter: @seanmcne Team Blog (English): http://blogs.msdn.com/CrmInTheField

Kenichiro Nakamura Team Blog (Japanese): http://blogs.msdn.com/CrmJapan

Team Twitter: @pfedynamics

microsoft.xrm.data.powershell.samples's People

Contributors

crshnbrn66 avatar jeffreynelson avatar kenakamu avatar rikiku avatar sanjint avatar seanmcne avatar yaweriqbal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microsoft.xrm.data.powershell.samples's Issues

Unable to run the View Performance script to completion

I'm able to get the script to start and run through the views, but when it reaches the end and starts to write out the list of the top 10... it fails.
Initially I found that it was a typo in the library ("verobse" instead of "verbose") - but after correcting that now I get:

2016-08-01_20-31-50

Archive attachments to azure storage

It will be great to have an example of how we could archive attachments to azure storage in CRM online and store a link in Notes. (we have this program written in C# but could be a great example in powershell)

Bulk Duplicate Deletion jobs using a script

Any thoughts on how we could run a bulk duplicate deletion job using powershell with a predefined view. The idea is to export all duplicate contacts in a csv file, so it can be investigated further in a spreadsheet.

On a similar note, any thoughts on retrieving a multi-page view result from powershell. Get-CrmRecordsByViewName only returns the first 5000 results. It will be great to retrieve the entire result set 99,999

Delete activitypointer entry given Id

Tried to use Remove-CRMRecord to delete activities but got a error message as below

Remove-CrmRecord -conn $conn -EntityLogicalName activitypointer -Id 5e24fedb-a052-e511-8103-c4346bad2660

The 'Delete' method does not support entities of type 'activitypointer'.

Dynamic Marketing List

Hello,

It would be great if we could get a command which would retrieve a dynamic marketing list and its constituents. In other words execute the fetchxml query stored in a dynamic marketing list.

-Venkat

Get/Set all usersettings

Hello,

It would be great to get a list of all CRMUserSettings for a particular property. example, incomingemailfilteringmethod

The use case is to retrieve a list of all user settings for "incomingemailfilteringmethod"
Once a review is done, we need the ability to set "incomingemailfilteringmethod" to "Email messages from CRM Leads, Contacts and Accounts"

-Venkat

Sample ideas

it will be great if we can get samples of how each command could be used.
For instance, how to retrieve records using FetchXML (or) specify filtercriteria in powershell command
How to access individual record in the resultset
How to page across pages in the resultset

Here is an example of my own contribution, where I wrote a simple script which would take a csv file of contactId's and mark them inactive. Hope it is of help.

Ensure CRM 2015 sdk and Microsoft.Xrm.Data.PowerShell are installed

Ensure $conn is populated by logging in using example provided here

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Import-Module Microsoft.Xrm.Data.PowerShell

$global:conn = Get-CrmConnection -InteractiveMode

$contactList=Import-CSV .\contact_dupes.csv
ForEACH ($Contact in $contactList) {
$contactid = $contact.contactId

$contactid="449104b5-1ed0-e411-80e7-c4346bac7958"

Retrieve CRM Record

$contactrecord = Get-CrmRecord -conn $conn -EntityLogicalName contact -id $contactid -Fields firstname,statecode

set the status code to be inactive

$contactrecord.statecode=1

Update CRM Record

echo $contactid
Set-CrmRecord -conn $conn -CrmRecord $contactrecord
}

Solution import fails due to timeout

Hello!
I faced with a problem using Import-CrmSolution:
Solution size is 1.5 Mb, and import via CRM gui usually takes 2-3 minutes. but using the code I have next exeption:
capture
At the same time solution was imported to CRM.
The code (run via jenkins) is:
Param (
[Parameter(Mandatory=$True)]
[string]$TargetServer,
[Parameter(Mandatory=$True)]
[string]$organizationName2
)
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
try {
$conn2 = Get-CrmConnection -OrganizationName $organizationName2 -ServerUrl $targetServer -Credential $cred2 -MaxCrmConnectionTimeOutMinutes 60 -ErrorAction Stop -Verbose
}
catch {
write-output $Error[0].Exception
}
try {
Import-CrmSolution -conn $conn2 -SolutionFilePath $env:importedSolution -OverwriteUnManagedCustomization -ErrorAction Stop -Verbose
}
catch {
write-output $Error[0].Exception
}
Exit $LastExitCode

Could you please give an advise how to handle a moment than solution import was finished and end the script successfully? I have tried different timeouts, it doesn't work.

'Import-CrmSolutionAsync' is working well, but is not good for this case because I'd like to get detailed error message if import is failed

Thank you in advance!

How to Test & Enable mailbox in CRM Online?

I am trying to use Set-CRMMailbox but couldn't figure out.
After enabling the mailbox thru Portal, when I check with Get-CRMMailbox -userID, I see EnabledForOutgoingEmail , EnabledForIncomingEmail, EnabledForACT, OutgoingEmailStatus, ACTStatus & IncomingEmailStatus attributes are getting set as Yes or Success.

update Organization Information

I am new to XRM Powershell.
I am trying to update Organization Information like Strategic Business Unit, Global Business Line, Legacy Division, Region,
Country for bulk users.

So, far I am able to update business unit using below

#Get all business Unit and store it in variable
$businessUnit = Get-CrmRecords -EntityLogicalName businessunit -FilterAttribute name -FilterOperator eq -FilterValue 'abc' -Fields businessunitid
$businessUnitId = $businessUnit.CrmRecords[0].businessunitid.Guid

#Set the system user business unit
Set-CrmRecord -EntityLogicalName systemuser `
-id $systemId -Fields @{ "businessunitid"=(New-CrmEntityReference -EntityLogicalName systemuser -Id $businessUnitId)}

How can I update Organization Information like Strategic Business Unit, Global Business Line in similar way?
Any help is appreciated.

Creating A New Entity Within A Solution?

Hi,

Is there any way to create an entity using this module
I know you can create a new solution using the below:

$UniqueName = Read-Host "Name Of New Solution"
$PublisherID = "----"
$Publisher = New-CrmEntityReference -entitylogicalname publisher -id $PublisherID
$Version = "1.0"

$Entity = New-CrmRecord -EntityLogicalName solution -fields @{friendlyname = $uniquename; uniquename = $uniquename;
publisherid = $publisher;`
version = $version}

But cannot fathom how you could create an entity within a solution

Document Location

Hello,

Is there currently a way to use the XRM Powershell to create Document Locations within Sharepoint Online? I can create the sharepoint location and the docs but need to be able to create the location in Dynamics at the same time.

Thanks,
Dave

Opportunity to enable or disable user via powershell script

Hi all!
I've tried to enable disabled users, and I've faced the issue I could'n change property "isdisabled" for systemuser entity.
I can enable user in the web, but I couldn't do it in the script. Also I found out that "IsValidForUpdate" is "False" for field "isdisabled" in the systemuser entity.
So, my question is:
How could I change user's state from enable to disable and back, using powershell?

Issue with data import

Hi,
I'm writing to understand what could have caused the below issue while importing data. I'm using configuration migration tool module powershell crm commands i.e. import-crmdatafile to push data.

#import configuration migration powershell module
- powershell: |
Install-Module -Name Microsoft.Xrm.Data.Powershell -RequiredVersion 2.8.14 -Force -Scope CurrentUser
Install-Module -Name Microsoft.Xrm.Tooling.ConfigurationMigration -RequiredVersion 1.0.0.64 -Force -AllowClobber -Verbose
displayName: 'Install XRM Modules'

#importdata
- powershell: |
$conn = Get-CrmConnection -ConnectionString "$(ConnectionString)"
$importParams = @{
CrmConnection = $conn
DataFile = "$data.zip"
ConcurrentThreads = "2"
}
Import-CrmDataFile @importParams -EmitLogToConsole -Verbose -ErrorAction Stop
displayName: 'Import data.zip'
timeoutInMinutes: 180

ERROR
Error : The request channel timed out while waiting for a reply after 00:02:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

Data.zip file doesn't have any huge data, it is just 2 records and interestingly this is importing the records but failing to associate the relationship N:N. This happened in our PRD environment and has had no issues in other downstream environments.

PLEASE HELP!

@seanmcne

Export-CrmSolution does not work with Dynamics 365 v9

In Dynamics 365 instances that were updated to v9, Export-CrmSolution does not work any more.
It throws the error "Solution with name x in CRM Instance: y not found!", although the solutions are installed an can be exported manually.

The cmdlet still works in instances where identical solutions are installed, but that are not yet updated to v8.2.

A fix would be greatly appreciated. Thanks!

CRM 2013 OnPrem Export error

I'm getting an error when I try to export from a 2013 OnPrem. The error says that "ExportSales" is not supported. It works fine when I manually skip this line in the Microsoft.Xrm.Data.PowerShell.psm1 file.

$exportRequest.ExportSales =$ExportSales

The version of CRM said 6.1.x in the debugger, so perhaps a quick check of the version before setting this property would solve the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.