Quantcast
Channel: SharePoint Diary
Viewing all 1058 articles
Browse latest View live

Create SQL Server Alias using PowerShell

$
0
0
As per SharePoint best practices for SQL Server, SQL Alias needs to be created on all SharePoint Servers in the farm. Creating SQL Alias for SharePoint through UI, is already explained in my another post: Create SQL Server Alias for SharePoint , and here is the PowerShell version of creating SQL Server Alias.

#Name of your SQL Server Alias
$AliasName = "SP13_PROD_SQL"

# Actual SQL Server Name
$SQLServerName = "G1VSP13-SQLC001"

#These are the two Registry locations for the SQL Alias
$x86 = "HKLM:\Software\Microsoft\MSSQLServer\Client\ConnectTo"
$x64 = "HKLM:\Software\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo"

#if the ConnectTo key doesn't exists, create it.
if ((test-path -path $x86) -ne $True)
{
New-Item $x86
}

if ((test-path -path $x64) -ne $True)
{
New-Item $x64
}

#Define SQL Alias
$TCPAliasName = ("DBMSSOCN," + $SQLServerName)

#Create TCP/IP Aliases
New-ItemProperty -Path $x86 -Name $AliasName -PropertyType String -Value $TCPAliasName
New-ItemProperty -Path $x64 -Name $AliasName -PropertyType String -Value $TCPAliasName
finally, open these two executables to verify:
  • C:\Windows\System32\cliconfg.exe
  • C:\Windows\SysWOW64\cliconfg.exe

SharePoint Knowledge Transfer Check-List

$
0
0
In a SharePoint architect/administrator's life, Its quite a common task to takeover existing SharePoint environments at the time of Job/Role switch. From my experience, Here is the check list to help easing up that job:

