Posts

Showing posts with the label PowerShell

SharePoint PowerShell: Delete all list items in one line

Short & handy (Get-SPWeb http://yoursite).Lists["Listname"].Items | % { $_.ParentList.GetItemById($_.ID).Delete() }

Remove-SPManagedAccount is not working or you can't remove Managed Accounts from GUI

Image
The Problem I had to change the farm administrator because the IT decided not to use a single account as local admin anymore. So I changed the farm account with powershell and adapted all the services. The only think was that I had forgot to delete the account from the managed accounts list. Weeks passed and I stumbled over the account in the managed accounts list. When I tried to open the link " Security " -> " Configure managed accounts " I got an exception. The error was obvious. The account which was deleted from the AD could not be resolved. 1.Try I created the user again in the AD. After that the error in UI disappeared but when I tried to deleted the managed account from the list, I got following error. 2. Try It seemed that there some services still reference this account. The first thing was to check the IIS Application Pool accounts. Then I checked twice the settings in the CA " Security " -> " Configure Service...

Offline Metadata Instances in SharePoint 2010 & OfflineTermstoreNames

If you're using powershell to add metadata to your termstore and you see only an entry in the OfflineTermstoreNames property, then it seems that some of your Metadata Services are offline. C:\> $site = Get-SPSite http://mysharepoint/sites/project C:\> $session = new-object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)  C:\> $session To activate all instances open the SharePoint Management Shell and type: C:\>$instance = Get-SPServiceInstance | ? {$_.TypeName -eq "Managed Metadata Service"} C:\>$instace It will now display all your instances. If the e.g. first and second are disabled, start it with: C:\>$instance[0] | Start-SPServiceInstance #Start First C:\>$instance[1] | Start-SPServiceInstance #Start Second Wait few minutes. Grab the instance again and check if they are enabled: C:\>$instance = Get-SPServiceInstance | ? {$_.TypeName -eq "Managed Metadata Service"} C:\>$instace Now all Termstores should be...

Migrate a SharePoint Team Wiki to an Enterprise Wiki

Perhaps someone has also migrated his old SharePoint 2007 Team Wiki to SharePoint 2010 and wants to have the cool features from an Enterprise Wiki. I searched a while and I think the best way to do this is to migrate with PowerShell. The List Wiki and the Enterprise Wiki are using different fields so there will be no other way I thing but PowerShell or manually. So the great script for your use. Just adapt the settings for your environment. <# PowerShell Script to migrate Team Wikis into Enterprise Wiki Pages #> # Setup Basic sites and pages $webappURL = "http://sharepoint-uat" $wikiSiteURL = "$webappURL/sites/serverplatforms" $wikiWebURL = "$wikiSiteURL/wiki" $pageFolder = "/Seiten/" $oldWikiWeb = "$webappURL/sites/serverplatforms" $wikiListName = "Team Wiki" try { Write-Host " >> STARTING MIGRATION ..." -foregroundcolo...

Delete a SharePoint 2010 Site Collection

Image
When you delete a site collection in SharePoint 2010 from the Web UI it is not immediately deleted. The site is inserted into a queue of "To be deleted" sites. A timer job (Name:Gradual Site Delete) then deletes the sites at some point. This is called "GRADUAL DELETION". This is recommended when you delete large sites to use less system load. Sometimes this can cause errors when you want to create a site collection with the same url immediately after you deleted one. Then you have to wait until the site is really deleted by the timer job or use PowerShell to speed up the process. Helpful PowerShell Commands 1.) You can list the sites in the deletion queue with PowerShell: Get-SPDeletedSite 2.) To delete a site in the queue you can also use PowerShell: Remove-SPDeletedSite -Identity 1f11a7e8-4e89-48ref-af8a-ad805a505753 (Identity is the SiteId) 3.) To restore a site collection in the queue use: Restore-SPDeletedSite -Identity 1f11a7e8-4e...

Restore a previously restored SharePoint Site Collection with Restore-SPSite

Image
In SharePoint you get an error if you try to restore a site collection that war previously restored. I always make a site collection backup of a site while I'm developing directly on a site and if i make any mistakes I restore the back with the Powershell command Restore-SPSite. Common error messages were: Restore-SPSite : The operation that you are attempting to perform cannot be completed successfully.  No content databases in the web application were available to store your site collection.  The existing content databases may have reached the maximum number  of site collections, or be set to read-only, or be offline, or may already contain a copy of this site collection.  Create anoth er content database for the Web application and then try the operation again. Reason The reason for this problem is that you can't restore sites or web which have the same id. SharePoint don't remove all ids when you delete a site collection. (Don't know why) Solutio...

SharePoint Use Confirmation for Site Owners

Image
A problem in SharePoint is to keep content up to date. Therefore SharePoint offers the possibility to create use confirmations. The only problem is that the confirmation can only be approved by the site collection administrators. Not in all companies the site collection admins are also the site owners. This can be due to permission restrictions or other actions that a normal site owner should not do. In this post I'll show you how you can create your own confirmation rules and pages without using visual studio or SharePoint solution files. Standard Site Use Confirmation SharePoint offers an out of the box site confirmation mechanism. It send an email to the site collection owner and updates a counter of how many times a mail is sent without receiving a confirmation. The mechanism does not check the real use of the site. It simply send an email after a period of time to check the use. You can configure it in the Central Administration  under "Application Management...

Check Ports for Extranet SharePoint Farms with PowerShell

When you create a SharePoint Farm within an extranet you usually have to check ports to other servers within other security layers behind firewalls. Here is a simple script for a quick check. Copy this script to every SharePoint Server and modify the ip addresses. Run the script on the server to see if a port is blocked. <# These values can be modified Enter the IPS of the server Ports from http://technet.microsoft.com/en-us/library/cc262849.aspx #> $SERVER_APP = "xxx.xxx.xxx.xxx" $SERVER_WEBAPPS = @("xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx") $SERVER_DB = "xxx.xxx.xxx.xxx" $SERVER_AD = "xxx.xxx.xxx.xxx" $SERVER_DNS = "xxx.xxx.xxx.xxx" $SERVER_SMTP = "xxx.xxx.xxx.xxx" $CLIENT = "xxx.xxx.xxx.xxx" #IP of a client which should access SharePoint $USE_KERBEROS = $false $USE_NETBIOS = $false $USE_SMTP = $true # bi = bidirectional # out = outbound $CONNECTIONS = @( #SQL ( "out", $SERVER_APP, $S...