onsdag den 15. januar 2014

Managing CRM 2011 and 2013

I fixed a series of bugs and tested my CRM powershell module against both 2011 and 2013. Enjoy.

PSCRM.zip

Add-CRMRoleMember
Disable-CrmLanguage
Disable-CrmOrganization
Disable-CRMSystemUser
Enable-CrmLanguage
Enable-CrmOrganization
Enable-CRMSystemUser
Get-CrmAvailableLanguage
Get-CrmLanguage
Get-CrmOrganization
Get-CRMRole
Get-CRMSystemUser
Get-CRMSystemUserSettings
Get-CrmUsermappingFile
Import-CrmOrganization
New-CrmConfig
New-CRMCustomerAdminRole
New-CrmOrganization
New-CRMSystemUser
Remove-CrmOrganization
Remove-CRMRole
Remove-CRMRoleMember
Remove-CRMSystemUser
Select-CrmOrganization
Set-CRMSystemUser
Set-CRMSystemUserSettings

17 kommentarer:

  1. Hi,

    How to use your powershell module ? How to Import it.

    Thanks

    SvarSlet
  2. hey

    Extract the zip file some where, lets say its c:\tmp

    you need to unlock the dll files, since downloading files will "tag" them
    Unblock-File C:\tmp\pscrm\*.dll

    Then import the module using
    Import-Module C:\tmp\pscrm\pscrm.psd1

    to get a list of commands, to a
    Get-Command -Module pscrm

    To "talk" with anything you need to be authenticated first, so start by doing a

    New-CrmConfig -server dev.crm.wingu.dk

    If you are not on a machine that is member of the domain, you can also use username/password

    New-CrmConfig -server dev.crm.wingu.dk -username alz@wingu.dk -password *****

    after that your ready to use any of the other commands, for instance
    Get-CrmOrganization

    SvarSlet
    Svar
    1. maybe its worth mentioning server should be the fqdn (domain name, not URL) for your discovery service ...
      Its the buttom one one the first page, when going through the "Configure Internet-Facing Deployment" wizard

      Slet
    2. Our CRM instances (prod and dev) sit off in a third party cloud. Visiting the URL of the instance hits a Fed Server, Authentication is processed via windows credentials then passes through. How would I gain the FQDN to connect with this server?

      Slet
  3. Thanks, I can know create organization.
    But I have an other problem to add user on oraganization. Why upn is check on AD ? It's not necessary.

    PS C:\Users\admincrm> New-CRMSystemUser -upn name.firstname@mydomain.com
    New-CRMSystemUser : Could not find 'name.firstname@mydomain.com' in AD.
    At line:1 char:1
    + New-CRMSystemUser -upn name.firstname@mydomain.com
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : FromStdErr: (:) [New-CRMSystemUser], Exception
    + FullyQualifiedErrorId : 0,pscrm.NewCRMSystemUser

    SvarSlet
    Svar
    1. hey

      you where correct.
      as a quick "hack" i made a version that supports creating users with first/lastname and a email. Tested against CRM 2013

      https://skadefro.blob.core.windows.net/public/pscrm2.zip

      Using
      New-CRMSystemUser -upn name.firstname@mydomain.com
      it will try and resolve the user in AD

      using
      New-CRMSystemUser -upn findme@somewhere.com -firstname find -lastname me -skiplookup
      It will bypass all checks ( first/lastname is mandator in CRM and since it cannot look it up in add you need to suply them )

      Slet
  4. Thanks a lot.
    Is it possible to set my user "System Administrator"by exemple. I don't find how.
    Is it with Add-CRMRole ?


    PS C:\Users\admincrm> Add-CRMRoleMember
    cmdlet Add-CRMRoleMember at command pipeline position 1
    Supply values for the following parameters:
    name: System Administrator
    user: mail@domain.com
    Add-CRMRoleMember : Cannot bind parameter 'user'. Cannot convert the "mail@domain.com" value of type "System.String" to type "pscrm.SystemUser".
    At line:1 char:1
    + Add-CRMRoleMember
    + ~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Add-CRMRoleMember], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,pscrm.AddCRMRoleMember

    SvarSlet
  5. roles is language specific in CRM so can be a little tricky. There is a way to find the english name for each group, but since i wanted to support "custom" roles too, i never got around to finish it. So for now you need to use the localised name (the base language of your CRM installation)

    Get-CRMRole
    gives you a list of all roles in current organisation

    Get-CRMRole -user (Get-CRMSystemUser -domainname "user@domain.dk")
    Will give you all roles for user user@domain.dk

    Add-CRMRoleMember -Role (Get-CRMRole "System Administrator") -user (Get-CRMSystemUser -domainname "user@domain.dk")
    Will add user@domain.dk to the role "System Administrator" if such exists.

    Remove-CRMRoleMember -Role (Get-CRMRole "System Administrator") -user (Get-CRMSystemUser -domainname "user@domain.dk")
    Will remove user@domain.dk from the role "System Administrator" if such exists.

    or if you prefere using variables

    $crmrole = Get-CRMRole 'Systemadministrator'
    $crmuser = Get-CRMSystemUser -domainname "user@domain.dk"
    $isAdmin = (Get-CRMRole -user $crmuser | where {$_.Name -eq 'Systemadministrator'})
    if(!$isAdmin)
    {
    Add-CRMRoleMember $crmrole $crmuser
    }

    SvarSlet
  6. Is there any way to perform "New-CrmConfig -server" with a CRM setup that does not utilize https? My server is not being found because it is prepending "https://" when really http is all that I can deal with.

    Thanks, this script is a great idea.

    SvarSlet
    Svar
    1. hey, i haven't tested this but i did try take that into account.
      Did you try with -nossl switch on New-CrmConfig ?

      Slet
    2. That worked, thanks!

      Slet
  7. Is there any support for managing Teams using this module?

    SvarSlet
    Svar
    1. no I didn't need that, but i can do that too, if you need it.
      Just creating/modifying/deleting teams and members ?

      Slet
  8. Yes, that is it exactly. If you could do that it would be much appreciated. You should toss up a donation link on your site so that I can buy you a virtual drink in return. This module is making my life a lot easier.

    SvarSlet
    Svar
    1. Hey. I haven’t forgotten you; work has just been a complete nightmare the last few weeks. But my 3 week holiday has just started, so i will properly have time to do it now ;)....

      Slet
    2. Awesome, that'll be the last piece in the puzzle for completely automating our new user setups. Thanks

      Slet
  9. Is it possible to set manager on a user?

    SvarSlet