[PowerShell] Get-DetailsOf - Die erweiterten Eigenschaften von Dateien ausgeben

DPXone

Lieutenant
Registriert
Mai 2009
Beiträge
552
Hi,

hier heute nochmal eine Funktion ;) , um die erweiterten Dateieigenschaften von Dateien auszugeben.
Selbst der Explorer zeigt ja bei RECHTSKLICK -> Eigenschaften nicht alles Details an.

PS:
Das Ganze gibt's von mir auch als Kontextmenü-Option via VB.Net, bei Interesse (Computerbase exklusiv; ist kein Tool das ich verbreite oder vermarkten will; entstand aus privaten und beruflichen Grünen meinerseits).
Siehe OneDrive-Link hier:
https://www.computerbase.de/forum/threads/exel-vba-getdetailsof.1723354/#post-20652641

PowerShell:
Function Get-DetailsOf { 
	[CmdletBinding()] 
	Param (
		[Parameter(Mandatory = $true , 
			ValueFromPipeline = $true , 
			ValueFromPipelineByPropertyName = $true , 
			ValueFromRemainingArguments = $false , 
			Position = 0)] 
		[string[]] $FullName , 
		
		[Parameter(Position = 1)] 
		[switch] $SingleOutput = $false 
	) 
	
	
	Begin { 
		$objShell = New-Object -ComObject Shell.Application 
		$Results = @() 
	} 
	
	Process { 
		Foreach ($Path In $FullName) { 
			$Result = @() 
			$FSItem = get-item $Path 
			
			If ($FSItem -is [System.IO.FileInfo]) { 
				$FolderPath = [System.IO.Path]::GetDirectoryName($FSItem.FullName) 
				$FileName = $FSItem.Name 
				
				$objFolder = $objShell.namespace($FolderPath) 
				$obJFolderItem = $objFolder.ParseName($FileName) 
				
				For ($attr = 0 ; $attr -le 2000 ; $attr++) { 
					$attrName = $objFolder.getDetailsOf($null , $attr) 
					$attrValue = $objFolder.getDetailsOf($obJFolderItem , $attr) 
					
					If ($attrValue) { 
						$Result+= New-Object psobject -Property([ordered] @{ ID = $attr ; Name = $attrName ; Value = $attrValue }) 
					} 
				} 
				If ($SingleOutput) { 
					$Result 
				} Else { 
					$Results+= New-Object psobject -Property([ordered] @{ Fullname = $FSItem.FullName ; Details = $Result | Sort ID }) 
				} 
			} 
		} 
	} 
	
	End { 
		If (-not $SingleOutput) { 
			$Results 
		} 
	} 
} 



# Beispiel:      

'C:\Windows\regedit.exe' | Get-DetailsOf -SingleOutput | Out-String # Mit '-SingleOutput', um bei einzelnen Dateien die Attribute einzeln als Liste auszugeben      
Get-ChildItem 'C:\Windows\' | Get-DetailsOf # Ohne '-SingleOutput', um alles in einer Hashtabelle auszugeben und im Anschluss auf die Objekte einzeln zugreifen zu können



Ausgabe:
Code:
ID Name             Value                                        
 -- ----             -----                                        
  0 Name             regedit.exe                                  
  1 Size             328 KB                                       
  2 Item type        Application                                  
  3 Date modified    29.09.2017 15:41                             
  4 Date created     29.09.2017 15:42                             
  5 Date accessed    29.09.2017 15:42                             
  6 Attributes       A                                            
  9 Perceived type   Application                                  
 10 Owner            TrustedInstaller                             
 11 Kind             Program                                      
 19 Rating           Unrated                                      
 25 Copyright        © Microsoft Corporation. All rights reserved.
 33 Company          Microsoft Corporation                        
 34 File description Registry Editor                              
 52 Total size       428 GB                                       
 56 Computer         SVEN-PC (this PC)                            
159 File extension   .exe                                         
160 Filename         regedit.exe                                  
161 File version     10.0.16299.15                                
164 Space free       179 GB                                       
182 Shared           No                                           
185 Folder name      Windows                                      
186 Folder path      C:\Windows                                   
187 Folder           Windows (C:)                                 
189 Path             C:\Windows\regedit.exe                       
191 Type             Application                                  
194 Language         English (United States)                      
197 Link status      Unresolved                                   
249 Space used       ‎58%                                         
290 Sharing status   Not shared                                   
291                  Available                                    
292 Product name     Microsoft® Windows® Operating System         
293 Product version  10.0.16299.15                                




