Tag Info

Hot answers tagged

3

Retrieving Office 365 users and SharePoint users are slightly different things. With the CSOM method you describe, you will only be able to get SharePoint users who have accessed that site, or who have been explicitly added to groups on it etc. If you want to get all of the Office 365 users in your tenancy, you need to use the Office 365 management cmdlets ...


3

Nate, try the following code $web = Get-SPWeb "http://webAddress" $folderPath = "folderPath" $relativeUrl = $web.ServerRelativeUrl $folder = $web.GetFolder($relativeUrl+$folderPath) if ($folder.Exists) { Write.Host("Folder exists"); } else { Write.Host("Folder does not exists"); } Let me know if you have any questions.


3

The simplest way to check existence of a folder is the following (code not tested, may contain syntax errors, but the idea is clear): $web = Get-SPWeb "<Sub-site absolute URL>" $folder = $web.GetFolder("<absolute, or server-relative URL of the folder>") $folder.Exists


3

Here you go: $spWeb = Get-SPWeb -Identity http://<sitecollection>/<subsite> $lList=$spWeb.Lists["<ListName>"] $spItems = $lList.GetItems() foreach($spItem in $spItems) { $spItem["Date"] = $spItem["Created"].AddYears(2) $spItem.Update() }


2

You should use microsoft.SharePoint.Client.RoleDefinitionBindingCollection instead of Microsoft.SharePoint.Client.RoleAssignment. Try below snippet (Not tested but will give you idea of what all steps are required): # Get the list by Title and load. $web = $ctx.Web $list = $web.Lists.GetByTitle("Quiz") $ctx.Load($list) # Load in list of groups on the ...


2

Try to use Owner instead of owneralias, and SecondaryContact instead of secondaryowneralias.


2

The method SPFieldCollection.Add (String, SPFieldType, Boolean, Boolean, StringCollection) has only five arguments. Whereas, in your code you are passing 6 parameters. Try changing the code to this: $newSiteColumn = $web.Fields.Add($name,[Microsoft.SharePoint.SPFieldType]::Choice, $false,$false, $stringColl) Source: ...


2

_UIVersionString “1” = version “0.1” _UIVersionString “2” = version “0.2” _UIVersionString “3” = version “0.3” _UIVersionString “512” = version “1.0” _UIVersionString “1024” = version “2.0” _UIVersionString “1025” = version “2.1” Example : If page version is 5.4 Then it will show 2564 5 * 512 + 4 = 2564 We call this a "base-512" counting system in ...


2

Try: $item.BreakRoleInheritance($false,$false) You will have to specify the first parameter as False, which means all the permissions from the parent will not be copied over. See the documentation for BreakRoleInheritance .


1

There are two things you should change in your script: You are using $file.Properties which are not exactly SPListItem metadata. You should use $file.Item["fieldname"] = ... To change document metadata. As it seems you are trying to set a taxonomy field that is not so straightforward. You should look,at this blog post on how to set taxonomy field using ...


1

Yes, that seems like a perfectly reasonable solution. The documentation for SPField.Update(boolean) even calls the boolean parameter pushChangesToLists. So if you pass $false, it should not update the lists, only the site column. So, you could potentially do something like: $web = Get-SPWeb http://vstg01 $field = $web.Fields["Customer Initials"] ...


1

this error occurred due to couple of reason. when you are trying to create managed property with the same name which already exist. Or you dont have peroper permission on SharePoint Search service and DBs. Further you should check the logs during the period and see if their is any access denied or other errors.


1

I would avoid the use of user profile subtypes and organizations. Neither was fully implemented and the support for subtypes is weak.


1

SharePoint CSOM request size is very limited and it cannot excess 2 MB limit and you cannot change this setting in Office 365 environment. So if you have to upload bigger files you have to use REST API. Here is MSDN reference https://msdn.microsoft.com/en-us/library/office/dn292553.aspx


1

$site = get-spsite http://www.url.com/sites/sitecollection $site.Recyclebin | where {$_.itemtype -eq "web"} This get's all the sub-sites in a site collections recycle bin. Powershell for working with SharePoint Recycle Bin


1

It would be difficult to know the exact cause of your error without actually seeing some code or error message. One of the common reasons could be that you arent using the REST api and hence are only allowed a limited file size to upload. The article here explains how to upload using REST with Powershell. Also check out this SO question previously answered. ...


1

You need to Download SharePoint Online Management Shell and SharePoint Online Client Components SDK in order to work with SharePoint Online using PowerShell. Then you can write PowerShell code and execute it in SharePoint Online Management Shell. Following sample code creates a list (Document Library) in SharePoint online. #Import the required DLL ...


1

The following will iterate all files in the root of your style library. Add-PSSnapIn Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue cls $web = Get-SPWeb "https://mydms.prod.com/sites/dmsHome/" $stylelib = $web.lists["Style Library"] write-host "Title:"$stylelib.title foreach ($file in $stylelib.RootFolder.Files) { Write-Host "inside ...


1

You create the object muser, but never initialize it. So, your comparison is always false. I would suggest inspecting the Groups property of the SPUser object. (The following is not tested since I don't have an environment handy.) $site = get-spite "{siteUrl}" $web = $site.RootWeb $user = $web.AllUsers["{domain\\user_alias}"] Foreach($group in ...


1

you can use piping to iterate through all results e.g. param( $webUrl = "http://yoursite", $groupTitle = "your group" ) clear-host function Send-Mail($to){ write-host "Sending email to $to..." $smtp = "SMTP server addresss" $from = "sharepoint@company.com" $subject = "This is a Test of HTML Email" $body = "Dear Users" ...


1

I am not 100% sure what you are asking but just incase I am right This script will return a list of all sites, the groups and the permissions the groups have. Add-PSSnapin Microsoft.SharePoint.PowerShell $sites = get-spsite | get-spweb foreach($site in $sites) { write-host $site.URL -ForegroundColor Green $site.associatedgroups | select name, roles ...


1

i found 1 way $site = new-object Microsoft.SharePoint.SPSite("http://server/") $web = $site.OpenWeb("/") $resultsPath = "Paginas/default.aspx" $page = $web.GetFile($resultsPath) $page.CheckOut() $wpm = $web.GetLimitedWebPartManager($resultsPath, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared) $wpm.WebParts | ft Title, StorageKey ...


1

Here is the script. It will get you primary administrators in an excel file for each site collection inside a web application. I am not able to get Secondary Owner Property though. $WebApplicationUrl = "https://peopletest.brookfield.com" $outputFile1 = "C:\TEMP\siteCollectionAdminsPrimary.csv" $outputFile2 = "C:\TEMP\siteCollectionAdminsSecondary.csv" ...


1

simple: Get-SpWebApplication http://www.contoso.com | Get-SPSite -Limit All | Select URL, ID, contentdatabase,Owner, SecondaryOwner | Export-CSV "f:\VLESites.csv" -NoTypeInformation


1

Using csom PowerShell you can try below function to give a group your desired permissions it uses Microsoft.SharePoint.Client.RoleDefinitionBindingCollection and Microsoft.SharePoint.Client.RoleType to get role types. function Set-PermissionsOnList() { param( [Parameter(Mandatory=$true)][string]$url, ...


1

For SharePoint Online refer to: https://technet.microsoft.com/en-us/library/fp161387.aspx Set-SPOSiteGroup -Site http://contoso.sharepoint.com/sites/siteA -Identity "ProjectViewers" -PermissionLevelsToRemove "Full Control" -PermissionLevelsToAdd "View Only" Example 1 changes permission level of the ProjectViewers group inside site collection ...



Only top voted, non community-wiki answers of a minimum length are eligible