SharePoint  Infrastructure
  • Farm(s) Topology - List of servers and roles, physical and logical architecture diagrams for production, Staging and Development Environment (if applicable)
  • Server Infrastructure (Physical/Virtual), Storage, CPU-RAM-Network configurations
  • List of Service Accounts (Setup account, Farm account, search crawler account, etc) and passwords
  • Maintenance windows schedule - Patching, patch Level? OS versions?
  • Incoming/Outgoing E-mail configurations. SMTP configuration details
  • IIS Level customizations (compression, URL rewrite, redirects, etc.)
  • Backup, Disaster recovery in place. Tools used (SCDPM, Comvault, etc). Backup frequency.
  • Database server details. SQL Alias? Redundancy - Clustering in place? Mirroring? Always ON?
  • Monitoring setup for server/application Health, SCOM, etc
  • Load Balancing/Publishing details (ISA? TMG? CISCO Ace? or any other Hardware load balancer, F5 Big IP?)
  • Third party software (Nintex, Layer2, Control Point, etc installed in the environment
  • Licensing details for SharePoint and any 3rd party software. Volume/MSDN Licenses for DEV/TEST? Premier support with vendors such as Microsoft?
  • Profile Import/My site setup - Schedules, directory services/sources List
  • Last but not least - Contact person/teams for all dependent teams such as Network, DBA teams, System Admins, Backup, AD, Server Hardware, Security, Exchange server, etc.
Users & Security:
  • User Base - Total No. of users, region, locations, internal vs. external, site usage in last one Month?
  • How external users access SharePoint? Published Intranet? users member of AD? VPN connections?
  • Custom authentication provider in use (E.g. FBA, AD LDS, ADFS, Live)? Kerberos ?
  • Web applications/CA is SSL enabled? certificate details, providers.
  • Any SharePoint specific Antivirus on SP Servers? E.g. Forefront antivirus for SharePoint? Third party anti-virus solutions such as McAFee?
  • Are there any exclusive site for end-user training materials, FAQs, KB, etc?Any self service sites?
  • Access Rights Policies? - Any custom permission levels created (E.g. contributor without delete)
SharePoint Inventory:
  • List of web Applications, site collections with owner contacts
  • List of customizations/custom solutions and its documentation
  • Additional Language Packs installed.
  • CA Specific custom settings - Recycle bin, Max File Upload size, Storage quotas, etc
  • Integration points (Interfaces) with LOB and other applications/ Software (SQL server reporting services?)
  • List of SharePoint and other related application databases
  • How Branding is applied, Whats being done? (feature staplers/custom site definitions/Themes/Custom CSS, Master pages, etc)
  • List of SharePoint Sites that are most critical to business?
  • Typical SharePoint Usages in the Org. (Collaboration, Knowledge Management, Enterprise content Management, Document management, Dashboards, etc. )
  • Repository for configuration files, Implementation/Build guides, Known error database (KEDB) , Incident Logs, RCA (root cause analysis), (CSV, SVN, TFS, etc.)
Process and Metrics:
  • Team Structure - Team Members, Roles supporting existing SharePoint environment.
  • System in place for Incident/Request/Change management? 
  • How end user requests are routed to the team? Provide the complete request life cycle.
  • Existing SLA and priorities for incident management. 
  • Governance Policies in place. E.g. site creations, content responsibility, support limits, etc 
  • Support statistics (Tickets received last month, open/close, etc)
  • Scheduled Reports to the business owners? E.g. Monthly reports for usage.
  • Remote Sharing/ User Interaction methods (Web ex, etc).
  • Communication plan for any planned/unplanned outages - Key stakeholder list
Please comment to add/remove your own items to this list.

"Open with Explorer" Greyed out in SharePoint 2013?

$
0
0
Open with Windows Explorer is Disabled in SharePoint 2013 or in SharePoint 2010? Well, Open with Explorer works only in 32 bit version of Internet Explorer! It may not work on Chrome or Firefox.
 open with explorer sharepoint 2013 disabled

Solution: 
To enable Open with explorer, Open your SharePoint 2010 or SharePoint 2013 site with 32 bit version of Internet explorer,  located at: "C:\Program Files (x86)\Internet Explorer\iexplore.exe"

Getting error on clicking open with explorer in SharePoint 2013? Well, Use this checklist to resolve: Open with Windows Explorer Error and Solutions for SharePoint

Export-Import All Lists and Libraries from One Site to Another using PowerShell

$
0
0
Requirement is to copy and paste all SharePoint lists and libraries from one site to another. While "Save List as a Template" is one approach, it doesn't work for larger lists and its time consuming. Using Central Administration export method also kills my time.

We can copy and paste SharePoint lists using PowerShell. Here is how to Export-Import all lists and libraries from one site to another using PowerShell:

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

#Custom PowerShell Function to Export All Lists and Libraries from a SharePoint site
Function Export-AllLists($WebURL, $ExportPath)
{
#Get the source web
$web = Get-SPWeb $WebURL

#Check the Local Folder export Lists

#Get all lists - Exclude System lists
$ListCollection = $web.lists | Where-Object { ($_.hidden -eq $false) -and ($_.IsSiteAssetsLibrary -eq $false) -and ($_.Author.LoginName -ne "SHAREPOINT\system") }

#Iterate through each list and export
foreach($list in $ListCollection)
{
Write-host "Exporting: " $list.Title
#Remove : from List title - As we can't name a file with : symbol
$ListTitle = $list.Title.Replace(":","")
Export-SPWeb $WebURL -ItemUrl "/$($list.RootFolder.Url)" -IncludeUserSecurity -IncludeVersions All -path ($ExportPath + $ListTitle+ ".cmp") -nologfile
}
}

#Custom PowerShell Function to Export All Lists and Libraries from a SharePoint site
Function Import-AllLists($WebURL, $ImportPath)
{
#Get the Target web
$web = Get-SPWeb $WebURL

#Check the Local Folder export Lists

#Get all File Backups to Import
$FilesCollection = Get-ChildItem $ImportPath

#Iterate through each file and import
foreach($File in $FilesCollection)
{
Write-host "Importing: " $File.Name
Import-SPWeb $webURL -path $ImportPath$File -includeusersecurity -UpdateVersions Overwrite -nologfile
}
}

#Call the function to export
Export-AllLists "http://sales.crescent.com/" "D:\Backup\"
#To import, Use:
#Import-AllLists "http://marketing.crescent.com/" "D:\Backup\"
This script helped me to move all lists from a highly customized and corrupted site to a clean SharePoint site. 
Here is my PowerShell script to copy-pasts all lists and libraries between Sites:

Related Post: Copy SharePoint List or Library between Sites with PowerShell

SharePoint 2013 Warmup Scripts using PowerShell

$
0
0
What is "Warmup Scripts" in SharePoint?
By default IIS applications pools recycles every night to keep clean memory space -  Every time during IIS Application pool recycles - Asp.net assemblies to be re-compiled to serve the page to end user. So, When the recycling occurs during mid night (or when you do manual recycling/IISReset), The very first user types the URL, experiences the wait time of 30 seconds to 120 seconds on an average. (again, this depends on your hardware-software configurations!). But the subsequent requests come faster from the server for the same site!

So, the idea is: "warm up" the site before users start requesting it so that they don't suffer at first time hit.  Warm up scripts triggers  requests to your servers regularly to "Warmup" IIS.

Ok, Where is the script? which warm up script I've to use? Well, There are lot many available. Here is one among them: https://spbestwarmup.codeplex.com/ and You may have to customize it based on your requirement.

In my experience, This simple warmup script works amazing with all versions of SharePoint: SharePoint 2013, SharePoint 2010 and in SharePoint 2007:

Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

function Get-WebPage([string]$url,[System.Net.NetworkCredential]$cred=$null)
{
$WebClient = new-object net.webclient
if($cred -eq $null)
{
$cred = [System.Net.CredentialCache]::DefaultCredentials;
}
$WebClient.credentials = $cred;
return $WebClient.DownloadString($url);
} # end Function

# Make sure the account has enough permission to read sites
#$cred = [System.Net.CredentialCache]::DefaultCredentials;
#Change these values accordingly
#$cred = new-object System.Net.NetworkCredential("USER ID","PASSWORD","DOMAIN")

#Get All Web Applications and iterate through
$WebAppsColl = Get-SPWebApplication -IncludeCentralAdministration

foreach($WebApp in $WebAppsColl)
{
#Get All site collections and iterate through
$SitesColl = $WebApp.Sites

foreach ($Site in $SitesColl)
{
Write-Host "Warming up Site collection:" $Site.URL
$html = Get-WebPage -url $Site.URL -cred $cred
}

#Change these URL's if you need any other Site/URL for warmup
#$html = Get-WebPage -url "http://northwind.crescent.com/SitePages/Home.aspx" -cred $cred
You'll have to add each of your web application to the above list of URLs. For Search web application, You'll have to send a Search query, such as: https://intranet.contoso.com/_layouts/OSSSearchResults.aspx?k=warmup

You have to edit your host files, so that Your Warmup script hits the same WFE server its running, instead of going to the load balancer and gets pages from any other web server.

Warmup Script for Host-Named Site Collections:
Lets add bit more enhancement to it:
  • Lets keep a log for warmed up sites, 
  • Warm-up all Host-named site collections - Lets create a proxy to hit on the SAME web front end rather going to load balancer - We can't edit HOST file for each HNSC, isn't it?
start-transcript -path C:\Scripts\$(get-date -format 'ddMMyyyy').txt -append

Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

function Get-WebPage([string]$url)
{
$bypassonlocal = $false
$proxyuri = "http://" + $env:COMPUTERNAME
$proxy = New-Object system.Net.WebProxy($proxyuri, $bypassonlocal)
$wc = new-object net.webclient
$wc.credentials = [System.Net.CredentialCache]::DefaultCredentials
$wc.proxy = $proxy
$pageContents = $wc.DownloadString($url)
#write-host $wc.ResponseHeaders.Get("WFE")
$wc.Dispose()
return $pageContents
}

#Central Administration
write-host "Warming up Central Administration..."
$WebApps = Get-SPWebApplication -IncludeCentralAdministration
Get-SPWebApplication -IncludeCentralAdministration | ? {$_.IsAdministrationWebApplication -eq $true} | % { $Req = Get-WebPage $_.url }
write-host "`nCentral Administration Warmed up!"

# Warm up Host Name Site Collections (HNSC)
Write-Host "Warming up Host Name Site Collections (HNSC)...`n"
$hnsc = Get-SPSite -Limit All |? {$_.HostHeaderIsSiteName -eq $true} | Select Url
foreach ($sc in $hnsc) {
write-host "Processing HNSC: "$sc.Url
$Req = Get-WebPage $sc.url
}

# Clean Temporary Files
Remove-item "$env:systemroot\system32\config\systemprofile\appdata\local\microsoft\Windows\temporary internet files\content.ie5\*.*" -Recurse -ErrorAction SilentlyContinue
Remove-item "$env:systemroot\syswow64\config\systemprofile\appdata\local\microsoft\Windows\temporary internet files\content.ie5\*.*" -Recurse -ErrorAction SilentlyContinue

stop-transcript

When and How often we've to run Warm up Scripts?
Usually, We schedule it to run before the beginning of the day. Its a good idea to schedule the PowerShell script via Task scheduler and Warmup script must be scheduled on all WFEs of your SharePoint Farm.

Here is how you can schedule PowerShell scripts using Windows task scheduler: Create a Scheduled Task for PowerShell Script with Windows Task Scheduler
Use "Search Crawl Account"to run warm-up script (Provided, This account has "Login as a Batch Job rights!").

You can create a scheduled task with command line:
schtasks /create /tn "Warmup Script" /ru <<Domain\Account>> /rp <<Password>> /rl highest /sc daily /st 01:00 /ri 60 /du 24:00 /tr "PowerShell.exe -ExecutionPolicy Bypass D:\Scripts\Warmup.ps1"  

How to Find Which SharePoint Server You are Hitting

$
0
0
To troubleshoot a issue in SharePoint environment, I had to figure out from which SharePoint server I'm getting the page response. How to check which SharePoint web front end is serving your requests? I found these two ways to determine which SharePoint WFE you are hitting:
  1. Using IIS HTTP Response header and Fiddler Tool
  2. Placing a specific image file in each WFE denoting its whereabouts and linking it to SharePoint

Method 1: Using HTTP Response Header

Set the HTTP Response Header in IIS:
  1. Go to your Web Front End server, Open IIS, Choose your SharePoint web application from Sites tree view. Open "HTTP Response Headers" widget find sharepoint server address, sharepoint find server name
  2. From the Right pane of the widget, Click on "Add" link, Give a name and value. Here, I gave "WFE" as name and "WFE01" as my web front end name. Click "OK"to save your changes. Repeat this step of setting HTTP response header in IIS for all of the web front end servers of your SharePoint farm!
  3. Now, from the client side, run Fiddler tool. From the Fiddler tool , Go to "Inspectors" tab and then "Header"section. You can get the custom HTTP response header we've created with its corresponding value.

    How to Find Which SharePoint Server You are Hitting

Method 2: WFE Specific Image 

What if you don't want to use tools like Fiddler? Well, you can just place an image depicting your web front end server name, link it to your SharePoint sites. E.g. Say, you have two web front end servers. Just make two different logo files of same name, say: "WFE-Logo.png" and place each of them in corresponding web front end server location: "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\IMAGES" . Here is mine:
 
Now, Go to any of your SharePoint site, change your site logo point to: "/_layouts/15/images/wfe-logo.png" and at run time, it should fetch the corresponding image from the web server.

Restore-SPSite Error on Backup-Restore Between Different Farms

$
0
0
When I was trying to backup restore between SharePoint DEV and QA Farms got this error message:
Restore-SPSite : <nativehr>0x80070003</nativehr><nativestack></nativestack>
Restore-SPSite : <nativehr>0x80070003</nativehr><nativestack></nativestack>

Root Cause:
The source and target SharePoint Farm's build version mismatch!

Solution: Upgrade either the source or destination SharePoint farm and then backup-restore.

Backdoor way:
What if you don't have the option of immediate upgrade and complete this backup restore operation? Here is the backdoor way to skip upgrades and backup-restore SharePoint sites or lists between farms with different versions/build numbers.

One way is: Backup-restore the content database of your SharePoint site collection to the target farm. While mounting your database will be automatically upgraded to target version build schema.

There is an another way: Binary Edit! Just open the backup file in any HEX editor tool, I've used HxD from: http://mh-nexus.de/en/hxd/ , and change the version build number to your target SharePoint farm version.

Try restoring the site collection again, It should work now.

Office Web Apps Previews Not Working in SharePoint 2013?

$
0
0
During a SharePoint 2013 deployment, integrated Office Web Apps 2013 with SharePoint 2013 with my implementation guide How to Install and Configure Office Web Apps 2013 for SharePoint 2013. Everything went well until we received all of the Office Web Apps services failing errors in SharePoint 2013.

Word Web Apps gave an error: 
Sorry, there was a problem and we can’t open this document.  If this happens again, try opening the document in Microsoft Word.”
Sorry, there was a problem and we can’t open this document.  If this happens again, try opening the document in Microsoft Word.

Excel and PowerPoint Web Apps also failed. "Excel Web App - Sorry, we're having a problem showing this workbook"
Excel Web App - Sorry, we're having a problem showing this workbook"

On PowerPoint web application: "Microsoft PowerPoint Web App - Sorry, we couldn't open this presentation because we ran into a problem. please try again"
Microsoft PowerPoint Web App - Sorry, we couldn't open this presentation because we ran into a problem. please try again

Troubleshooting:
Analyzed event logs of SharePoint and OWA servers and found nothing useful. Logged in to the Office Web Apps server and Analysed the latest log file from "C:\ProgramData\Microsoft\OfficeWebApps\Data\Logs\ULS" location.

While scanning LOG files, found these lines:  "WOPICheckFile,WACSERVER FileNotFound [url:http://sharepoint.crescent.com/_vti_bin/wopi.ashx/files/7529f29d45234898b81a46a14a74203b?access_token=REDACTED_1072&access_token_ttl=1418077932722"
Office Web Apps Issue with SharePoint 2013 - WOPICheckFile,WACSERVER FileNotFound
Root Cause and Solution:
Well, Office web apps server must be able to resolve and communicate with SharePoint 2013 sites to render office documents in SharePoint sites. In my case, It couldn't do that because of a WRONG IP placed in the HOST file of Office Web Apps server! I just fixed it by clearing HOST file entries and creating global DNS record for SharePoint sites! You can also try placing a HOST file entry in Office web Apps server, pointing to SharePoint sites, if DNS change isn't possible.

So, Make sure Office Web Apps server is able to contact SharePoint sites to get rid of these issues.

Disable UAC in Windows Server 2012 - SharePoint Best Practice

$
0
0
In SharePoint 2013 farms on Windows Server 2012, its annoying that we've to choose "Run as Administrator" every time when opening Central Administration, Command Prompt, SharePoint Management Shell, Windows PowerShell,etc. and failing so would introduce some weird issues such as: buttons and links missing in SharePoint Central Admin ribbon, Getting Access denied for Farm administrators, etc.
PowerShell too! When launching SharePoint Management shell, it scolds with "The local farm is not accessible. Cmdlets with featuredependencyId are not registered." On running any SharePoint cmdlets, "Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permissions to access the database before trying again."
Although I'm a Domain Administrator and Local Server administrator, I've to pick "Run as Administrator" to get rid of these issues. I hate to do Right Click and choose "Run as Administrator" every time on these programs. So, Lets disable UAC in Windows Server 2012 in two steps. Here is how:
  • Go to Server Manager >> Choose "System Configuration" from Tools menu. (Shortcut: MSCONFIG)
  • Under Tools tab, Select "Change UAC Settings" and click on "Launch" button

  • Drag the slider down to "Never Notify" and click "OK".

But wait! We are not yet done. Make this registry change!
Unlike Windows Server 2008 R2, Sliding down UAC button to "Never notify" will NOT disable UAC in Windows Server 2012. You got to do one more fix in windows registry:
  • Open Windows Registry Editor (shortcut: regedit)
  • Navigate to the following registry key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
  • In the Right Pane, locate the "EnableLUA" DWORD value. Double click and set its Value "0" (zero)
  • Exit Registry Editor and then restart your Server.
You can achieve the registry fix with PowerShell. Just run these commands in Windows PowerShell.
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0"
Shutdown -r -t 0
This script disables UAC and restarts your Server automatically!

The installation of this package failed - Error in SharePoint 2013 Hotfix Installation

$
0
0
During a planned quarterly maintenance window, wanted to patch SharePoint 2013 servers with available hot fixes and cumulative updates (CU). As the first step, From Microsoft site http://technet.microsoft.com/library/dn789211%28v=office.14%29, requested hot fixes, Received an E-mail with hot fix links, downloaded those hot fixes and extracted to individual folders as in the below screen.
sharepoint cu the installation of this package failed

When trying to patch SharePoint 2013 servers with those hot fixes, installation failed suddenly with an error "The installation of this package failed".
sharepoint 2013 cu the installation of this package failed
Troubleshooting: 
Navigated to "%Tmp%" location and tried catching the root cause of the failure from the log file generated "opatchinstall.txt". Found these lines while scanning through the log file: "Getting the data from file <path location> UBERSRV_2.cab"
the installation of this package failed sharepoint foundation 2013
So, the catch here is, Hot fix installer is looking for "ubersrv_2.cab" file which we extracted into a different folder, and fails since it couldn't locate that file on the same folder it exists.

Solution:
Solution is simple! Just place all three extracted files together in the same folder and re-run the hot fix installation. It went through well after moving cab files in to the same folder where the hot fix installer ubersrv.exe was placed.
sharepoint 2013 service pack the installation of this package failed

Get All Users of SharePoint Farm-Web Application-Site Collection-Site using PowerShell

$
0
0
Requirement: Get all users of SharePoint environment.

PowerShell script to get all SharePoint users at Farm-Web Application-Site Collection-Web levels:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Output Report File
$currentLocation = (Get-Location).Path
$outputReport = $currentLocation + "\" + "SharePointUsers.csv"
#Write CSV File Header

#Array to hold user data
$UserDataCollection = @()

#Get All Web Applications and iterate through
$WebAppsColl = Get-SPWebApplication
#To Get all Users from specific web application, Use: $WeAppsColl = Get-SPWebApplication "web-app-url"
#and remove line #12

foreach($WebApp in $WebAppsColl)
{
Write-host "Scanning Web Application:"$WebApp.Name
#Get All site collections and iterate through
$SitesColl = $WebApp.Sites
#To Get all Users from site collection, Use: $SitesColl = Get-SPSite "site-collection-url"
#and remove lines between #11 to #20 and Line #55 "}"
#get all users from site collection PowerShell
foreach ($Site in $SitesColl)
{
Write-host "Scanning Site Collection:"$Site.URL
#Get All Webs and iterate through
$WebsColl = $Site.AllWebs
#To Get all Users from aq site, Use: $WebsColl = Get-SPWeb "web-url"
#and remove lines between #11 to #28 and Lines #53, #54, #55 "}"

foreach ($web in $WebsColl)
{
Write-host "Scanning Web:"$Web.URL
#Get All Users of the Web
$UsersColl = $web.AllUsers #get all users programmatically
#list all users
foreach ($user in $UsersColl)
{
if($User.IsDomainGroup -eq $false)
{
$UserData = New-Object PSObject

$UserData | Add-Member -type NoteProperty -name "UserLogin" -value $user.UserLogin.ToString()
$UserData | Add-Member -type NoteProperty -name "DisplayName" -value $user.displayName.ToString()
$UserData | Add-Member -type NoteProperty -name "E-mailID" -value $user.Email.ToString()

$UserDataCollection += $UserData
}
}
$Web.dispose()
}
$site.dispose()
}
}
#Remove duplicates
$UserDataCollection = $UserDataCollection | sort-object -Property {$_.UserLogin } -Unique

#Remove duplicates and export all users to excel
$UserDataCollection | Export-Csv -LiteralPath $OutputReport -NoTypeInformation

Write-host "Total Number of Unique Users found:"$UserDataCollection.Length

This script can be used to get all users in site collection and export all users to excel.

How to Rename SharePoint 2013/2010 Central Admin Database to Remove GUID

$
0
0
When you run the SharePoint products configuration wizard right after installing SharePoint binaries, it creates SharePoint central administration database with GUIDs. E.g. SharePoint_AdminContent_a149fa83-d2b9-4ad9-9e4c-ad12f73f0dd6.

Your DBAs may not be happy with these GUIDs as they deviates from database naming standards. So, lets rename SharePoint Central administration content database with the following steps:
Always, Remember to backup SharePoint Central Admin database prior performing these steps.
Here is how to remove GUID from SharePoint 2013 Central Admin database in three simple steps:

Step 1. Detach Central Admin Content Database:
Detach Central Admin Content Database: (PowerShell: Dismount-SPContentDatabase)

stsadm -o deletecontentdb -url http://centraladmin:2013 -databasename SharePoint_AdminContent_a149fa83-d2b9-4ad9-9e4c-ad12f73f0dd6 -databaseserver SP13_SQL

Step 2. Rename the Content Database from SQL Server
Right click the database, Choose Properties, Select Options tab. Set the Database restricted access property to to "Single User Mode". Rename the Database by removing GUID from it (Right click the database, choose "Rename"). Now, set the database restricted access back to "Multi-User".

Step 3.Attach the renamed Content Database
Attach the renamed content database back to Central Administration web application: (PowerShell: Mount-SPContentDatabase)

stsadm -o addcontentdb -url http://centraladmin:2013 -databasename SharePoint_AdminContent 

Alternate approach to rename SharePoint database:

Alternatively, You can create a create a new content database with right naming conventions, Move all sites from the existing content database to new database and then get-rid of the old database. Here is the script:
#Create new Content Database
New-SPContentDatabase -Name SharePoint_AdminContent -WebApplication http://centraladmin:2013
Now the Central Admin should have two databases attached with it.

Lets get the IDs of those two databases:
# Get SharePoint database IDs for old and new DBs for central admin site
Get-SPWebApplication –Identity http://centraladmin:2013 | Get-SPContentDatabase | SELECT ID, Name, WebApplication | Format-List

#Note down the IDs of Original Database and New Database.
# In my case, Old database id: c87506a9-b87d-40b8-9582-aac9ee89c8f8.
# New Database id: 8f35dc3b-56ab-45df-a1cf-459b60aa7454

Now, Lets move all sites from Old database to New Database:
# Move central admin sites to from old Database to new SharePoint content database
Get-SPSite –ContentDatabase c633c573-966d-4362-a1f8-430fba561f11 | Move-SPSite –DestinationDatabase 8f35dc3b-56ab-45df-a1cf-459b60aa7454

#You must do an IISReset!
# Now, You can Remove OLD SharePoint admin content database using Old database ID - actually deletes the database on the SQL Server.
Remove-SPContentDatabase -identity c633c573-966d-4362-a1f8-430fba561f11

How to Avoid GUIDs in SharePoint Databases:
Prevention is better than cure! Always use PowerShell to to avoid GUIDs in SharePoint Databases. Do not run Products configuration wizard right after installation. Use PowerShell to create the SharePoint farm and service applications.

How to Check SQL Server Connectivity from SharePoint

$
0
0
How do I quickly check SQL Server connectivity from SharePoint server? Well, you can use Telnet.
telnet {SQL-Server-Name or IP} 1433

If your SQL Server listens on different port, change the default port 1433 accordingly.

Using PowerShell to test SQL server connectivity:
Or you can use PowerShell to check if SharePoint it able to connect with SQL Server:
(New-Object System.Net.Sockets.TCPClient("SQL-Server-Name",1433)).Connected 

Create New Managed Account in SharePoint 2013 Using Powershell

$
0
0
Managed accounts are active directory accounts for SharePoint's whose credentials are managed by SharePoint. Managed accounts in SharePoint 2013 is explained in my another article: Configuring Managed Accounts in SharePoint 2013.
Important: Before creating a managed account, They must be already created in your Active directory.
To register new managed account in SharePoint 2013, here are the steps:
  1. Open Central administration.
  2. Go Security >> Click on Configure Managed Accounts.
  3. Click the Register Managed Account link to create a new managed account.
  4. Enter the account’s AD username in domain\username format. Specify the account's password.
  5. Optionally, You can enable the automatic password reset.
  6. Click "OK" to to create managed account in SharePoint 2013.
    create managed account sharepoint 2013 powershell
Important: To register managed account SharePoint 2013, You must be a member of Farm Administrators SharePoint group.

To create a managed account using PowerShell: use the New-SPManagedAccount cmdlet. Here is how:
$cred = Get-Credential
New-SPManagedAccount –Credential $cred
This prompts to enter credentials and register managed account in SharePoint 2010/2013.

Register new managed accounts SharePoint 2013 in Bulk:
Lets create multiple Managed accounts in SharePoint 2013 in bulk:
Add-PSSnapin microsoft.sharepoint.powershell -ea SilentlyContinue

#Define a common password for all service accounts
$password = "Password1"
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force

#List of Service accounts
$ServiceAccounts = "SP-Farm","SP_Services","SP_Search","SP_UserProfile"

ForEach ($Account in $ServiceAccounts)
{
#Get the account in Domain\UserName format
$userName = $env:USERDOMAIN + "\" + $Account
#Set the Credentials
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $securePassword
#Create Managed Account
New-SPManagedAccount -Credential $cred
}
Here, I've specified a common password for all managed account. However, you  can specify different passwords for different service accounts.

Troubleshooting: 

Whiletrying to add managed account in SharePoint 2010 or in SharePoint 2013, You may encounter the below issues:

SharePoint register managed account access denied: unable to register managed account 
You may get access denied error when you try to register a managed account via Central Administration, You'll get this error: >> Security >> Configure Managed Account >> Register Managed Account.
  • Make sure either you are running SharePoint Management shell as administrator or UAC is disabled prior executing PowerShell cmdlets. 
  • Verify that your service account is allowed to change password from its properties -  “User cannot change password” !
  • if "Automatic Password reset" property is already enabled for your managed account, you may get "Access denied" error! Remove that existing account and crate a new one.
  • Use PowerShell to register new managed account!
SharePoint managed account requested registry access is not allowed:
Fix: Your Central administration App pool Identity must be a Farm Admin account also a LOCAL Administrator account

The given key was not present in the dictionary when register managed account in SharePoint 2013
Fix - KB: http://support.microsoft.com/kb/2463865/en-us

How to Change Managed Account Password in SharePoint 2013

$
0
0
You may have to change your service account passwords for reasons such as: Password expiration, Security best practice, Your SharePoint guy left your company, etc. Remember those old days? You got to run stsadm -o updatefarmcredentials and update application pool accounts on every server in the farm?

Luckily, we got managed accounts feature starting from SharePoint 2010 onwards. The primary advantage of the managed accounts idea is: To centrally manage service accounts of SharePoint in one place, by registering and mapping them with  SharePoint Services such as: Farm, Service Applications, Application Pools, etc. So, whenever you need to change the service account's password, Update them once!

There are three different cases to change managed account passwords in SharePoint 2013 either from SharePoint Central Administration or using PowerShell.
  1.     Generating new password
  2.     Set account password to new value
  3.     Use existing password - This option lets us updating the account password in SharePoint, if it is changed in Active Directory(or somewhere!)
Change Managed Account Password in SharePoint 2013
Case 1: Change password of the Managed account to a new random password:
If you want the password to be changed to an automatically generated random password, Use the "Generate new password" option.

To reset managed account password SharePoint 2013 with PowerShell:
Set-SPManagedAccount –Identity domain\user -AutoGeneratePassword $true

Case 2: Change Password of the Managed account in SharePoint as well as in AD
If you want to change the service password to a specific value, select the option "Set account password to new value" and enter the new password.

You can change managed account passwords in SharePoint 2010/2013 using PowerShell as:
$ManagedAccount = Read-Host "Enter the Managed account in Domain\User Format:"

#$ManagedAccount = Get-SPManagedAccount -Identity “sharepoint\sa-spcontent”
#Get new Password for the managed account
$Password = Read-Host "Enter new password for managed account" –AsSecureString

#Change the password for the managed account
Set-SPManagedAccount -Identity $ManagedAccount -NewPassword $Password

When you try to change managed account password in SharePoint 2013k, You may get the error:
"Set-SPManagedAccount: The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements"
Apparently, the given password is not satisfying your AD domain's password policy. Just check with your AD admin to get the password policy insights.

Case 3: Update the password of the Managed Account, which is updated in AD:
If you / AD admin has already changed the service password in active directory, you have to update it in SharePoint. Select "Use existing password" option and then enter the password

To update managed account passwords in SharePoint  2013, using PowerShell:
$ManagedAccount = Read-Host "Enter the Managed account in Domain\User Format:"

#Get new Password for the managed account
$Password = Read-Host "Enter new password for managed account" –AsSecureString

#Change the password for the managed account
Set-SPManagedAccount -Identity $ManagedAccount -ExistingPassword $Password -UseExistingPassword $true
If you get access denied error on changing password of managed account in SharePoint 2013 or in SharePoint 2010, one possible reason could be: "User cannot change password" settings.
change managed account password sharepoint 2010


SharePoint 2013 Set Site Collection to Read Only

$
0
0
At times we may require to set site collections to read-only to prevent any add/edit/delete operations on the site's content. During a SharePoint migration we decided to set sites to read only to restrict any updates. How to set site collection to read only in SharePoint 2013?

Set SharePoint 2013 site collection to read using Central Administration:
Usually making SharePoint 2013 site collections to read only is done at SharePoint Central administration site.
  • Go to Central Administration >> Select Application Management  >> Configure quotas and locks
  • Choose the site collection you want to set on Read-only mode and select the option “Read-Only". Choose farm administrator controlled or site collection administrator controlled options accordingly.
  • Enter the lock information and click "Ok"
Fortunately, Unlike its previous versions, SharePoint 2013 displays a banner "This site is read only at the farm administrator's request" to notify end users - when site collections are in read-only mode!
sharepoint 2013 set site collection read only
Once sites are in read-only, you may notice certain controls on ribbons, menus are disabled. But site content can be accessed as usual.

Set Site Collection Read Only with PowerShell
We can make SharePoint site read only using PowerShell. Open SharePoint Management Shell. Enter following command:
Set-SPSite -Identity "Site-Collection-URL" -LockState "ReadOnly"

How to set all SharePoint sites to Read-only:
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

#Get all Site Collections
$SitesColl = Get-SPSite -limit All

#Loop through all site collections
ForEach($Site in $SitesColl)
{
Set-SPSite -Identity $site.Url -LockState "ReadOnly"
#You can also use: Set-SPSiteAdministration -LockState "ReadOnly" -Identity $Site.URL
}

Unlocking SharePoint 2013 read only site collections
To revert the Read only mode, Return to the SharePoint Central Administration's Site collection Quotas and Locks page and choose "Not locked".

We can unlock the site collection using PowerShell by entering the command:
Set-SPSite -Identity "Site-Collection-URL" -LockState "Unlock"

You can use STSADM also to set sharepoint 2013 site in read only mode
To make a SharePoint site read-only, Enter:
Stsadm -o SetSiteLock -url "Site-Collection-URL" -lock ReadOnly

To undo read-only, use:
Stsadm -o SetSiteLock -url "Site-Collection-URL" -lock none

Tips: If your site is read-only and you couldn't unlock it, your site may be in maintenance mode. Some times, SharePoint 2013 sites goes in read only mode after an interrupted backup. Try above methods to unlock. If they fail, You have to clear maintenance mode to revert read only: Maintenance Mode in SharePoint 2013

Its also possible to make sites to read only using SharePoint Server Object Model: SPSite.ReadOnly = true. Setting up sites to read-only can be done at SQL Server also at content database level.

SharePoint site locks are explained in my another article: Site Collection Locks in SharePoint

Configuring Managed Accounts in SharePoint 2013

$
0
0
What is Managed Account in SharePoint? Why We Need Managed Accounts?
SharePoint uses service accounts for operations such as Farm account, application pools and for service applications. You have to keep a track of all service accounts with their password in a secured file in your system. If the password for any one of those accounts has been changed, the service which uses that specific service account will stop functioning, until you manually update them in SharePoint.

So, The solution comes with SharePoint 2010 and 2013 is you can register your service accounts as a Managed accounts, and you don't have to keep-up the passwords once you register them in your farm and you can manage those managed accounts centrally from SharePoint central administration.

SharePoint centrally stores managed accounts and passwords and it can change the password regularly-automatically, if needed. If there is a password expiry policy set on Active Directory, Then SharePoint automatically detects and changes the password before the scheduled date. (If automatic password change is enabled!). SharePoint also provides Email notification options prior changing the passwords.
In short, Managed accounts are active directory accounts whose credentials are managed by SharePoint
Not all accounts needs to be a managed accounts. E.g. In Search Service Application: Default content access account, which is used to crawl content is usually an un-managed account. Because, when SharePoint changes the password automatically, the content source its crawling may not get that, if its not a SharePoint content source.

How to Create a New Managed Account in SharePoint 2010/2013:

Before creating a managed account, They must be already created in your Active directory and you should create Managed accounts before provisioning web applications and service accounts, as you'll be prompted to choose managed account while creating a web application or service application. To create a new managed account with Central Administration, follow these steps:
  1. Go to Central Administration, Click Security >> Click on Configure Managed Accounts.
  2. Click the Register Managed Account link to create a new managed account.
  3. Enter the Service account's AD user name in domain\username format. Specify the account's password.
  4. If you want SharePoint to automatically change this account’s password on a regular schedule, check the "Enable Automatic Password Change" check box and specify when to change password in accordance to the password expiry policy of your AD.
  5. Check the "Start Notifying By E-mail" check box and specify the number of days before the password change you want to be notified.
  6. Specify the schedule for your password change. You can change the password weekly or monthly.
    You should set changes to occur during scheduled downtime or during light usage, because the password changes will cause momentary service interruptions as application pools are restarted.
  7. Click OK to save the new managed account.
SharePoint sends password change notifications to a single email address, which can be configured via Under: Security >> Configure Password Change Settings >> Notification E-Mail Address.

Add managed account in SharePoint 2013 using PowerShell:
To create a managed account using PowerShell, use the New-SPManagedAccount cmdlet. Here is how to add new managed accounts in SharePoint 2013 using PowerShell:

Configuring Managed Accounts in SharePoint 2013
If you have created a new managed account or want to change the mapping of managed Accounts, Go to:
  • Central Administration >> Security 
  • Under the General Security section, click Configure service accounts. 
Get All Managed Accounts
To view existing Managed Accounts using SharePoint Central Administration:
  1. Select Security from the SharePoint Central Administration page.
  2. On the Security page select Configure managed accounts under General Security.
  3. The Managed Accounts page will list all Managed Accounts registered in SharePoint.
This page lists all of the managed accounts. The date and time for the next password change is shown if you enabled Automatic Password Change.

To view existing Managed Accounts using Windows PowerShell, open the SharePoint 2013 Management Shell and enter Get-SPManagedAccount cmdlet.

Edit a Managed Account
  1. To edit an existing managed account using Central Administration, follow these steps:
  2. Click Security and then select Configure Managed Accounts.
  3. The list of existing managed accounts is displayed. To make changes to the account, Click the edit icon for the managed account.
  4. Click OK to save your changes.
To edit a managed account using PowerShell, use the Set-SPManagedAccount cmdlet. Here is how to change managed accounts password using PowerShell: How to Change Managed Account Password in SharePoint 2013

Removing a Managed Account
Before removing a managed account, you should first make sure this managed account is not associated with any SharePoint services or application pools. To determine if it is in use, edit the managed account and look at the Account Information section to see what farm components are using this account.
Once you’ve confirmed the account is not in use, here is how you can use Central Administration to remove the account.
  1. Click Security and then select Configure Managed Accounts.
  2. Click the delete icon for the managed account you want to remove.
  3. In the Remove Managed Account page, confirm the correct account is selected and click OK.
To remove a managed account using PowerShell, use the Remove-SPManagedAccount cmdlet. E.g.
Remove-spmanagedaccount "Crescent\SP_Farm" 
The above cmdlet, Un-registers the account from SharePoint farm. But doesn't do any delete operation on AD!

Migrate SharePoint Users from One Domain To Another

$
0
0
Requirement:
During a acquisition, Our company decided to merge with an acquired company's AD by re-creating their user Ids in our AD. Also, the acquired company had a bunch SharePoint sites and we wanted to migrate them to our SharePoint environment.

That brought an another challenge of re-mapping user Ids with permission between domains. How do we migrate SharePoint users from one domain to another domain?

Solution: 
Well, In SharePoint 2007 days, I used STSADM to migrate users between domains:
Stsadm -o migrateuser -oldlogin domain\OldUserID -newlogin domain\NewUserID -ignoresidhistory 

Now with SharePoint 2013, Its replaced with the PowerShell cmdlet: Move-SPUser. So, rather moving users one by one, we prepared a CSV file, mapping users from one domain to new domain and used PowerShell script to migrate users in bulk.

Here is my CSV file structure:
sharepoint migrate users between domains

The csv file just maps old SAMAccountName with the new one.

PowerShell script to Migrate Users from one domain to another:
Add-PSSnapin Microsoft.SharePoint.PowerShell

#Import data from CSV file
$UserData = Import-CSV -path "C:\Accounts.csv"

#Iterate through each Row in the CSV
foreach ($Row in $UserData)
{
write-host "Processing user:" $row.Email

#Site collection URL
$siteURL ="https://intranet.crescent.com"
$site = Get-SPSite $siteURL

foreach($web in $site.AllWebs)
{
#Get All Users
$UserColl = Get-SPUser -web $web.Url

foreach ($User in $UserColl)
{
#Get values from CSV File
$OldUserID= $Row.OldUserID.Trim()
$NewUserID =$Row.NewUserID.Trim()
$Email = $Row.Email.Trim()

#Search for Old User Accounts
if($User.UserLogin.Contains($OldUserID))
{
#Update the User E-mail
Set-SPUser -Identity $User.UserLogin -Email $Email -Web $web.URL

$NewUser = $User.UserLogin.replace($OldUserID, $NewUserID)

#Migrate user from Old account to new account - migrate users to new domain
Move-SPUser -Identity $User -NewAlias $NewUser -IgnoreSID -confirm:$false
write-host "User Migrated: $($User.userlogin) at site $($web.Url)"
}

}
}
}
This PowerShell script migrates users to new domain programmatically. You have to use the same method when users leaves the company and rejoin - if their AD accounts are deleted and re-created.

Manage Access Request Settings in SharePoint 2013

$
0
0
Access request feature allows users to request access to sites and content. Access requests feature is improved in SharePoint 2013. Now, Administrators can keep a track of access requests.

Enable access request SharePoint 2013
Site owners can enable access requests in SharePoint. To configure access request settings in SharePoint 2013, navigate to: Go to
  • Settings >> Site Settings
  • Click the "Site permissions" link under "Users and permissions" section
  • Now, from the ribbon, Click on “Access Request Settings” button. You'll be prompted with the access request Settings popup window.
sharepoint 2013 allow access request
  • Click on "Allow access request" option to enable access request and enter the E-mail address of the user who will receive access requests from that site.
sharepoint 2013 access request email address
This allows access request in SharePoint 2013. You can change access request email or you may want to turn off access request at later point of time by visiting the same link. 

Manage access request SharePoint 2013:
Here is how the process works:
When users who doesn't has access to this site will get "Let us know why you need access to this site" page where they can enter their request and submit.
Once request sent, site collection administrators can approve reject this request by opening “Access requests and invitations” link in site settings page.

This page lists down all SharePoint 2013 access requests and invitations.
 
To approve or decline any requests, Just open the access request item, set the permissions for the user, and click on "Approve" or "Decline" button.


Once its approved/rejects, that entry removed from access request queue and moved to access request history.  SharePoint keeps track of the access requests and replies as a conversation under access request history.
sharepoint 2013 approve access request
Enable access request in SharePoint 2013 using PowerShell:
To allow access request in SharePoint 2013, on entire site collection, here is the PowerShell script.
Add-PSSnapin Microsoft.SharePoint.Powershell

#Set the site URL variable accordingly!
$SiteURL = "https://intranet.crescent.com"

$site = Get-SPSite $SiteURL

ForEach ($web in $site.AllWebs | where { $_.Permissions.Inherited -eq $false})
{
#sharepoint 2013 access request settings powershell
$web.RequestAccessEmail="Support@Crescent.com"
write-host Updated Access request settings for $web.Title, at: $web.URL
}
This script can be slightly changed and used for setting access request configuration for all sites in the entire web application.

Related Posts:

Create SharePoint Service Accounts in AD using PowerShell

$
0
0
I do a lot of SharePoint deployments now a days. I use PowerShell scripts to quickly create SharePoint service accounts instead of manually creating them in Active directory one by one. Run the below PowerShell script from domain controller (or from Remote Server Administration Tools installed workstation) to create service accounts in one-short.

Here is the list of Service accounts I use in my SharePoint 2013/SharePoint 2010 deployments:
  1. SP_Setup - SharePoint Setup account
  2. SP_Farm    - SharePoint Farm account
  3. SP_Pool    - The account is used to run the Web Application Pools
  4. SP_Services - The Services Account is used to run the Service Applications
  5. SP_Crawl - The Default Content Access Account for the Search Service Application
  6. SP_UserProfile - The User Profile Import and Synchronization Account
  7. SP_SuperUser - Cache account for Web application super User account
  8. SP_SuperReader - Cache account for Web application super reader account
  9. SQL_Admin - SQL Admin on the SQL Server. Used to Install the SQL Server.
  10. SQL_Services - Service account to run SQL Server services
Here is the PowerShell script to create SharePoint Service Accounts in Active directory:
Import-Module ActiveDirectory -ErrorAction SilentlyContinue

#Set configurations
$AccountPassword = "Password1"
#Convert to Secure string
$Password = ConvertTo-SecureString -AsPlainText $AccountPassword -Force

$Domain = "YourDomain.com"
#Specify the OU
$AccountPath= "ou=SharePoint,DC=YourDomain,DC=com"

#Create SharePoint Accounts
$Account="SP_Setup"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description="Account Used to install SharePoint"}

$Account="SP_Farm"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description="SharePoint Farm Account."}