Fullname                                    Details                                                                                                                                                                                                   
--------                                    -------                                                                                                                                                                                                   
C:\Windows\bfsvc.exe                        {@{ID=0; Name=Name; Value=bfsvc.exe}, @{ID=1; Name=Size; Value=64,0 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=29.09.2017 15:41}...}                              
C:\Windows\bootstat.dat                     {@{ID=0; Name=Name; Value=bootstat.dat}, @{ID=1; Name=Size; Value=66,0 KB}, @{ID=2; Name=Item type; Value=DAT File}, @{ID=3; Name=Date modified; Value=18.12.2017 19:08}...}                              
C:\Windows\comsetup.log                     {@{ID=0; Name=Name; Value=comsetup.log}, @{ID=1; Name=Size; Value=20,2 KB}, @{ID=2; Name=Item type; Value=LOG File}, @{ID=3; Name=Date modified; Value=19.10.2017 20:53}...}                              
C:\Windows\DfsrAdmin.exe                    {@{ID=0; Name=Name; Value=DfsrAdmin.exe}, @{ID=1; Name=Size; Value=227 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=28.09.2017 01:43}...}                           
C:\Windows\DfsrAdmin.exe.config             {@{ID=0; Name=Name; Value=DfsrAdmin.exe.config}, @{ID=1; Name=Size; Value=1,28 KB}, @{ID=2; Name=Item type; Value=XML Configuration File}, @{ID=3; Name=Date modified; Value=20.10.2017 17:46}...}        
C:\Windows\diagerr.xml                      {@{ID=0; Name=Name; Value=diagerr.xml}, @{ID=1; Name=Size; Value=7,44 KB}, @{ID=2; Name=Item type; Value=XML File}, @{ID=3; Name=Date modified; Value=19.10.2017 20:54}...}                               
C:\Windows\diagwrn.xml                      {@{ID=0; Name=Name; Value=diagwrn.xml}, @{ID=1; Name=Size; Value=7,44 KB}, @{ID=2; Name=Item type; Value=XML File}, @{ID=3; Name=Date modified; Value=19.10.2017 20:54}...}                               
C:\Windows\DirectX.log                      {@{ID=0; Name=Name; Value=DirectX.log}, @{ID=1; Name=Size; Value=473 KB}, @{ID=2; Name=Item type; Value=LOG File}, @{ID=3; Name=Date modified; Value=01.07.2017 10:25}...}                                
C:\Windows\DPINST.LOG                       {@{ID=0; Name=Name; Value=DPINST.LOG}, @{ID=1; Name=Size; Value=28,4 KB}, @{ID=2; Name=Item type; Value=LOG File}, @{ID=3; Name=Date modified; Value=29.07.2017 13:40}...}                                
C:\Windows\DtcInstall.log                   {@{ID=0; Name=Name; Value=DtcInstall.log}, @{ID=1; Name=Size; Value=4,07 KB}, @{ID=2; Name=Item type; Value=LOG File}, @{ID=3; Name=Date modified; Value=19.10.2017 20:51}...}                            
C:\Windows\explorer.exe                     {@{ID=0; Name=Name; Value=explorer.exe}, @{ID=1; Name=Size; Value=3,72 MB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=08.12.2017 00:27}...}                           
C:\Windows\HelpPane.exe                     {@{ID=0; Name=Name; Value=HelpPane.exe}, @{ID=1; Name=Size; Value=954 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=29.09.2017 15:41}...}                            
C:\Windows\hh.exe                           {@{ID=0; Name=Name; Value=hh.exe}, @{ID=1; Name=Size; Value=17,5 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=29.09.2017 15:41}...}                                 
C:\Windows\mib.bin                          {@{ID=0; Name=Name; Value=mib.bin}, @{ID=1; Name=Size; Value=42,1 KB}, @{ID=2; Name=Item type; Value=BIN File}, @{ID=3; Name=Date modified; Value=29.09.2017 15:42}...}                                   
C:\Windows\notepad.exe                      {@{ID=0; Name=Name; Value=notepad.exe}, @{ID=1; Name=Size; Value=241 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=29.09.2017 15:41}...}                             
C:\Windows\NvContainerRecovery.bat          {@{ID=0; Name=Name; Value=NvContainerRecovery.bat}, @{ID=1; Name=Size; Value=1,90 KB}, @{ID=2; Name=Item type; Value=Windows Batch File}, @{ID=3; Name=Date modified; Value=27.10.2017 18:36}...}         
C:\Windows\NvTelemetryContainerRecovery.bat {@{ID=0; Name=Name; Value=NvTelemetryContainerRecovery.bat}, @{ID=1; Name=Size; Value=1,90 KB}, @{ID=2; Name=Item type; Value=Windows Batch File}, @{ID=3; Name=Date modified; Value=11.10.2017 01:26}...}
C:\Windows\PFRO.log                         {@{ID=0; Name=Name; Value=PFRO.log}, @{ID=1; Name=Size; Value=328 KB}, @{ID=2; Name=Item type; Value=LOG File}, @{ID=3; Name=Date modified; Value=02.12.2017 18:02}...}                                   
C:\Windows\Professional.xml                 {@{ID=0; Name=Name; Value=Professional.xml}, @{ID=1; Name=Size; Value=34,6 KB}, @{ID=2; Name=Item type; Value=XML File}, @{ID=3; Name=Date modified; Value=29.09.2017 15:43}...}                          
C:\Windows\regedit.exe                      {@{ID=0; Name=Name; Value=regedit.exe}, @{ID=1; Name=Size; Value=328 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=29.09.2017 15:41}...}                             
C:\Windows\Setup1.exe                       {@{ID=0; Name=Name; Value=Setup1.exe}, @{ID=1; Name=Size; Value=328 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=01.06.2016 11:03}...}                              
C:\Windows\setuperr.log                     {@{ID=0; Name=Name; Value=setuperr.log}, @{ID=1; Name=Size; Value=0 bytes}, @{ID=2; Name=Item type; Value=LOG File}, @{ID=3; Name=Date modified; Value=19.10.2017 20:48}...}                              
C:\Windows\splwow64.exe                     {@{ID=0; Name=Name; Value=splwow64.exe}, @{ID=1; Name=Size; Value=127 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=29.09.2017 15:42}...}                            
C:\Windows\ST6UNST.EXE                      {@{ID=0; Name=Name; Value=ST6UNST.EXE}, @{ID=1; Name=Size; Value=73,0 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=01.06.2016 11:03}...}                            
C:\Windows\system.ini                       {@{ID=0; Name=Name; Value=system.ini}, @{ID=1; Name=Size; Value=219 bytes}, @{ID=2; Name=Item type; Value=INI File}, @{ID=3; Name=Date modified; Value=30.10.2015 08:21}...}                              
C:\Windows\twain_32.dll                     {@{ID=0; Name=Name; Value=twain_32.dll}, @{ID=1; Name=Size; Value=64,0 KB}, @{ID=2; Name=Item type; Value=Application extension}, @{ID=3; Name=Date modified; Value=29.09.2017 15:42}...}                 
C:\Windows\win.ini                          {@{ID=0; Name=Name; Value=win.ini}, @{ID=1; Name=Size; Value=92 bytes}, @{ID=2; Name=Item type; Value=INI File}, @{ID=3; Name=Date modified; Value=30.10.2015 08:21}...}                                  
C:\Windows\WindowsUpdate.log                {@{ID=0; Name=Name; Value=WindowsUpdate.log}, @{ID=1; Name=Size; Value=276 bytes}, @{ID=2; Name=Item type; Value=LOG File}, @{ID=3; Name=Date modified; Value=18.12.2017 21:06}...}                       
C:\Windows\winhlp32.exe                     {@{ID=0; Name=Name; Value=winhlp32.exe}, @{ID=1; Name=Size; Value=11,5 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=29.09.2017 15:42}...}                           
C:\Windows\WMSysPr9.prx                     {@{ID=0; Name=Name; Value=WMSysPr9.prx}, @{ID=1; Name=Size; Value=309 KB}, @{ID=2; Name=Item type; Value=PRX File}, @{ID=3; Name=Date modified; Value=29.09.2017 15:41}...}                               
C:\Windows\write.exe                        {@{ID=0; Name=Name; Value=write.exe}, @{ID=1; Name=Size; Value=11,0 KB}, @{ID=2; Name=Item type; Value=Application}, @{ID=3; Name=Date modified; Value=29.09.2017 15:41}...}                              
C:\Windows\xhunter1.sys                     {@{ID=0; Name=Name; Value=xhunter1.sys}, @{ID=1; Name=Size; Value=37,4 KB}, @{ID=2; Name=Item type; Value=System file}, @{ID=3; Name=Date modified; Value=12.06.2017 19:14}...}
 
Zuletzt bearbeitet:
Zurück
Oben