Tag Info

New answers tagged

0

Below script accepts the array of the sub sites name, But you can amend it instead of passing the SubSIte name arrays just add test(i)...i mean in the for loop instead of checking the array's count, check fix the number of subsite($i <100000)...then susbite url will be like this $SiteUrl = $SiteCollectionURL + "/test" +$i . Copy and Paste the code ...


0

The basic syntax for creating site would be New-SPSite -Url $WebSiteUrl -OwnerAlias $SiteOwner -Name "Store" -Template $webTemplate and creating subsite `New-SPWeb -Url $WebSiteUrl -OwnerAlias $SiteOwner -Name "Store" -Template $webTemplate. Now for your requirement I think you have to use some kind of loop and call the above syntax for that many times. ...


0

Put The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. "/" is used to create the complete URL for the File location. i.e.library path is ...


0

Actualy you can do somethinf like this: $field = $list.Fields["Test"] $xmlSource = $field.SchemaXml $xmlData = [System.Xml.Linq.XElement]::Parse($xmlSource) $choicesParent=$xmlData.Element("CHOICES") $allchoices=$choicesParent.Elements("CHOICE") $allchoices = $allchoices|Sort-Object -Property Value $choicesParent.RemoveAll() ...


0

There is no direct way to do this neither in powershell nor in C# code.Ideally you should sort values while displaying . Create a temporary array, add all the choice fields, sort it and remove previous values in SharePoint and again add the new values :-P


0

I made a mistake. The error happens in the while loop. Apparently $nodes.Count never changes, so the while loop runs until $nodes[0] is null and $nodes[0].Delete() throws the error. I changed the while condition to catch it. $nodes = $subWeb.Navigation.QuickLaunch write-host $nodes.Count while($nodes.Count -gt 0 -and $nodes[0] -ne $null) { ...


0

I think after deleting the last node, QuickLaunch (SPNavigationNodeCollection) is not exists anymore as no child items exists in the database. That why $nodes is null in your example.


1

Here's a question which is similar to yours and already answered: You can replace the Date beeing compared with this: $DateToCompare = (Get-date).AddDays(-90) powershell to delete items from a list where created date < "1/1/2011"


0

This technet article has a great script for managing themes across site collections. This is complete PowerShell snippet which you can use to deploy and apply theme to your environment. I have not tested it for ‘My Sites’ but it should work practically. Script: Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue; ...


2

Double quoted string expand variables and single quoted strings do not. Use like this: $query = "<query> <where> <eq> <FieldRef Name="ID" <Value Type="Number">$IDNum</value> </eq> </where> </query>" http://blogs.msdn.com/b/powershell/archive/2006/07/15/variable-expansion-in-strings-and-herestrings.aspx


1

You can clone the site collection( i am sure you are going to use Backup & restore Method). What i see in terms of disadvantage, you have to perform the cleanup on the new site collection as Security / permissions Event reciever & Workflows in the list Alerts on List Search, If both sites crawled and having the same content will cause the ...


0

If your site(s) remain slow, you might want to check out this article about Microsoft clr... http://blogs.msdn.com/b/sofocle/archive/2012/07/24/sharepoint-still-slow-to-open-first-page-could-be-a-problem-with-microsoft-clr.aspx When you run the script as a scheduled task, it probably runs under different user credential, this is why you don't see anything. ...


0

Here is the complete working script. $siteURL = "URL" $site = new-object Microsoft.SharePoint.SPSite ( $siteURL ) $web = $site.OpenWeb() $oList = $web.Lists["ListName"]; $collListItems = $oList.Items; $count = $collListItems.Count -1; for($intIndex = $count; $intIndex -ge 0; $intIndex--) { $collListItems[$intIndex].Delete(); }


1

The registry determines the level of PS compatibility, in my case the value was 3.0, it should be 1.0. I corrected this value by editing the following key: HKLM\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.SharePoint.PowerShell\PowerShellVersion The initial cause of the problem was the installation of the Windows Management Framework 3.0 ...


1

You have to break the permission of the list, create a new role and assing it the to group. Then assign the role to the list. $list.BreakRoleInheritance($True) $group = $web.SiteGroups[$GroupName] $roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group) $roleDefinition = $web.RoleDefinitions[$PermissionLevel]; ...


0

You can get site collection admins from powershell as: foreach($siteAdmin in $site.RootWeb.SiteAdministrators) http://gallery.technet.microsoft.com/office/PowerShell-Script-for-aeba93d8 http://sharepointhangout.com/powershell-script-to-display-site-collection-administratorsprimary-secondary/


0

The problem is in $workflow | where {$_.InternalState -ne "Completed"} You are trying to enumerate through $workflow object, wich is not the collection. So as Lance said the good way is to filter workflows: $badWorkflows = $item.Workflows | Where-Object {($_.InternalState -eq "Running") -and ($_.Created.ToLocalTime().AddHours(4) -lt (Get-Date))} or ...


0

It will get all the workflows because you are looping through $item.Workflows without filtering. Also, I think there might be something wrong with your if logic. You have a $workflow in the context of the loop but then you pipe it to Where. There might be a reason you did it that way but I don't get it. Perhaps try this in place of the inner loop and if: # ...


0

that's how i did, i just did for farm admin group you have to modify for others as well.: Declare this on top $results = @() $fileLocation = "C:\user.csv then in your Check before out-put csv if($user.LoginName -eq $SearchUser){ $output = New-Object PSObject $output | Add-Member NoteProperty -name Url -Value $AdminWebApp.URL $output | Add-Member ...


0

To copy a site collection in SP 2010 follow the instruction below. If want to copy within same Web Application take the backup of existing site collection Create a new Content Database(otherwise will get error) restore the site collection with different name. If going to different Web app then no need of new content Database. Simply do the backup and ...


1

Copy-SPSite wasn't supported in 2010, it only applies to 2013. http://technet.microsoft.com/en-us/library/fp161280(v=office.15).aspx


1

In this scenario you can actually use the -force attribute on Enable-SPFeature, since it will reenable the feature. But I normally uses your approach, but I use the ID of the feature and not the actual $Feature object: $FeatureId = $Feature.Id Disable-SPFeature $FeatureId -URL $oneweb.URL -Confirm:$False Enable-SPFeature -$FeatureId -URL $oneweb.URL ...


2

Try to use [Double]::Parse("xxx") $item["currencyfield"] = [Double]::Parse("123.48"); $item.Update(); You can find a complete guide about powershell and list s fields here: getting-and-setting-fields Powershell


1

Your method expects an array of strings, but you are passing in a single string. Also, the first line of your method overwrites the value that was passed in (perhaps you added this because you were getting an error?) I would suggest changing the method signature to public static void Main(string args) and also removing the following line of code: args ...


0

You can use the Register-SPAppPrincipal command to register an App using PowerShell. Something like this: $realm = Get-SPAuthenticationRealm -ServiceContext $web.Site; $appIdentifier = $clientID + '@' + $realm; Register-SPAppPrincipal -DisplayName $appName -NameIdentifier $appIdentifier -Site $web Look here for the explanation.


1

I did a bit of searching, and found the below. If you're just looking to the read the values from the cell, any of the below should work. I was able to return values on them all. $objWorksheet.Range("B1").Text $objWorksheet.Range("B1:B1").Text $objWorksheet.Range("B1","B1").Text $objWorksheet.cells.Item(2, 1).text $objWorksheet.cells.Item(2, 1).value2 ...


4

When I've ran C# within PowerShell, I've done the assembly bit differently (I'm in O365, so only use CSOM): $path = "path to folder containing dll's (e.g.,ISAPI folder in 15 Hive)" $assemblies = @( "$path\Microsoft.SharePoint.Client.dll", "$path\Microsoft.SharePoint.Client.Runtime.dll" "System.Core" ) $cSharp = @" using System; using ...


1

The issue you have is, you are looping till index i reaches RoleAssignment count and within the loop you are removing the RoleAssignment one by one. This means, the loop count decreases by one. So, on every run, it will only loop half the total no of permissions. So, you have to run multiple times to delete all permissions. What you can do is create an ...


5

You can also use sharepoint backup restore feature to clone sharepoint site. Backup-SPSite -Identity "http://myspsite" -Path "C:\backups\myspsite.bak" -Force -Confirm:$False Restore-SPSite "http://myspsite:81" -Path C:\backups\myspsite-81.bak -Force -Confirm:$False For more details: ...


0

You should use SharePoint Management Shell for this, it includes the SharePoint-Commands.


2

Go to the visual studio feature file and check whether you have all the webparts you needed in the feature. Else add them by selecting and send from left to right.


3

If you have developer knowledge, you can interrupt the email alerts, according to : http://blogs.msdn.com/b/sharepointdeveloperdocs/archive/2007/12/14/how-to-customizing-alert-emails-using-ialertnotificationhandler.aspx. We have used it to modify the email alert. The other solution is to filter them in exchange, but the exchange guy won't be very happy


1

the files your accessing are on a local or shared drive eg C:/filepath that your looping through each item? from what i gather its giving you access denied to the file path location your trying to delete from! goto the folder location (my example its called filepath, so i goto C:/ and right click filepath) right click and select properties... security -> ...


0

Instead of: $fileCollection.Delete($file.Name) Try: $file.delete()


2

Make sure that your feature (in the VS solution) has all the web parts in it.


0

Looks Like this is not supported by MSFT so that we don't any solution far. Even Spence Harber respond on one of post. But this code from Technet Gallery. http://gallery.technet.microsoft.com/office/Create-User-Profile-Sync-e9ec0cf7 ...


0

I Tried the command with localhost instead of server name and it works for my case P.S. (I tried everything mentioned here but nothing works except this :-) )


1

The following script allows you to access user profile properties for Sharepoint Online users. Under PersonalSpace you can find either a link or an empty field. It will let you know if the user has the personal site. Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Context.Credentials = $Creds #Identify users in the Site Collection ...


0

We usually run a Start Up script or so called Warm up script at a scheduled time at the beginning of the day. This refreshes the App pool and in turn the subsequent IIS requests come faster like normal. You should not be doing this activity every 5 min . Remember that if you warm up all your sites/pages you will put a big memory pressure on the servers and ...


0

Why you need to run it every 5 min or so...typically App Pool Recycle(usually after mind AM hours). If you place the empty character in the File path then may be issue. check this one. https://spbestwarmup.codeplex.com/discussions/468743 If you have an error code please share it.


1

You can go to the webpart gallery and check whether webparts are there first. If not, then you have to make sure you run as admin the PowerShell as well as try including the user as farm admin. There can be errors sometimes which occur only when activating the feature but not when installing the solution. So try running the script for just to add the ...


0

First thing is take backup of your wsp and rename it to say mywsp.cab . This will show you a zip file with all the items in wsp . Check if the desired webpart is there or no . If the webpart is present : Goto central admin -> System settings->Manage farm solution Retract and remove your solution which you deployed . Copy the wsp under above folder like ...


-1

Did you try to restore to a host header web application? if so use: $w = Get-SPWebApplication <your webapp> Restore-SPSite -Identity <URL of sitecol> -Path <path to backup> -HostHeaderWebApplication $w.Url


1

You can hide a subsite with the following script: Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue $web = Get-SPWeb http://SubSiteUrl... $publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) $publishingWeb.IncludeInGlobalNavigation = $false $publishingWeb.Update(); $web.Dispose() To delete a ...


0

Add-SPShellAdmin -username DOMAIN\YourUser As well Just run Add-SPShellAdmin -username DOMAIN\YourUser again and it will set the appropriate permissions. Follow http://blogs.msdn.com/b/kvosters/archive/2012/11/29/the-local-farm-is-not-accessible-cmdlets-with-featuredependencyid-are-not-registered.aspx


1

The second one that raises error can be solved by removing the escape character: "\", because it causes an error in PowerShell. So here is the working code: $termGroup.AddContributor("Domain\Everyone")


1

I am sure Gary Lapointe's custom stsadm will not work in 2013. You need to do the following things. 1st deploy the Lapointe.wsp to install all the custom commands. Download it from here :SharePoint 2013 Server Cmdlets (x86, x64) Once above solution succesfully installed then all his custom command will be available. Now you to run the following command. ...


0

In followup to @JoeJohnston answer crediting me: If you want to play by the rules you won't go modifying permissions on the SQL Server directly. Here is an alternate approach that may work for you, provide you already have one account that can use PowerShell to connect to the SharePoint farm. I haven't had occasion to try it directly. From SharePoint ...


1

Assuming I understand your question, you want to email the csv file and cc the site owners and secondary contacts the file as well. This should do what you were looking for assuming the rest of your code was correct. Please keep in mind you will have to change the appropriate values. if (( Get-PSSnapin -Name “Microsoft.SharePoint.Powershell” -ErrorAction ...


0

When you import the list content, it will add a new row with same information, It has happened to me many times.



Top 50 recent answers are included