Monday, 26 October 2015

Invalid Action

When trying to browse for CRM org, I started to get following Error


Invalid Action
The selected action was not valid.


When looking into event viewer got following information.


Current key (KeyType : CrmWRPCTokenKey) is expired. This can indicate that a key is not being regenerated correctly. Current Key : CrmKey(Id:4e1d5f40-4d60-e511-a481-00155dc1050c, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True, ValidOn:09/21/2015 10:41:04, ExpiresOn:10/24/2015 10:41:04, CreatedOn:09/21/2015 10:41:04, CreatedBy:<domain>\<domain user name>.




Resolution:
Start the async service (this could be stopped for many reasons, running out of space/performace and developer thought to stop, service was configured to run under user account and the useraccount either expired or disabled and now async service no longer running). Once async service started restart IIS after 5 minutes, so that new generated keys can be used.



Monday, 12 October 2015

windows shortcut commands

Windows -> Run

1. inetcpl.cpl : opens internet options

2. iexplore.exe -extoff : opens internet explorer with addons as disabled

3. inetmgr : opens IIS manager

Monday, 21 September 2015

Enable-WSManCredSSP : Root element is missing.

 Enable-WSManCredSSP -Role Server

Enable-WSManCredSSP -Role client -DelegateComputer *.<<FQDN e.g kuk.solutions.com>>

Error:
Enable-WSManCredSSP : Root element is missing.




At line:1 char:1

+ Enable-WSManCredSSP -Role client -DelegateComputer *.mydomain.com

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (:) [Enable-WSManCredSSP], XmlException

+ FullyQualifiedErrorId : System.Xml.XmlException,Microsoft.WSMan.Management.EnableWSManCredSSPCommand
 
 


Solution applied was to run the script provided in the link below to directly update values.

http://stackoverflow.com/questions/18113651/powershell-remoting-policy-does-not-allow-the-delegation-of-user-credentials


 

Friday, 18 September 2015

get crm service users and app pool identitiy and add them to sharepoint

#$SPSiteURL = 'http://lbh.ntlm/sites/rnbtest'
#$GroupName = 'CRM Docs Members '

[CmdletBinding()]
param ([Parameter(Mandatory=$true)] $SPSiteURL,[Parameter(Mandatory=$true)] $GroupName)
$ErrorActionPreference = "Stop"
 

$CRMAPPUsers = Get-WmiObject win32_service | Where-Object{ ($_.Name -like "MSCRMUnzipService") -or ($_.Name -like "MSCRMSandboxService") -or ($_.Name -like 'MSCRMAsyncService$maintenance') -or ($_.Name -like "MSCRMAsyncService") } |%{$_.StartName}|Get-Unique

$CRMAppUser = Get-WmiObject -Class IISApplicationPoolSetting -namespace "root\microsoftiisv2" | Where-Object {$_.Name -like 'W3SVC/APPPOOLS/CRMAppPool'}|%{$_.WAMUserName}
$Users = $CRMAsyncUser , $CRMAPPUsers
$Users = $Users|Get-Unique
if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"}
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$GroupName ='RNBTest Members'
$web = Get-SPWeb -Identity $SPSiteURL
foreach ($User in $Users) {
$User
$web.EnsureUser($User)
$SPUser = get-spuser -web $sPSiteURL|where-object{$_.userlogin -like "*$User*"} |%{$_.Userlogin}

Set-SPUser -UserAlias $SPUser -Web $SPSiteURL -Group $GroupName
#stsadm -o adduser -url $SPSiteURL -userlogin $User -useremail "email@dummy.com" -group $group -username 'dummyusername'
}

Thursday, 17 September 2015

Powershell

Pre-Req .Net 4.0 Framework full
http://www.microsoft.com/en-GB/download/details.aspx?id=17851

Download PowerShell V3
http://www.microsoft.com/en-us/download/details.aspx?id=34595


Enable Remoting

To connect to a different machine (or local) and use that's feature e.g. I am logged on to Machine A (my deb box) (no SharePoint installed) and Machine B got SharePoint stuff and I got a task to write PowerShell script add x,y and z user to SharePoint site. The solution is use to remoting instead of logging on to Machine B.


On Machine B write following command
Enable-PSRemoting -Force

On Machine A write following command

Enter-PSSession -ComputerName MachineB -Credential (Get-Credential <domain>/<username>)

now enter SharePoint related command from with in MacihneB like it got SharePoint installed (the commands are executed on remote machine, and PowerShell gets the response with similar objects to work against gets attributes with data but not methods)

Wednesday, 26 August 2015

fetch xml to query expression

Some times its easier to get fetch xml using advance find, but then to use it in query expression use the following command, this take fetchxml and then returns the query expression object


var conversionRequest = new Microsoft.Crm.Sdk.Messages.FetchXmlToQueryExpressionRequest


{

FetchXml = fetchXml

};
var conversionResponse =

(Microsoft.Crm.Sdk.Messages.FetchXmlToQueryExpressionResponse)_service.Execute(conversionRequest);

QueryExpression queryExpression = conversionResponse.Query;