Scripting with PowerShell

Top  Previous  Next


As well as a Command Line interface FileLocator Network also provides external .NET components that can be used to control searches. Using PowerShell it is possible to run a search with just a few lines of script, e.g.


[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Mythicsoft\FileLocator Network\Mythicsoft.FLR.External.dll")

$search = new-object -typename Mythicsoft.FLR.External.Search

$search.Load( "Main Search" )


$search.ExportResults( “c:\Results.txt”, [Mythicsoft.FLR.Data.Types.ExportFormatType]::Text )


This simple example loads the saved search named 'Main Search' and runs it against the list of saved target computers. Once the search has finished the results are exported to a file in text format.


The component model also allows complex customization of  a saved search before running it, e.g.


[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Mythicsoft\FileLocator Network\Mythicsoft.FLR.External.dll")


$search = new-object -typename Mythicsoft.FLR.External.Search

$search.Load( "Main Search" )


# Add a list of targets to the search

$search.Targets.AddFileList( "C:\ServerLists\GroupOne.txt" );


# Change the Containing Text criteria to load boolean criteria from a file

$search.Criteria.ContainingText = "=C:\SearchTerms\Illegal.txt"

$search.Criteria.ContentsExprType = [Mythicsoft.Search.Core.ExpressionType]::Boolean


# Run the search using the AdminShare method run as the current user

$search.Transport = [Mythicsoft.FLR.Data.Types.TransportType]::AdminShare

$search.Authentication.UserName = ""




# Export the results using a custom XSL Transform

$search.ExportResults( “c:\Results.txt”, "C:\Transform\UniqueHitsOnly.xsl" )



As with most PowerShell objects it is possible to query the methods and properties of an object using get-member (or the alias gm) e.g. to query the search object:


$search | get-member


or the Criteria object:


$search.Criteria | get-member


Also, to list enumerations using the Enum class:


[Enum]::GetNames( [Mythicsoft.FLR.Data.Types.TransportType] )


Error Handling


If an error occurs the pertinent information is normally contained within the InnerException, e.g.



Copyright © 2010 Mythicsoft Ltd. All rights reserved.
Help file version: 3.6.0