# ============================================================================= # # NAME:DisplayFileMetaData.ps1 # # AUTHOR: Ed Wilson , microsoft # DATE : 11/10/2007 # # COMMENT: # Uses Params to allow modification of script at runtime # Uses funHelp function to display help # Uses funLine function to underline output # # ============================================================================= param( $folder, [switch]$whatif, [switch]$help, [switch]$examples, [switch]$min, [switch]$full ) #end param # Begin Functions function funHelp() { $descriptionText= ` @" NAME: DisplayFileMetaData.ps1 DESCRIPTION: Sample on a local or remote machine. PARAMETERS: -computer computer upon which to run the command -whatif Prototypes the command -help prints help description and parameters file -examples prints only help examples of syntax -full prints complete help information -min prints minimal help. Modifies -help "@ #end descriptionText $examplesText= ` @" SYNTAX: DisplayFileMetaData.ps1 Displays an error missing parameter, and calls help DisplayFileMetaData.ps1 -Folder "c:\fso" Displays meta data for each file in the c:\fso folder on the local machine DisplayFileMetaData.ps1 -Folder c:\fso,C:\fso1 Displays meta data for each file in the c:\fso folder and in the c:\fso1 folder on the local machine. note: quotation marks are not required around folder names DisplayFileMetaData.ps1 -strFolder "C:\fso" -whatif Displays what if: Perform operation display meta data for c:\fso folder DisplayFileMetaData.ps1 -help Prints the help topic for the script DisplayFileMetaData.ps1 -help -full Prints full help topic for the script DisplayFileMetaData.ps1 -help -examples Prints only the examples for the script DisplayFileMetaData.ps1 -examples Prints only the examples for the script "@ #end examplesText $remarks = ` " REMARKS For more information, type: $($MyInvocation.ScriptName) -help -full " #end remarks if($examples) { $examplesText ; $remarks ; exit } if($full) { $descriptionText; $examplesText ; exit } if($min) { $descriptionText ; exit } $descriptionText; $remarks exit } #end funHelp function function funline ( $strIN, $char = "=", $sColor = "Yellow", $uColor = "darkYellow", [switch]$help ) { if($help) { $local:helpText = ` @" Funline accepts inputs: -strIN for input string and -char for seperator -sColor for the string color, and -uColor for the underline color. Only the -strIn is required. The others have the following default values: -char: =, -sColor: Yellow, -uColor: darkYellow Example: funline -strIN "Hello world" funline -strIn "Morgen welt" -char "-" -sColor "blue" -uColor "yellow" funline -help "@ $local:helpText break } #end funline help $strLine= $char * $strIn.length Write-Host -ForegroundColor $sColor $strIN Write-Host -ForegroundColor $uColor $strLine } #end funLine function Function funWhatIf() { "what if: Perform operation display meta data for $Folder folder" exit } #end funWhatIf Function funMetaData() { foreach($sFolder in $folder) { $a = 0 $objShell = New-Object -ComObject Shell.Application $objFolder = $objShell.namespace($sFolder) foreach ($strFileName in $objFolder.items()) { FunLine( "$($strFileName.name)") for ($a ; $a -le 266; $a++) { if($objFolder.getDetailsOf($strFileName, $a)) { $hash += @{ ` $($objFolder.getDetailsOf($objFolder.items, $a)) =` $($objFolder.getDetailsOf($strFileName, $a)) } #end hash $hash $hash.clear() } #end if } #end for $a=0 } #end foreach } #end foreach } #end funMetadata # Entry Point if($help) { funhelp } if($examples) { funhelp } if($full) { funhelp } if($whatif) { funWhatIf } if($folder) { funMetaData } if(!$Folder) {"missing folder name..." ; funhelp }
kmichalo1