locked
where-object - filter array list RRS feed

  • Question

  • Hello all,

    using powershell...

    Trying to  filter where none of the file names are in the array list.

    Not working against Array list....

    any help would be great?

    $Dir =  Get-ChildItem  $DirSource -filter "*.cdr" |	
    		Where-Object {($_.PSIsContainer -eq $false)	-and ($_.BaseName -notcontains $DBexcludeList)}
    		
    		ForEach($file in $dir) 
    		{
    			$file.BaseName
    			
    		}

    gv



    Sword




    • Edited by gv-sword Monday, May 4, 2015 6:09 PM
    • Moved by Olaf HelperMVP Tuesday, May 5, 2015 8:46 AM Moved from "SQL Server Database Engine" to a more related forum
    Monday, May 4, 2015 6:04 PM

Answers

  • Swapping the order of the contains expression should work

    i.e. 

    $Dir =  Get-ChildItem  $DirSource -filter "*.cdr" |	
    		Where-Object {($_.PSIsContainer -eq $false)	-and ($DBexcludeList -notcontains $_.BaseName )}
    		
    		ForEach($file in $dir) 
    		{
                write-host $file
    			$file.BaseName
    			
    		}

    • Marked as answer by gv-sword Tuesday, May 5, 2015 6:02 PM
    Monday, May 4, 2015 6:49 PM

All replies

  • Swapping the order of the contains expression should work

    i.e. 

    $Dir =  Get-ChildItem  $DirSource -filter "*.cdr" |	
    		Where-Object {($_.PSIsContainer -eq $false)	-and ($DBexcludeList -notcontains $_.BaseName )}
    		
    		ForEach($file in $dir) 
    		{
                write-host $file
    			$file.BaseName
    			
    		}

    • Marked as answer by gv-sword Tuesday, May 5, 2015 6:02 PM
    Monday, May 4, 2015 6:49 PM
  • Thanks for your help!

    was taking to long so I Stopped it....I'm going to approach this differently..

    Thanks

    GV


    Sword

    Tuesday, May 5, 2015 6:02 PM