SharePoint Create Document Library Using PowerShell
cls
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell
# varable description
$webUrl = "http://sp2010:8080/personal/Test1/"
$web = Get-SPWeb $webUrl
$libraryName = "My Document Library"
$libraryDescription = "Storage for Personal Documents"
$libraryTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary;
# Adding Library
try
{
$web.Lists.Add($libraryName,$libraryDescription,$libraryTemplate);
$web.Update();
}
catch
{
write-host "Error" $_.exception
$errorlabel = $true
}
finally
{
if($web -ne $null)
{
$web.Dispose()
}
}
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell
# varable description
$webUrl = "http://sp2010:8080/personal/Test1/"
$web = Get-SPWeb $webUrl
$libraryName = "My Document Library"
$libraryDescription = "Storage for Personal Documents"
$libraryTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary;
# Adding Library
try
{
$web.Lists.Add($libraryName,$libraryDescription,$libraryTemplate);
$web.Update();
}
catch
{
write-host "Error" $_.exception
$errorlabel = $true
}
finally
{
if($web -ne $null)
{
$web.Dispose()
}
}
Wonderful article! This is the type of information that should
ReplyDeletebe shared around the internet. Disgrace on the seek engines
for now not positioning this publish higher! Come on over and consult with my
website . Thanks =)
Also visit my webpage - raspatory