Thursday, 4 April 2019

Remove People picker from SharePoint

#Remove People picker from SharePoint
STSADM.exe -o setproperty -pn peoplepicker-searchadforests -pv  -url "http://mysite.com"

#Remove the properties.

$wa = Get-SPWebApplication http://mysite.com
$wa.PeoplePickerSettings.ActiveDirectoryCustomFilter = $null
$wa.Update()

#Get the People Picker value.
$wa = Get-SPWebApplication http://mysite.com
$wa.PeoplePickerSettings

#Get the People Picker exist or not.
STSADM.exe -o getproperty -pn peoplepicker-searchadforests  -url "http://mysite.com"

How to set people picker in cross domain / Multi domain of SharePoint

#This command is must Password can be any here
STSADM.exe -o setapppassword -password “Password”

#Cross Domain \ Multi domain
#Pass the Password in a variable
$password = 'XXXXXX'
$SecurePassword = (ConvertTo-SecureString $password -AsPlainText -Force)
$UnSecurePassword = [System.Net.NetworkCredential]::new("",$SecurePassword).Password

#Run People Picker command
stsadm -o setproperty -url http://mysite.com/ -pn peoplepicker-searchadforests  -pv "domain:Localdomain.com;domain:Guestdomain.com",Guestdomain\XXXX,$UnSecurePassword

# Enable the global setting for the farm. This must run in SP2019 
$farm = get-spfarm
$farm.Properties #show current properties values
$farm.Properties["disable-netbios-dc-resolve"] = "True"
$farm.Properties
$farm.Update()

#if you require filter

stsadm -o setproperty -url https://mysite.com -pn peoplepicker-searchadcustomfilter -pv "(|(mail=*@abcd.com) (mail=*@efgh.com) (mail=*@xyz.com)   (userPrincipalName=*@Localdomain.com) (objectcategory=group))"

#this has to run to sync
stsadm -o sync

#Get People picker Value
$wa = Get-SPWebApplication https://mysite.com
$wa.PeoplePickerSettings

#Remove People picker from SharePoint
STSADM.exe -o setproperty -pn peoplepicker-searchadforests -pv  -url "http://mysite.com"

#remove the properties.
$wa = Get-SPWebApplication http://mysite.com
$wa.PeoplePickerSettings.ActiveDirectoryCustomFilter = $null
$wa.Update()


Thursday, 7 March 2019

Delete corrupt site collection with PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$CorruptedSiteURL ="http://mysite.com/sites/sales"

#Get the site collection
$site = Get-SPSite $CorruptedSiteURL

#Get the GUID of the site collection
$siteGUID = $site.Id
Write-host "Site collection GUID:"$siteGUID

#Get the content Database of the Site collection
$siteDatabase = $site.ContentDatabase

#Force delete the site collection
$siteDatabase.ForceDeleteSite($siteGUID, $false, $false)