# The Get-Command cmdlet can return information not only # about cmdlets but other applications and scripts that # PowerShell "knows" about. This month I have as PowerShell # oneliner that uses Get-Command to find all PowerShell # scripts in any folder in your path. Using a series of # Select-Object expressions, the oneliner displays the # script name, location, its size, when it was created, # when it was last modified and the status of its # digital signture. You do sign your production scripts # don't you? I'm sorting the output by folder and size # but you may have other uses for this information. # DISCLAIMER AND WARNING: # THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY # KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. # TEST THOROUGHLY IN A NON-PRODUCTION ENVIRONMENT. IF YOU DON'T KNOW WHAT THIS # SCRIPT WILL DO...DO NOT RUN IT! # Technically this is a one line command but I've # split it for legibility. Get-Command -commandtype externalscript | select Name,@{name="Folder";expression={ Split-Path $_.definition -parent}},@{ name="Size";Expression={ (Get-ChildItem $_.definition).length}},@{ name="Created";Expression={ (get-childitem $_.definition).CreationTime}},@{ name="Modified";Expression={ (get-childitem $_.definition).LastWriteTime}},@{ name="Signature";Expression={ (Get-AuthenticodeSignature $_.definition).Status }} | Sort Folder,Size #sample output # Name : Initialize-VIToolkitEnvironment.ps1 # Folder : C:\Program Files (x86)\VMware\Infrastructure\VIToolkitForWindows\Scripts # Size : 7749 # Created : 1/20/2009 9:01:34 PM # Modified : 1/20/2009 9:01:34 PM # Signature : Valid