get-childitem

Confused with -Include parameter of the Get-ChildItem cmdlet

From documentation: -Include Retrieves only the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as "*.txt". Wildcards are permitted. The Include parameter is effective only when the command includes the Recurse parameter or the path leads to the ...

PowerShell Scripting - Get-ChildItem

I'm just learning PowerShell and I've written a script that will be used for archiving log files from a server. I'm in pretty good shape with everything but the recursiveness or not of get-childitem... The issue I seem to be having is that when Get-ChildItem is not recursive and -Include is present with only one filter, it is ignored! ...

Passing directory contents as a single line to an executable in Powershell

I have a binary executable that takes a list of file paths as arguments, e.g., C:\Tool.exe C:\Files\File1.txt C:\Files\File2.txt I would like to call this tool from Powershell. The question is, how can I get the output of get-childitem all on one line? If I run: ls C:\Files\*.txt | select FullName I get one path per line. H...

Powershell Get-ChildItem -Include/-Exclude doesn't filter if passed as an arg to a function

Having a problem getting a filter argument to Get-ChildItem in a function The following works fine and displays a whole list of files: c:\temp\Get-ChildItem -Include deleteme.txt -Recurse Now say I have the following script file starts here filename = GetLastFile.ps1 param([string] $filter) $files = Get-ChildItem $filter Write-Ho...

Copy files where lastwritetime -ge 3/26/2010 9:00pm with Powershell

I need to copy files in one directory to another directory where the lastwritetime is greater than or equal to 3/26/2010 9:00pm. I'm using: Get-ChildItem C:\pstest\hlstore\folder1\data | where-object {$i.lastwritetime -ge “3/26/2010 9:00 PM”} | Copy-Item -destination c:\pstest\hlstore2\folder1\data But nothing happens... Any help wo...

Powershell, ftp, get-childitem

Hey all, Little new to powershell. I am trying to locate a get-childitem like command that will work on an ftp site. Here is some psuedo-code: $target = "c:\file.txt" $username = "username" $password = "password" $ftp = "ftp://$username:$password@myftpsite" $webclient = New-Object System.Net.WebClient $uri = New-Object System.Uri(...

How to write a Powershell function to get directories?

Using Powershell I can get the directories with the following command: Get-ChildItem -Path $path -Include "obj" -Recurse | ` Where-Object { $_.PSIsContainer } I would prefer to write a function so the command is more readable. eg: Get-Directories -Path "Projects" -Include "obj" -Recurse And the following function does exactly t...

PowerShell: Subdirectory listing to a txt-file

Hello! Today I started scripting in Windows PowerShell - so please excuse my "dumbness"... I want to create txt-Files with the name of the subfolders of each "rootfolder" on drive G:. On G:\ I have the following folders: 1_data 2_IT_area 3_personal 4_apprenticeship 7_backup 8_archives 9_user_profile So I wrote this script: get-chil...