New answers tagged

0

Yes, this is one of my favorites. It's SharePoint's punishment for lazy programming ;) Try this code: $list.Views[0] -eq $list.Views[0] This results in False. That's because $list.Views[0] always returns new instance. Same as $web.Lists['Title'] and few more examples. Solution: $view = $list.Views[0] $view.Title = 'New Title' $view.Update()


0

I ended up doing this: $site = Get-SPSite "http://nameofsite/sites/subsite" $filePath = "E:\lists.txt" $array = "array of site column names" $column = $site.RootWeb.AvailableFields[$element] $lists = $column.ListsFieldUsedIn() $column.ListsFieldUsedIn() | ForEach-Object { $w = $site.AllWebs[$_.WebID] $l = $w.Lists[$_.ListID] "Web:" +$w.Title+ " ...


0

So I never got formally introduced to sharepoint, but the error seems trivial to me. [Microsoft.SharePoint.SPFile]$spFile = $folder.Files.Add($folder.URL + "/" + $File.Name, [System.IO.Stream]$fileStream, $true) $spSite = Get-SPSite -Identity $siteURL $taxonomySession = Get-SPTaxonomySession -Site $siteURL My two changes were [Microsoft.SharePoint....


0

You need to get the activated features by the AdministrationService Powershell : [Microsoft.SharePoint.Administration.SPWebService]::AdministrationService.Features C# : Microsoft.SharePoint.Administration.SPWebService.AdministrationService.Features


0

this MS developer blog by Joe Rodgers helped us with: Get-SPWeb http://sharepoint2010/subsite | % { $results = @() Get-SPFeature -Web $_ -Limit All | % { $feature = $_; $featuresDefn = (Get-SPFarm).FeatureDefinitions[$_.ID]; $cc = [System.Globalization.CultureInfo]::CurrentCulture; $obj = New-Object PSObject; ...


0

As per msdn The Get-SPFeature cmdlet behaves differently at each scope, returning the enabled Features at each level. If no scope is provided, all installed Features are returned That means below command will return only active list of features Get-SPFeature -Farm Here is another snippet that gives the same result $siteFeatures = Get-SPFeature | ...


0

@GMasucci, I needed GetFolderByServerRelativeUrl function to retrieve folders folders. function Recurse ($folder){ $context.Load($folder) $context.ExecuteQuery() write-host $folder.Name $rootURL="https://SPOnlineSite.sharepoint.com"+$folder.ServerRelativeUrl $f = $web.GetFolderByServerRelativeUrl($rootURL) $context.Load($f) $...


0

Try the below steps to configure it. Install Windows PowerShell 3.0 from Windows Management Framework 3.0. Install the SharePoint Online Management Shell from the Microsoft Download Center. Click Start>All Programs>SharePoint Online Management Shell. Run Connect-SPOService. For example, Connect-SPOService -Url https://contoso-admin.sharepoint.com -...


0

That snap-in is for on-prem. You should be using the Client OM as mentioned here


0

Usually, SharePoint adds "domainusers" or "Everyone" to the "Moss-root visitors"-group. Please check if this is the case in your environment. Removing this domainusers-group will remove all read permissions on moss-root for everyone. Only users that have been granted permission through another way will be able to access moss-root. In case you need a group ...


3

Select database by type, and ask for the server. Like this: $ConfigDB = Get-SPDatabase | Where-Object{$_.Type -eq "Configuration Database"} $ConfigDB.server


2

Assuming a setup close to the defaults (and that you already loaded the SharePoint snapin via asnp *sh*), I would try this: $server = (Get-SPDatabase | ?{$_.name -like "SharePoint_Config"})[0].Server $server


0

If account is registered in managed account then try this for search service application $MgtAccount = Get-SpManagedAccount -Identity "Domain\ManagedAccountusername" $procId = (Get-SPEnterpriseSearchService).get_ProcessIdentity() $procId.CurrentIdentityType = "SpecificUser" $procId.ManagedAccount = $MgtAccount $procId.Update() http://tharindupg.blogspot....


0

Try modifying your code as below $svc = Get-SPServiceInstance -Server DEVSP01 | where {$_.TypeName -eq "Search Service Application"} Set-ServiceIdentity $svc "Domain\ManagedAccountusername" function Set-ServiceIdentity($svc, $username) { $pi = $svc.Service.ProcessIdentity if ($pi.Username-ne $username) { $pi.Username= $username ...


2

One of my favorite ways to automate repetitive tasks is to use PowerShell + CSOM. The Client Object Model allows me to run my scripts on top of on-prem SharePoint or Office 365 using the exact same code, so I don't have to migrate it in order to make it run in one or the other. Here is an example of how you use the client dll in a PowerShell script to ...


0

If you are sure of your list name, you should probably avoid enumerating manually all the available lists and just accessing the target list directly. foreach ($SPweb in $spSite.allwebs) { Write-Host "Checking " $spWeb.Title " for duplicate documents" $list = $spWeb.Lists.TryGetList("Your List Display Name") if(($list) -and ($list.BaseType -eq "...


0

At this foreach specifically at if condition foreach ($list in $spWeb.Lists) { if($list.BaseType -eq "DocumentLibrary" -and $list.Title -eq "Test" add this $list.Title -eq "Test" The full code should be like this foreach ($list in $spWeb.Lists) { if($list.BaseType -eq "DocumentLibrary" -and $list.RootFolder.Url -notlike "_*" -and $list....


0

You have to add the following snippet at the top of your code: Param( [Parameter(Mandatory=$True, Position=1)] [string]$sitename , [Parameter(Mandatory=$True, Position=2)] [string]$contentType ) Be careful, nothing should be addbefore this, except comments. The snippet allows the script to get input parameters entered by the user. You can ...


1

The solution below is not optimal but easy to use: Download and install the SPOMOD Run Connect-SPOCSOM Run: $files=(Get-SPOListItems alib -IncludeAllProperties $true -Recursive) foreach($file in $files){ foreach ($file2 in $files){ if ($file.FileLeafRef -eq $file2.FileLeafRef -and $file.ID -ne $file2.ID) {$file.FileRef}}} alib is the name of your ...


1

You will have to query the library using caml query, and specifically use <FieldRef Name='FsObjType'/><Value Type='Text'>0</Value> in the query set the ViewAttributes of the query object to 'RecursiveAll'. Then you can use the item collection to check for duplicates. And this can be done using powershell just Google it.


4

Just add this before your code in the .ps1 file: #Load SharePoint PowerShell SnapIn if ( (Get-PSSnapin -Name Microsoft.Sharepoint.Powershell -ErrorAction SilentlyContinue) -eq $null ) { Add-PsSnapin Microsoft.Sharepoint.Powershell } This will load the required Snapin. Then all the SharePoint commands should work. If you want to stop a running ...


0

It could be something like this $webUrl = "http://sp2013-sp/Test" $rootFolderUrl = "Shared%20Documents" $destinationfolder= "c:/test" function BuildPrefix($folderName, $previousPrefix) { return $previousPrefix + "abc" + $folderName + "_" } function isHidden($folder) { $attribs = $folder.Properties["vti_winfileattribs"] if ($attribs -eq $null) { ...


0

This script uses PowerShell to copy all files and folders from one document library to another document library. This script will allow you to copy an entire document library, along with user-defined metadata from one site collection to another. $ver = $host | select version if($Ver.version.major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"} if(!(...


1

try this one go to the IIS Manager, Click on the Server and in the feautre pane select the configuration Editor On this page from drop down Exapand System.WebServer and Click on the StaticContent Now on in Action Tab(right hand side) Make Sure it say Lock Section if not then unlock it. Do this on all Servers and reset IIS. This link is basically go ...


2

I have modified the script from this URL to adjust with your requirements ######################## Start Variables ######################## ######################## Varun's Script###################### $destination = "C:\\tools\\Folder" $webUrl = "<Url of the specific site>" $listUrl = "<Url of the specific list. This url is complete Url and NOT ...


1

The All Versions command, doesn't mean versions of the list, but means it exports all versions of all list items. When the list is then imported, the entire version history of the list items is present instead of the most recent version.


0

According to the options present in the command line the import may not work. So, add or remove options untill it works: Import-SPWeb https://test.mywebsite.com/another_site/test -Path "export.cmp" Import-SPWeb https://test.mywebsite.com/another_site/test -Path "export.cmp" -Force Import-SPWeb https://test.mywebsite.com/another_site/test -Path "export.cmp" -...


0

$site = Get-SPSite http://iddddp:100/ foreach ($web in $site.AllWebs) { $web.MasterUrl = $site.RootWeb.ServerRelativeUrl + "_catalogs/masterpage/seattle.master"; $web.CustomMasterUrl = $site.RootWeb.ServerRelativeUrl + "_catalogs/masterpage/HMC_Master_IN.master"; $web.Update(); Write-Host $web.Url $web.MasterUrl $web.CustomMasterUrl;}


0

When developing custom sharepoint timer jobs sometimes you want to delete junk jobs created by deployment attempts . Warning !!! DO NOT DELETE ANY TIMER JOB UNLESS BE SURE Searching listing and find timer job to delete.We need an id. Get-SPTimerJob | where { $_.name -like “*<your search criteria>*” } |ft id,name Set job to a variable $job = Get-...


0

$jobToDelete = Get-SPTimerJob | ? { $_.name -eq "sitename" } $jobToDelete.Delete() sitename=Name of your site Also you can create filters for getting specific Timer jobs Example $jobToDelete = Get-SPTimerJob –WebApplication “http://test.intranet.local” | Where-Object {$_.name –like “*health*” } $jobToDelete.Delete() Delete Timer Jobs


0

Ok so in basic terms. you are not able to retrieve with the ID, so what I have done is to lock down the URL so that the users cannot change it with a bit of j-query (not with permissions). So now I can safely take the original title from sharepoint and use it to build the url, I can now get the URL.


-1

I had the same issue and was able to resolve it using JavaScript (actually, it's a workaround). It won't set the flag itself to true but will 'emulate' it. Here is a copy-paste-able code. If you want some explanations, please use the link: InplaceSearchEnabled doesn't work when set programmatically in XsltListViewWebPart /// we need to wait until ...


0

if you're using a single master page and publishing feature (I'm assuming here), just go into site collection settings, master page (Look and Feel) and select the checkbox for "Reset all subsites to inherit this site master page setting". Edit: To modify your master page and add the site title within your aspx, please go to this other thread


1

Just skip the -Url parameter Enable-SPFeature -Identity <feature_name_or_Guid> -confirm:$false More found on TechNet


0

After a complete investigation together with a colleague, I have found the issue which causes this error. In our powershell script for provisioning the site collection was a function which adds a javascript to the page header. This js File was only needed to overwrite the "Create new subsite" and caused the error in the calendar lists. After modifiing the js ...


0

If you just want to find WHERE this group has permissions at SITE COLLECTION level, but not WHAT permissions and NOT subsites, then use SharePoint Online Management Shell and: Get-SPOUser -Site e.g. $sites=(get-SPOSite).Url foreach($site in $sites){ foreach($user in (get-spouser -site $site)){ if($user.DisplayName -eq "SPGroup") {write-host $site}}}


1

Modify your script like so, and you're good to go: param([string]$workspaceUrl) [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges( { $site = SPSite($workspaceUrl) $web = $site.RootWeb $spList = $web.Lists["ListName"] $spFieldType = [Microsoft.SharePoint.SPFieldType]::Note $newFieldName = $spList.Fields.Add("YourColumn", $...


0

If this is for SharePoint Online, then the easiest and only CSOM-free way would be foreach($site in $sites){set-spouser -Site $site -LoginName user@domain.com -IsSiteCollectionAdmin $true} Admin is not the same as Full Control, but does not require CSOM. If this is SharePoint on prem, then use this: $csv=import-csv C:\Users\Administrator\Desktop\stack....


1

Try this one: get-spwebapplication -IncludeCentralAdministration | where {$_.isAdministrationWebApplication} | select *outbound* You will see several properties, including OutboundMailReplyToAddress, OutboundMailSenderAddress and OutboundMailSenderAddress. OutboundMailSenderAddress is the 'From Address' OutboundMailSenderAddress should be the character ...


0

If you are using CSOM (which it looks like) then if you change subfolders for folders, you should get an iteration of all the folders starting at the one you pass into the function all the way to its furthest leaf.. Below is a small example of a recursive folder function: function global:RecurseFolders([Microsoft.SharePoint.Client.Folder] $folderObject, $...


0

One of the things wrong with your script is: if($ll.Title -eq $ctName) That means you are checking if the list title is the same as the name of a content type. I don't think that's what you want to check. You can also try using this script from Technet Gallery (aren't you using it already, just forgot to mention the source?) or Remove-SPOContentType ...


0

Your code returns result in ClientResult format. Use [System.IO.Stream($file.OPenBinaryStream().Value) May it helps you.


0

Easy! Foreach($item in $spSourceList) That's all because of in an $item you got list but not an item :) try foreach ($item in $sourcelist.Items) The method in second post wont work with 2013 workflows only 2010!


0

By running the script in windows powershell in administrator mode will execute without errors. Interestingly SP Management Shell runs the script successfully and also fails in random cases, but when you run the same script using windows powershell, execution succeeds in all runs.


0

First, confirm that the field is actually among the list item's fields. $sourceItem.Fields | select InternalName, StaticName | sort StaticName | ft -AutoSize There's a possibility that the field, though attached to the list, has not been added to the content type of the list item. Second, when using bracket notation to access an item's fields, you can ...


1

May be users can only edit their own items. There is a setting somewhere ( see for example here: http://stackoverflow.com/questions/26510951/sharepoint-2013-list-users-only-view-their-own-items )


1

Here's something that might (partly) help you on the way. Partly because it only works for pages in the pages libraries across your farm. [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing") | out-null Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | %...


0

Yes ,you can move list item attachments to document library. However, each attachment will be stored as a separate item in document library. If you are trying to group this into a single entity , then consider using document sets where you can group the attachments to a single entity.


2

This should allow you to search within content pages for a specific string, such as a given URL. param( $webUrl = "http://dev:8081", $urlToFind = "mylink.domain.com/" ) clear-host $web = get-spweb $webUrl $list = $web.Lists["Pages"] foreach($item in $list.Items) { write-host "" write-host "*** PAGE *** "$item.Url write-host "" $...


1

BreakRoleInheritance has two params. Just use false and true for copyroleassignments and clearsubscopes respectively then add the groups you want: $list.BreakRoleInheritance($false,$true) $group = $ctx.Web.EnsureUser($group) $roleDef = $web.RoleDefinitions.GetByName($role) $ctx.Load($group) $ctx.Load($roleDef) $roleBinding = New-Object Microsoft.SharePoint....



Top 50 recent answers are included