Archive

Archive for July, 2010

Powershell – List Compressed Files/Folders

2010/07/20 Leave a comment

Source: http://stackoverflow.com/questions/1500114/powershell-wmi-and-compressed-files-folders

Powershell, WMI and compressed files/folders

Question:

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

Answer:
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.

Categories: Knowledge Tags: ,

RunAs + SystemRoot\system32 on a 64 Bits box

2010/07/01 Leave a comment

source:http://forums.techarena.in/windows-x64-edition/1189266.htm

Problem: From a 64bits machine (logged as a Domain User) i cannot run Qwsinta or Qprocess,… from a CMD (ran as Domain Admin)

Resolution:

 

When i launch cmd as admin (runas) i cannot find or use qwinsta qprocess rwinsta… even if im in %systemroot%\system32, here is the reason why:
“32-bit applications can access the native system directory by substituting
%windir%\Sysnative for %windir%\System32. WOW64 recognizes Sysnative as a
special alias used to indicate that the file system should not redirect the
access. The Sysnative is just a virtual directory, alias or pseudo-directory
that is not visible in Windows Explorer, directory listing, and does not
support native 64-bit processes that already been accessing the
%windir%\System32 folder. As such, Sysnative can only be used in file system
calls, and not in application’s user interface such as dialog box to open or
select folder.”