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()
}
}
Comments