Saturday, 3 July 2021

Add user

 #Add user though Powershell Script

$web = Get-SPWeb -identity "http://mysite.com/"

$web.EnsureUser("USER1")

Set-SPUser -Identity "i:0#.w|soe\USER1" -web "http://mysite.com/" -Group "READ"


Tuesday, 19 May 2020

Usage and Health Data Collection Proxy Stopped

$UsageAppProxy = Get-SPServiceApplicationProxy | Where {$_.TypeName -eq "Usage and Health Data Collection Proxy"}
$UsageAppProxy.Provision()

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)

Thursday, 2 August 2018

Get the number of user connected to the server.

Get-Counter -Counter "web service(my)\current connections" -ComputerName "Server90.com"

"my" is Name of the application in appool and Server90.com is server name

Site created time in SharePoint

$w = Get-SPWeb http://uat2013.corp.com

$w.Created