$Account="SP_Pool"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description="SharePoint Web Application Pools Account"}

$Account="SP_Services"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description="Account to run the Service Applications"}

$Account="SP_Crawl"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description="Content Access Account for the Search Service Application"}

$Account="SP_UserProfile"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description="User Profile Import and Synchronization Account"}

$Account="SP_SuperUser"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description="Web application super User account"}

$Account="SP_SuperReader"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description=" Web application super reader account"}

$Account="SQL_Admin"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description="SQL Server Admin Account"}

$Account="SQL_Services"
New-ADUser -SamAccountName $Account -name $Account -UserPrincipalName $Account@$domain -Accountpassword $Password -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description="Account to run SQL Server services"}
Here I'm directly specifying accounts in the PowerShell script. However, You can also use CSV files to import list of service accounts and create them in bulk in active directory.

Create SharePoint Service Accounts from CSV
Here is my CSV file with accounts, passwords and descriptions filled:

PowerShell script to Create AD accounts from CSV:
Import-Module ActiveDirectory -ErrorAction SilentlyContinue

#Set configurations
$Domain = "YourDomain.com"
#Specify the OU
$AccountPath= "ou=SharePoint,DC=YourDomain,DC=com"

# Import the CSV File
$ServiceAccounts = Import-Csv D:\SharePoint\ServiceAccounts.csv

Foreach ($ServiceAccount in $ServiceAccounts)
{
write-host "Creating Account:"$ServiceAccount.Account
write-host "Creating Account:"$ServiceAccount.password

#Convert to password to Secure string
$AccountPassword = ConvertTo-SecureString -AsPlainText $ServiceAccount.Password -Force

$UPN = "$($ServiceAccount.Account)@$($domain)"

#Create SharePoint Service Accounts from CSV
New-ADUser -SamAccountName $ServiceAccount.Account -name $ServiceAccount.Account -UserPrincipalName $UPN -Accountpassword $AccountPassword -Enabled $true -PasswordNeverExpires $true -path $AccountPath -OtherAttributes @{Description=$ServiceAccount.Description}
}
Viewing all 1058 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>