Question

Using a PowerShell cmdlet (non-alias), pipe the contents of your current directory into a Where-Object search...

Using a PowerShell cmdlet (non-alias), pipe the contents of your current directory into a Where-Object search to find a file or group of files by partial or full filename. (Suggestion: Use part or all of a filename to filter everything else out of a directory listing. It’s much easier to test by looking for a file that really exists)

POWERSHELL PLEASE!

Homework Answers

Answer #1
get-ChildItem $targetDir -recurse | where {$_.name -like $pattern} | select name

The Get-ChildItem cmdlet gets the items in one or more specified locations. If the item is a container, it gets the items inside the container, known as child items. You can use the Recurse parameter to get items in all child containers and use the Depth parameter to limit the number of levels to recurse.

where clause is used to define the regular expression of the required type.

select is used to select a specific field

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT