Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Friday, June 16, 2017

PowerShell to Add Data Row-wise to CSV File

Execute following script to insert data in new or existing CSV file.

$FilePath = "D:\Data\FileName,csv"
#Add Title Row
$Row = "Full Name,Age,Gender"
Add-Content ($Row) -Path $FilePath

#Add Data Row
$Name = "Prashant"
$Age = "29"
$Gender = "Male"
$Row = $Name + "," + $Age + "," + $Gender
Add-Content ($Row) -Path $FilePath

Create New Content Database Using SharePoint PowerShell

Execute following script to create new content database using SharePoint PowerShell. You can run this script on any WFE or APP server.

add-pssnapin Microsoft.SharePoint.PowerShell

#Set following parameters
$WebsiteName = "Test Site"
$DbServer = "SQLServer"
$WebAppUrl = "http://webapplink"
$DBName = "WSS_Content_" + $WebsiteName
$MaxSiteCount = 1 

$WarningSiteCount = 0

#Create new content database
New-SPContentDatabase -Name $DBName -DatabaseServer $DbServer -WebApplication $WebAppUrl -MaxSiteCount $MaxSiteCount -WarningSiteCount $WarningSiteCount -ErrorAction Stop