Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to extract about 40 folders with each containing a rar, but I never have done in it powershell. In bash you can use */*.rar to extract them using a wildcard, but how do I this in powershell ? I tried something along

C:\Program Files (x86)\Unrar\UnRAR.exe' x  .\*\*.rar 

But it errors:

UNRAR 4.10 freeware      Copyright (c) 1993-2012 Alexander Roshal

Cannot read contents of .\*\*.rar
The filename, directory name, or volume label syntax is incorrect.
share|improve this question

I use this:

$parent = 'c:\myrar_files'

$files = @()

Get-ChildItem $parent -Recurse -Filter "*.rar" | % {

    # Recurse through all subfolders looking for .rar files only.

    $files = $files + $_.FullName

foreach ($f in $files) {

    # UnRAR the files. -y responds Yes to any queries UnRAR may have.

   C:\scripts\WinRAR\unrar x -y $f
share|improve this answer

Test this first because I don't have anything to test it on:

get-childitem -recurse -filter *.rar | %{"C:\Program Files (x86)\Unrar\UnRAR.exe" x $_.fullpath}

I'm not 100% sure if the x will cause it to extract to the current directory or the directory of the rar file so you may have to add a cd to the commands.

get-childitem -recurse -filter *.rar | %{cd $; "C:\Program Files (x86)\Unrar\UnRAR.exe" x $}
share|improve this answer
The first one gives me: >> The second one gives me: – Lucas Kauffman Feb 2 '12 at 16:29
What version of PowerShell are you using? – Scott Keck-Warren Feb 2 '12 at 20:32
Ehm The standard one in windows 7 :/ – Lucas Kauffman Feb 2 '12 at 21:04
Try the first one again, I had an unterminated quote. – Scott Keck-Warren Feb 3 '12 at 15:56
Unexpected token 'x' in expression or statement. At line:1 char:84 + get-childitem -recurse -filter *.rar | %{"C:\Program Files (x86)\Unrar\UnRAR.exe" x <<<< $_.fullpath} + CategoryInfo : ParserError: (x:String) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken – Lucas Kauffman Feb 3 '12 at 16:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.