Thursday, March 16, 2017

sharepoint Powershell migrate users in a web application

[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({
param([string]$url = "http://sharepointsite/", `
[string]$oldprovider = `
"keystoneuser", `
[string]$newprovider = `
"i:0ǵ.t|keystone sts|radiant\")

add-pssnapin microsoft.sharepoint.powershell -EA 0

# Get all of the users in a site
#$users = get-spuser -web $url -Limit "11000"
$csvFile = "C:\Users\Users.csv"
# Loop through each of the users in the site
Import-Csv $csvFile | ForEach-Object{
# Create an array that will be used to split the user name from the domain/membership provider
$a=@()
$username = $_.oldlogin
$a = $username.split(":")
$userloginprovider = $a[0]
$displayname = $a[1]
Write-Host "Old Username: $username."
# Create the new username based on the given input
$newalias = $newprovider + $displayname
$user = Get-SPUser -Identity $username -Web http://
sharepointsite/ -EA "SilentlyContinue"
if($user -notlike "")
{
Move-SPUser –Identity $user -NewAlias "$newalias" -IgnoreSID -Confirm:$false -EA "SilentlyContinue"
Write-Host "User Changed to $newalias"
}
}
}); 




To migrate user in farm use the following,


$farm.MigrateUserAccount( $_.oldlogin, $_.newlogin, $false )

SharePoint: How to change the default home page

$site = Get-SPSite http://peakfinder/sites/site
$web = $site.RootWeb
  (or $web = $site.OpenWeb("site")
$folder = $web.RootFolder
$folder.WelcomePage = "SitePages/home.aspx"
  (or  $folder.WelcomePage = "default.aspx")
  (or  $folder.WelcomePage = "SiteAssets/myhome.aspx")
$folder.update()
$web.Dispose()
$site.Dispose()

Local accounts should only be used in standalone mode SharePoint 2010 / 2013 run PSConfig

I was trying to install SharePoint Server 2010. I ran into the following error.

Local accounts should only be used in standalone mode.

To get around this, you will need to use PSConfig  Command to create your Content Database.

To use PSConfig  command you need run command prompt with run as Administrator.

Then go the following location:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN

PSCONFIG.EXE -cmd configdb -create -server 5282-SUSHIL -database sharepoint_2013_config -user 5282\administrator -password password -passphrase password@123 -admincontentdatabase sharepoint2013_admincontent

*******************Worked*****************************

 

example: that worked for me.

psconfig -cmd configdb -create -server WIN-H0QE54APLD0 -database sharepoint_2013_config -user administrator -password admin@123 -passphrase pass@123 -admincontentdatabase sharepoint2010_admincontent

IT will run the task from 1 to 3 step only

then you need to run SharePoint Configuration Wizard.

Error occurred in deployment step ‘Retract Solution’: Attempted to perform an unauthorized operation

Error occurred in deployment step ‘Retract Solution’: Attempted to perform an unauthorized operation

You can fix it by setting the access policy for the current user deploying the SharePoint Solution.

Go to Central Administration - Manage web applications (under Application Management).

Please select the SharePoint application and then press "User Policy" in the ribbon. Over there you add your user you want  deploy with and give him full control.

PowerShell Script to Start / Stop SharePoint Timer Service

To stop Timer service:

net stop SPTimerv4

To start timer service

net start SPTimerv4