In PowerShell CSOM for SharePoint 2013 site, How to check if "Variation Labels" list is exists or not?
-
what is variation list? if you setup variations, so where they are saved? have you any screenshot of this list?Zdeněk Vinduška– Zdeněk Vinduška2019-02-26 10:27:59 +00:00Commented Feb 26, 2019 at 10:27
-
i want script to check for any list whether that exists or not. not specific to "variation labels" list only.Adarsh Awasthi– Adarsh Awasthi2019-02-26 11:32:23 +00:00Commented Feb 26, 2019 at 11:32
-
@ZdeněkVinduška i meant to say "varation Labels" list.Adarsh Awasthi– Adarsh Awasthi2019-02-26 12:43:14 +00:00Commented Feb 26, 2019 at 12:43
Add a comment
|
1 Answer
The following PowerShell with CSOM for your reference.
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$siteURL = "http://sp2013/sites/team"
$username="admin"
$password="xx"
$domain="contoso"
$creds = New-Object System.Net.NetworkCredential($username, $password, $domain);
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$ctx.credentials = $creds
try{
$rootWeb = $ctx.Site.RootWeb
$varLabelsList = $rootWeb.Lists.GetByTitle("Variation Labels")
$ctx.Load($varLabelsList)
$ctx.ExecuteQuery()
write-host "The Variation Labels list exists." -foregroundcolor green
}
catch{
write-host "The Variation Labels list not exists." -foregroundcolor red
}