Powershell magic - Get all files in folder (and subfolders) with a specific extension
After many years with bash-scripting and the power of unix in my fingertips, seeing that Microsoft finally made a good commandline shell was pleasant.
For finding files in unix from a particular folder i'd often use: find . -name *.jpg (or similar). Today I had the same need on windows. I needed to copy all files (images) from a rootfolder (and all files withing the subfolders) to another folder. The following lines will help you along to do just that (just add a copy for each of the files).
$items = Get-ChildItem -Recurse "C:\SomeDirectory\"
$filesWithDirectory = $items|?{$_.extension -eq ".jpg"}|select Directory,Name
This will give you a table with the following syntax (so you can use it in a foreach loop to copy or to whatever):
Directory Name c:\somedir\blabla\ somepicture.jpg
Enjoy!
Sharepoint - Fast Search gotchas
After fighting with Sharepoint 2010 and Fast Search for Sharepoint 2010 for a while, I thought I'd would be a good idea to write a post summarizing gotchas and things to check if something goes wrong. I'm starting to get a list of things that might help save some people time in debugging.
Any comments / ideas you'd like to share with me for such a post?
FAST - Unable to connect to search Service
FAST suddenly stopped working on the Sharepoint frontend. Doing a search from the search site, resulted in the following error: "Unable to Connect Search Service. "
I scanned the event logs; none giving any useful information, all seemed to be working.
The only two errors if relevance were:
- [Microsoft.Office.Server.Search.Query.SearchServiceNotFoundException]: The search request was unable to connect to the Search Service.
- [Microsoft.Office.Server.Search.Administration.SearchServiceApplicationFault]: The creator of this fault did not specify a Reason
Useful right? .. Not particularly..
I did a "nctrl status" on the fast-backends and admin, all services was running. Why all of the sudden did the query service stop working?
It turns out that the server-clocks were different (not synchronized). I adjusted the date & time (one server was 8 minutes behind the other) and it started working automagically!
I'm guessing WCF times out behind the scenes or some communication error occurs silently because of this. But no useful info in any logs. Quite frustrating!
So, lesson learnt: Check the system time on ALL Servers! They should be the same.
I hope this will be useful for others with the same problem(as google provides no results for this behaviour).
Windows Server 2008 R2 - 64-bit 100% CPU Load
I've only discovered this issue when running a 64-bit server with 16 GB ram (or more). The server will be stuck on 100% cpu load and continously increase memory usage (it seems like a memory bug to me..). It's all related to how windows uses paging and caching of the internal memory of windows.
Take a look at this post: http://blogs.msdn.com/b/ntdebugging/archive/2009/02/06/microsoft-windows-dynamic-cache-service.aspx and look at the Dynamic Cache Manager service (can be downloaded and installed from http://www.microsoft.com/downloads/details.aspx?FamilyID=e24ade0a-5efe-43c8-b9c3-5d0ecb2f39af )
I've installed it on most server and after tweaking the params, the server load falls down to normal. Quite neat and a really annoying bug if you don't know where to look.
Powershell tricks - BCS - List External content types (LOB Systems)
I spent a few hours figuring this out, hope it's useful for someone:)
From Powershell list the external content types (ECTS) / LOB (Line of Business) from the BCS/BDC (catalog meta data) service.
This is useful if you're scripting e.g. like we are adding of content-sources using the BDC models created. Here it is:
$ctx = "http://localhost"
# Get the BDC context
$bdc = Get-SPBusinessDataCatalogMetaDataObject -BdcObjectType Catalog -ServiceContext $ctx
# Get the list of all LOB systems
$lobs = $bdc.GetLobSystems("*")
Foreach($lob in $lobs){
$lobId = $lob.Id
$lobName = $lob.Name
$lobDisplayName = $lob.DefaultDisplayName
$lobEntities = $lob.Entities
$lobSystemInstance = $lob.SystemInstances
Write-Host $lob.DefaultDisplayName
}
10/26/10 03:00:27 am, 