Odpovědět uncompress folders and file but not all folders

  • 6. května 2012 17:01
     
      Obsahuje kód

    Hello,

    I need a script that uncompress all folders and files on c:\ d:\ e:\ drives and do nothing for the followings folders:

    C:\WINDOWS\$Nt*

    C:\WINDOWS\$hf_mig$

    C:\WINDOWS\ie7updates

    I already found this : but it's not enough, can  you please help me?

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colFolders = objWMIService.ExecQuery _
     ("SELECT * FROM Win32_Directory WHERE Name = 'c:\\'")
    For Each objFolder in colFolders
     errResults = objFolder.Uncompress
     Wscript.Echo errResults
    Next


    Thanks in advance.

    Salento.

Všechny reakce

  • 6. května 2012 17:45
     
     
    "SELECT * FROM Win32_Directory WHERE Name = 'c:\\' AND NOT Name LIKE '

    C:\WINDOWS\$Nt%'"

    Just add each bit of logic to you where clause using AND.


    ¯\_(ツ)_/¯

  • 6. května 2012 18:00
     
      Obsahuje kód

    Thank you very much, it's very helpfull

    Does it correct?

    ("SELECT * FROM Win32_Directory WHERE Name = 'c:\\' AND 'd:\\' AND 'e:\\' AND NOT Name like 'C:\WINDOWS\$Nt%' AND 'C:\WINDOWS\$hf_mig$' AND 'C:\WINDOWS\ie7' AND 'C:\WINDOWS\ie8")

  • 6. května 2012 19:00
     
      Obsahuje kód

    NO - more like this.

    wql="SELECT * FROM Win32_Directory" _
      & " WHERE Name='c:\\'" _
      & " OR Name='d:\\'" _
      & " OR Name='e:\\'" _
      & " AND NOT Name like 'C:\\WINDOWS\\$Nt%'" _
      & " AND NOT Name='C:\\WINDOWS\\$hf_mig$'" 
      & " AND NOT Name='C:\\WINDOWS\\ie7'" _
      & " AND NOT Name='C:\\WINDOWS\\ie8"
    Set colFolders = objWMIService.ExecQuery( wql )


    ¯\_(ツ)_/¯


  • 6. května 2012 19:25
     
      Obsahuje kód

    Of course looking at this it is n't going to do what you want. .

    This will specify the drives and recursion will do the rest.  All we need is the negative filters as ANDs while we need to OR the drives and we need to group them  to be sure they are evaluated first. 

    wql="SELECT * FROM Win32_Directory" _
      & " WHERE (Drive='c:' OR Drive='d:' OR Drive='e:')" _
      & " AND NOT Name like 'C:\\WINDOWS\\$Nt%'" _
      & " AND NOT Name='C:\\WINDOWS\\$hf_mig$'" 
      & " AND NOT Name='C:\\WINDOWS\\ie7'" _
      & " AND NOT Name='C:\\WINDOWS\\ie8"
    Set colFolders = objWMIService.ExecQuery( wql )

    This is also a very good way to crash your system.  Be careful.


    ¯\_(ツ)_/¯



  • 6. května 2012 20:14
     
      Obsahuje kód

    Thank you very much,

    still exist some errors, what's wrong?

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    
    wql="SELECT * FROM Win32_Directory" _
      & " WHERE Name='c:\\'" _
      & " OR Name='d:\\'" _
      & " OR Name='e:\\'" _
      & " AND NOT Name like 'C:\\WINDOWS\\$Nt%'" _
      & " AND NOT Name='C:\\WINDOWS\\$hf_mig$'" _ 
      & " AND NOT Name='C:\\WINDOWS\\ie7'" _
      & " AND NOT Name='C:\\WINDOWS\\ie8'" _
    Set colFolders = objWMIService.ExecQuery( wql )
    
    For Each objFolder in colFolders
     errResults = objFolder.Uncompress
     Wscript.Echo errResults
    Next

  • 6. května 2012 20:17
     
     

    You have to post the error I cannot see your screen.


    ¯\_(ツ)_/¯

  • 6. května 2012 20:36
     
     

    line 13

    char 1

    error = expected end of statement

    code 800A0401

  • 6. května 2012 20:55
     
     
    What is on line 13?

    ¯\_(ツ)_/¯

  • 6. května 2012 20:56
     
      Obsahuje kód
    Set colFolders = objWMIService.ExecQuery( wql )
  • 6. května 2012 21:05
     
     

    You are missing a quote somewhere before that line.

    End of wql statement


    ¯\_(ツ)_/¯

  • 6. května 2012 21:23
     
      Obsahuje kód

    Thanks again for your help, 

    As you may understand I’m not very practice with scripting, my whole code is like the following there is no more code, now for a test purpose, I created a folder (c:\users\%username%\test that is compressed but, now, when i run the vbs i can't see nothing happens, no error message.

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    wql="SELECT * FROM Win32_Directory" _
      & " WHERE Name='c:\\'" _
      & " OR Name='d:\\'" _
      & " OR Name='e:\\'" _
      & " AND NOT Name like 'C:\\WINDOWS\\$Nt%'" _
      & " AND NOT Name='C:\\WINDOWS\\$hf_mig$'" _ 
      & " AND NOT Name='C:\\WINDOWS\\ie7'" _
      & " AND NOT Name='C:\\WINDOWS\\ie8'"
    Set colFolders = objWMIService.ExecQuery( wql )
    
    For Each objFolder in colFolders
     errResults = objFolder.Uncompress
     Wscript.Echo errResults
    Next


     
    • Upravený Salento9 6. května 2012 21:24
    •  
  • 6. května 2012 21:28
     
     Odpovědět Obsahuje kód
    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    wql="SELECT * FROM Win32_Directory" _
      & " WHERE (Drive='c:' OR Drive='d:' OR Drive='e:')" _
      & " AND NOT Name like 'C:\\WINDOWS\\$Nt%'" _
      & " AND NOT Name='C:\\WINDOWS\\$hf_mig$'" _
      & " AND NOT Name='C:\\WINDOWS\\ie7'" _
      & " AND NOT Name='C:\\WINDOWS\\ie8'"
    Set colFolders = objWMIService.ExecQuery( wql )
    For Each objFolder in colFolders
        'errResults = objFolder.Uncompress()
        Wscript.Echo objFolder.Caption
    Next


    ¯\_(ツ)_/¯

  • 7. května 2012 6:39
     
      Obsahuje kód

    Good morning,

    Strange, tried again the script but can't see anything happens...

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    wql="SELECT * FROM Win32_Directory" _
      & " WHERE (Drive='c:' OR Drive='d:' OR Drive='e:')" _
      & " AND NOT Name like 'C:\\WINDOWS\\$Nt%'" _
      & " AND NOT Name='C:\\WINDOWS\\$hf_mig$'" _
      & " AND NOT Name='C:\\WINDOWS\\ie7'" _
      & " AND NOT Name='C:\\WINDOWS\\ie8'"
    Set colFolders = objWMIService.ExecQuery( wql )
    For Each objFolder in colFolders
        'errResults = objFolder.Uncompress()
        Wscript.Echo objFolder.Caption
    Next


    • Upravený Salento9 7. května 2012 6:39
    •  
  • 7. května 2012 12:26
     
      Obsahuje kód

    Also tried in this way but not working:

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    wql="SELECT * FROM Win32_Directory WHERE (Drive='c:' OR Drive='d:' OR Drive='e:' ) AND NOT Name like 'C:\\WINDOWS\\$Nt%' AND NOT Name='C:\\WINDOWS\\$hf_mig$' AND NOT Name='C:\\WINDOWS\\ie7' AND NOT Name='C:\\WINDOWS\\ie8'"
    
    Set colFolders = objWMIService.ExecQuery( wql )
    For Each objFolder in colFolders
        errResults = objFolder.Uncompress()
       ‘ Wscript.Echo objFolder.Caption
    Next
    

  • 7. května 2012 13:07
     
      Obsahuje kód

    Finally got what i need, and it works!!!

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    
    ExecQuery("c")
    ExecQuery("d")
    ExecQuery("e")
    
    Sub ExecQuery(sDrive)
    wql="SELECT * FROM Win32_Directory WHERE (Drive='" & sDrive & ":') AND NOT Name like 'C:\\WINDOWS\\$Nt%' AND NOT Name='C:\\WINDOWS\\$hf_mig$' AND NOT Name='C:\\WINDOWS\\ie7' AND NOT Name='C:\\WINDOWS\\ie8'"
    
    Set colFolders = objWMIService.ExecQuery( wql )
    For Each objFolder in colFolders
    '    errResults = objFolder.Uncompress()
        Wscript.Echo objFolder.Caption
    Next  
    End Sub

  • 7. května 2012 14:06
     
     
    Forgot something, i need to create a log file can you please help?
  • 7. května 2012 14:14
    Moderátor
     
     

    Hi,

    What have you tried so far?

    Bill

  • 7. května 2012 14:28
     
      Obsahuje kód

    Finally got what i need, and it works!!!

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    
    ExecQuery("c")
    ExecQuery("d")
    ExecQuery("e")
    
    Sub ExecQuery(sDrive)
    wql="SELECT * FROM Win32_Directory WHERE (Drive='" & sDrive & ":') AND NOT Name like 'C:\\WINDOWS\\$Nt%' AND NOT Name='C:\\WINDOWS\\$hf_mig$' AND NOT Name='C:\\WINDOWS\\ie7' AND NOT Name='C:\\WINDOWS\\ie8'"
    
    Set colFolders = objWMIService.ExecQuery( wql )
    For Each objFolder in colFolders
    '    errResults = objFolder.Uncompress()
        Wscript.Echo objFolder.Caption
    Next  
    End Sub

    It is impossible for th eabove code to work.  The code I posted was trested and works correclty.  It will display a list of folders.  If you do not see a list of folders then you cooied the code incorrectly.  You must copy to notepad and be sure the code is not damaged. The file must be save as ANSI and not unicode.

    The results can be logged by tredirecting the output.

    cscript uncompress.vbs > uncompress.log


    ¯\_(ツ)_/¯

  • 7. května 2012 16:56
     
      Obsahuje kód

    JVR, I'm very sorry but i tried the script as you describe but simply can't see nothing happens :(

    When i use this script

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    
    ExecQuery("c")
    ExecQuery("d")
    ExecQuery("e")
    
    Sub ExecQuery(sDrive)
    wql="SELECT * FROM Win32_Directory WHERE (Drive='" & sDrive & ":') AND NOT Name like 'C:\\WINDOWS\\$Nt%' AND NOT Name='C:\\WINDOWS\\$hf_mig$' AND NOT Name='C:\\WINDOWS\\ie7' AND NOT Name='C:\\WINDOWS\\ie8'"
    
    Set colFolders = objWMIService.ExecQuery( wql )
    For Each objFolder in colFolders
    '    errResults = objFolder.Uncompress()
        Wscript.Echo objFolder.Caption
    Next  
    End Sub


    with your command "cscript uncompress.vbs > uncompress.log" a log is created with a list of all folders but when i use this script

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    
    ExecQuery("c")
    ExecQuery("d")
    ExecQuery("e")
    
    Sub ExecQuery(sDrive)
    wql="SELECT * FROM Win32_Directory WHERE (Drive='" & sDrive & ":') AND NOT Name like 'C:\\WINDOWS\\$Nt%' AND NOT Name='C:\\WINDOWS\\$hf_mig$' AND NOT Name='C:\\WINDOWS\\ie7' AND NOT Name='C:\\WINDOWS\\ie8'"
    
    Set colFolders = objWMIService.ExecQuery( wql )
    For Each objFolder in colFolders
        errResults = objFolder.Uncompress()
    '    Wscript.Echo objFolder.Caption
    Next  
    End Sub

    it works, it decompress all needed files and folder but log file is empty.

    I own W7, but script should work on Win2003 and Win2008R2 servers.



    • Upravený Salento9 7. května 2012 16:59
    •  
  • 7. května 2012 17:01
     
     

    That is correct.  You disabled the output.

    Re-enble the output and you will get a log.   This iwll not tell you if a folder is compressed or uncompressed and it will not tell you about files.

    If you run out of space on C during decompression you can crash the server.


    ¯\_(ツ)_/¯

  • 7. května 2012 17:18
     
     

    thank you for warning me about 'run out of space'

    Is there a way to log file/folders that have been decompressed and not?

  • 7. května 2012 17:24
     
     

    thank you for warning me about 'run out of space'

    Is there a way to log file/folders that have been decompressed and not?

    Check the compressed bit on the folder. objFolder.Compressed.

    if objFolder.Compressed Then
        ret=objFolder.Uncompress
        Wscript.Echo ret
        Wscirpt.Echo objFolder.Caption
    End If


    ¯\_(ツ)_/¯

  • 7. května 2012 18:44
     
      Obsahuje kód

    do you mean like that?

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    
    ExecQuery("c")
    ExecQuery("d")
    ExecQuery("e")
    
    Sub ExecQuery(sDrive)
    wql="SELECT * FROM Win32_Directory WHERE (Drive='" & sDrive & ":') AND NOT Name like 'C:\\WINDOWS\\$Nt%' AND NOT Name='C:\\WINDOWS\\$hf_mig$' AND NOT Name='C:\\WINDOWS\\ie7' AND NOT Name='C:\\WINDOWS\\ie8'"
    
    Set colFolders = objWMIService.ExecQuery( wql )
    For Each objFolder in colFolders
    
        if objFolder.Compressed Then
        ret=objFolder.Uncompress
        Wscript.Echo ret
        Wscirpt.Echo objFolder.Caption
    End If
    
    Next  
    End Sub

  • 7. května 2012 19:09
     
     

    Did you try it?


    ¯\_(ツ)_/¯

  • 7. května 2012 19:18
     
     

    used in this way (decompress.vbs > decompress.log) but it don't decompress and it don't write to log and no error meassage

    strange.

    • Upravený Salento9 7. května 2012 19:19
    •  
  • 7. května 2012 19:28
     
     

    used in this way (decompress.vbs > decompress.log) but it don't decompress and it don't write to log and no error meassage

    strange.

    Because there are no compressed folders. That is what the IF does.

    Try this,

    if objFolder.Compressed Then
        ret
    =objFolder.Uncompress
       
    Wscript.Echo ret
       
    Wscirpt.Echo "Compressed:" & objFolder.Caption
    Else
        Wscript.Echo "Not Compressed:" & objFolder.Caption
    End If


    ¯\_(ツ)_/¯

  • 7. května 2012 19:40
     
     

    i receive now runtime error object require 'wscipt' but it decompress folders and if exist compressed files in a non compressed folder it do nothing

    error object require 'wscipt on "Wscirpt.Echo objFolder.Caption"

  • 7. května 2012 19:50
     
     

    i receive now runtime error object require 'wscipt' but it decompress folders and if exist compressed files in a non compressed folder it do nothing

    error object require 'wscipt on "Wscirpt.Echo objFolder.Caption"

    YOu have to post the complete error message.  Read it very carefull as it will tell you exactly what is wrong.


    ¯\_(ツ)_/¯

  • 7. května 2012 19:55
     
     

    (16, 5) Microsoft VBScript runtime error: Object required: 'Wscirpt'

    (16, 5) is "Wscirpt.Echo objFolder.Caption"

  • 7. května 2012 20:14
     
     

    (16, 5) Microsoft VBScript runtime error: Object required: 'Wscirpt'

    (16, 5) is "Wscirpt.Echo objFolder.Caption"

    Can you see it?  It is spelled wrong.  Fix the spelling and it will probably work.


    ¯\_(ツ)_/¯

  • 10. května 2012 12:11
     
      Obsahuje kód

    HI,

    i finally managed to have the following code which should decompress all folder and files on c:\ d:\ e:\ with same exclusion it also should write a log on c:\temp\decompress.log and if c:\ drive have less than 1 giga free space it should stop archiving, so after some test it seems to works fine but in doesn't decompress files that belongs on  non compressed folder. can you please help found what's wrong on the code?

    code:

    Option Explicit
    On Error Resume Next
    
    Const HARD_DISK = 3 
    Const ForReading = 1
    Const ForWriting = 2
    Const ForAppending = 8
    
    
    Dim oFSO                                : Set oFSO            = CreateObject("Scripting.FileSystemObject")
    Dim oWMI                               : Set oWMI           = GetObject("winmgmts:\\.\root\cimv2")
    Dim sLogFile                            : sLogFile              = "c:\temp\decompress.log"
    Dim oDisks, oItem          : Set oDisks =  oWMI.ExecQuery ("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "") 
    
    For Each oItem In oDisks
        If Int(oItem.FreeSpace / 1024 / 1024 / 1024) > 1 Then 'check Free Disk Space
             If UCase(Left(oItem.DeviceID, 1)) = "C" Then sub_ExecQuery("c")
             If UCase(Left(oItem.DeviceID, 1)) = "D" Then sub_ExecQuery("d")
             If UCase(Left(oItem.DeviceID, 1)) = "E" Then sub_ExecQuery("e")
        End if
    Next
    
    Sub sub_ExecQuery(sDrive)
    Dim sWql                                 : sWql                            = "SELECT * FROM Win32_Directory WHERE (Drive='" & sDrive & ":') AND NOT Name like 'C:\\WINDOWS\\$Nt%' AND NOT Name='C:\\WINDOWS\\$hf_mig$' AND NOT Name='C:\\WINDOWS\\ie7' AND NOT Name='C:\\WINDOWS\\ie8'"
    Dim oFolder, oFolders     : Set oFolders       = oWMI.ExecQuery( sWql )
    Dim sResults                           : sResults             = ""
    
             For Each oFolder in oFolders
             If oFolder.compressed Then
                       sResults = oFolder.Uncompress()
                       If sResults = 0 Then 
                                sResults = oFolder.Caption & " Uncompressed."
                       Else
                                sResults = "!!! E R R O R !!!  to uncompress : " & oFolder.Caption
                       End If
                       sub_EditLog(sResults)
             End If
             Next
    End Sub
    
    Sub sub_EditLog(sTxt)
             If Not oFSO.FileExists(sLogFile) Then oFSO.CreateTextFile sLogFile, True
             
             Dim oFile                        : Set oFile             = oFSO.OpenTextFile(sLogFile, ForAppending)
             oFile.Write sTxt & vbCrLf
             oFile.Close
             
    End Sub


    • Upravený Salento9 10. května 2012 12:12
    •  
  • 10. května 2012 14:06
     
     

    I posted earlier that Uncompress will not uncompress files.

    See the documentation for other ,ethods for uncomptrssing files and folders.

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394130(v=vs.85).aspx

    You can get all children of the folder an uncompress each one separately.  On a large system this could take days.

    Using UnCompressEx will recurse all children but will not exclude anything.


    ¯\_(ツ)_/¯


  • 18. května 2012 0:30
    Moderátor
     
     

    As there has been no activity in this thread for a few days, we assume the issue is resolved. We will mark it as "answered" to assist others in similar situations. If you disagree, please reply with further information. You can unmark the answer if you wish. If a reply helped answer your question, please mark it as the answer.


    Richard Mueller - MVP Directory Services

  • 24. května 2012 13:30
     
      Obsahuje kód

    I posted earlier that Uncompress will not uncompress files.

    See the documentation for other ,ethods for uncomptrssing files and folders.

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394130(v=vs.85).aspx

    You can get all children of the folder an uncompress each one separately.  On a large system this could take days.

    Using UnCompressEx will recurse all children but will not exclude anything.


    ¯\_(ツ)_/¯

    Indeed seems to not uncompress file, but this script seems to works, for ex. if you compress a txt file in c:\windows it will be decompressed, strange... can you may test it?

    So i have to try it with powershell, or maybe is there a ready to use script that meet my need?

    Option Explicit
    'On Error Resume Next
    
    Const ForReading = 1
    Const ForWriting = 2
    Const ForAppending = 8
    
    Dim oFSO                                : Set oFSO            = CreateObject("Scripting.FileSystemObject")
    Dim oWMI                               : Set oWMI           = GetObject("winmgmts:\\.\root\cimv2")
    Dim sLogFile                            : sLogFile              = "c:\temp\Gind\decompress.log"
    
    sub_ExecQuery("c")
    sub_ExecQuery("d")
    sub_ExecQuery("e")
    
    Sub sub_ExecQuery(sDrive)
    Dim sWql                                 : sWql                            = "SELECT * FROM Win32_Directory WHERE (Drive='" & sDrive & ":') AND NOT Name like 'C:\\WINDOWS\\$Nt%' AND NOT Name='C:\\WINDOWS\\$hf_mig$' AND NOT Name='C:\\WINDOWS\\ie7' AND NOT Name='C:\\WINDOWS\\ie8'"
    Dim oFolder, oFolders     : Set oFolders       = oWMI.ExecQuery( sWql )
    Dim errResults
    
             For Each oFolder in oFolders
             errResults = oFolder.Uncompress()
             'Wscript.Echo oFolder.Caption
             sub_EditLog(errResults)
             Next  
    End Sub
    
    Sub sub_EditLog(sTxt)
             If Not oFSO.FileExists(sLogFile) Then oFSO.CreateTextFile sLogFile, True
             
             Dim oFile                        : Set oFile             = oFSO.OpenTextFile(sLogFile, ForAppending)
             oFile.Write sTxt & vbCrLf
             oFile.Close
             
    End Sub




    • Upravený Salento9 24. května 2012 13:49
    •  
  • 24. května 2012 15:00
     
      Obsahuje kód

    It doesn't matter whether you use VBScript or POwerSHell.  Uncompressing a folder will not uncompress the files.

    In PowerSHell try the following:

    $d=gwmi win32_directory -filter 'name="e:\\test2"'
    $d.UncompressEx('',$true)


    ¯\_(ツ)_/¯

  • 28. května 2012 10:30
     
      Obsahuje kód

    Hi,


    Thanks again for your help.


    A colleague of mine gave me the following script which works on attribute "c" of "childitem", all seems to works fine but it does nothing on e:\ drive on server win2003\64Bit (c:\ & d:\ ok) which is formatted as filesystem as c:\ & d:\  and on Windows7 exclusions not working,  can you please help me to found why wont work?  strange..


    $disks = get-psdrive -PSProvider filesystem
    
    foreach($disk in $disks) {
        if($disk.Name -ne 'A') {
            get-childitem -path ($disk.root) -Recurse | % {
                if($_.Name -contains "ie7updates") {}
                elseif($_.Name -contains "ie8updates") {}
                elseif($_.Name -contains "$NT") {}
                elseif($_.Name -contains "$hf_mig$") {}
                else {
                    $_.fullname
                    if($_.attributes -ilike "*Compressed*") {
                    $Drive = Get-PSDrive $disk
                        $free = $drive.free/1024/1024/1024
                        $fpath = $_.fullname
                    if($free -gt 2) {
                            iex "c:\windows\system32\compact.exe /u /S /F '$fpath'"
                        out-file -filepath 'c:\temp\decompress.log' -inputobject $fpath -Append
                        }
                    }
                }
            }
        }
    }



    • Upravený Salento9 28. května 2012 10:33
    •  
  • 28. května 2012 11:17
     
     

    Compress will only work on NTFS volumes.

    It is not clear why you are skipping those folders.  They should be uncompressed and can just be included.

    compress /u /s /f c: >>uncompress.log 

    is all you need to do.

    This files also only exeist on the boot drive.  You can just type a line for each volume. or just do this:

    get-psdrive -PSProvider filesystem | ?{$_.Used -ne 0}|%{compact /u /s /f /i "$($_.Root)/*" >> uncompress.log }

    This skips all drives that are not writable directly (A, CDROM/DVD) although 'compact' will process these drives and report 0 files within 0 directories were uncompressed and it will do this very quickly.

    So this is the same as the above code:

    get-psdrive -PSProvider filesystem | %{compact /u /s /f /i "$($_.Root)\*" >> uncompress.log }

    I added the /I arg because any error will terminate the compacting without it.

    The log created is very useful.

    What you should be skipping altogether is the C:|windows folder and all subfolders.

    The method posted will work for skipping folders if needed howver the compact statement will neeed the /I and it will not work on non NTFS volumes.

    This is what the compress log looks like:

     Uncompressing files in T:\dhcpapi\

    DHCPApi [OK]
    DHCPAPI.ps1 [OK]
    DHCPApi.pws [OK]
    Get-DHCPClients.ps1 [OK]

     Uncompressing files in T:\dhcpapi\DHCPApi\


     Uncompressing files in T:\dhcptest\

    DHCPManager.dll [OK]
    DHCPManager.pdb [OK]
    TestLib.exe [OK]
    TestLib.pdb [OK]

    ¯\_(ツ)_/¯