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)