![]() PS H:\> $hash = # define a new empty hash table If it's not there yet - then I'll send that line into the new file. I'm going to add each line to a hash table.īut before adding it - i'll check if the line is already in the hash table. Remove Duplicate Rows From A Text File Using Powershell. If the file data is not 'sorted', but the order *is* important. the case that one bumps into is always the tricky case. (You now end up with a file that is sorted, and where every line is unique) Sort it - and then use Get-Unique gc $filename | sort | get-unique > $newfileName If the file's content is not sorted, and the final order of the lines is unimportant, then it's also easy. (But remember, the Get-Unique command only works on sorted data!) PS:\> gc $filename | get-unique > $newfileName $mappings.Add($currentList.Apple,, commandline, microISV, nimbletext, powershell, tools # Leveraged throughout the script for one or more calls.įunction SpmBuild-WebAndListIdMappings ’" -f $currentList.Title, $spWeb.Title # Import/load common SharePoint assemblies that house the types we’ll need for operations.Īdd-Type -AssemblyName "Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" # Usage from prompt: ".\FindDuplicateGuids.ps1 " The script created works with both SharePoint 2007 and SharePoint 2010, and it has no specific dependencies beyond SharePoint being installed and available on the server where the script is run. ![]() The script simply collected the identities of each list and web and reported back any GUIDs that appeared more than once. My solution was to whip-up a PowerShell script ( FindDuplicateGuids.ps1) that processed each of the lists ( SPList) and webs ( SPWeb) in a target site collection. It is precisely in times like those described that PowerShell comes to mind. We needed a relatively quick and easy way to figure out the name(s) of the object or objects which were being impacted by the duplicate GUIDs. SharePoint continued to run without issue (interestingly enough), but the duplication of object GUIDs made it downright difficult for any software that depended on unique object identities being … well, unique.Īlthough the software logs told us which GUID was being duplicated, we didn’t know which SharePoint object or objects the GUID was tied to. This isn’t anything that should ever happen, but it had. Apparently, the site collection in question contained two or more objects with the same identity that is, the objects had ID properties possessing the same GUID. The software ran fine when targeting all other site collections, so we naturally suspected that something was wrong with only one specific site collection.Īfter further examination of logs that were tied to the software, it became clear that we had a real predicament. The errors that were returned by the software were somewhat cryptic, but they pointed to a problem handling certain objects in a SharePoint site collection. I was part of a team that was working with a client to troubleshoot problems that the client was encountering when they attempted to run some software that targeted SharePoint site collections. ![]() I’m going to speak in generalities when it comes to the identities of the parties and software involved, though, to “protect the innocent” and avoid upsetting anyone. The story and situation I’m about to share is true. Of course, how many times have you heard “you shouldn’t ever really need this” when it comes to SharePoint? I’ve been at it a while, and I can tell you that things that never should happen seem to find a way into reality – and into my crosshairs for troubleshooting. Let me start by saying something right off the bat: you should never need what I’m about to share. This is a bit of an oldie, but I figured it might help one or two random readers. ![]()
0 Comments
Leave a Reply. |