0

I need to generate a script that will help me in getting a list of compressed files/folders (not zip files, but Windows compressed files) on a range of Windows 2003 servers. I have a client pc connected to the target servers and have access on a administrator role basis. My thoughts was to create a Powershell script to handle this problem using WMI or something else? But I'm kind of lost on the possibilities in the WMI world. Any hints/tips are appreciated.

Cheers

user155814
  • 101
  • 1
  • 9
  • I don't know how to flag such a file or folder. Keep in mind here, if you're planning to use WMI to scan systems, this will likely be very slow. – Marco Shaw Oct 01 '09 at 01:50

1 Answers1

1

I'm not sure if you can do that with WMI, then again I'm no WMI guru. If you can use PowerShell 2.0 this is pretty simple using the new remoting feature e.g.

$computers = 'server1', 'server2', 'server3'
$compressed = Invoke-Command $computers {Get-ChildItem C:\ -r -force -ea 0 | 
                 Where {$_.Attributes -band [IO.FileAttributes]::Compressed}}

Note that each file and dir object stored in $compressed will have an additional property PSComputerName that identifies which computer the deserialized object came from.

Alternatively, if you don't have PowerShell 2.0 you could access the servers via a share e.g.:

$sharePaths = '\\server1\C$', '\\server2\C$', '\\server3\C$'
Get-ChildItem $sharePaths  -r -force -ea 0 | 
    Where {$_.Attributes -band [IO.FileAttributes]::Compressed}

This approach is likely to be slow.

Keith Hill
  • 194,368
  • 42
  • 353
  • 369
  • Keith: Very nice solution, but I can see that I need to install Powershell 2.0 on all target servers, and I'm not sure that this is an option right now – user155814 Oct 01 '09 at 07:23
  • True, I guess you could run the command without using the Invoke-Command cmdlets and use UNC paths instead (C$) but that would probably be pretty slow. – Keith Hill Oct 01 '09 at 14:08