Create an ADSISearcher object


There are severals way to create .Net object from PowerShell.I usually used this one :

$Searcher = [ADSISearcher]'(admincount=1)'
$Searcher.SizeLimit = 5
$Searcher.SearchRoot   = [ADSI]""

But I just discovered a nice new way :

    Filter       = '(admincount=1)'
    SizeLimit    = 5
    SearchRoot   = [ADSI]""

You can use a hashtable that contains all needed properties.

This works for all type of objects :

    host  = ''
    port  = 587

You just need to check on MSDN all the constructor available for the .Net class.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.