Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

PowerShell – Find a file

Posted on October 10, 2019 By David Kittell

If you run into a need to find a file on your computer/server this script should help make things a bit easier

Get-ChildItem -Path f:\ -Filter 2019-10-07.log -Recurse -ErrorAction SilentlyContinue -Force
Function Format-FileSize() {
    Param ([int]$size)
    If ($size -gt 1TB) { [string]::Format("{0:0.00} TB", $size / 1TB) }
    ElseIf ($size -gt 1GB) { [string]::Format("{0:0.00} GB", $size / 1GB) }
    ElseIf ($size -gt 1MB) { [string]::Format("{0:0.00} MB", $size / 1MB) }
    ElseIf ($size -gt 1KB) { [string]::Format("{0:0.00} kB", $size / 1KB) }
    ElseIf ($size -gt 0) { [string]::Format("{0:0.00} B", $size) }
    Else { "" }
}

$PathToSearch = "F:\"
$FileToSearch = "2019-10-07.log"
Get-ChildItem -Path $PathToSearch -Filter $FileToSearch -Recurse -ErrorAction SilentlyContinue -Force |
    Format-Table -AutoSize `
        @{expression = { $_.Name }; label = "File Name"; },
        @{Expression = { (Format-FileSize $_.Length) }; Label = "File Size" },
        @{expression = { $_.FullName }; label = "File Path"; },
        @{expression = { $_.LastWriteTime }; label = "Last Modified"; }
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code PowerShell Windows Windows Server

Post navigation

Previous post
Next post

Related Posts

Droid Razr (XT912) Bloat Removal Script

Posted on March 17, 2014October 26, 2015

Must have ROOT on your phone. Disclaimer holds strong for this script. If you do not know what it means to delete a system app do not even try this script. #!/system/bin/sh echo "" echo "——————————————————" echo "" echo " Bloat Removal for DROID RAZR XT912" echo "" echo "…

Read More

Format Date Function

Posted on July 31, 2013October 26, 2015

IF OBJECT_ID(N’dbo.fnFormatDate’) IS NOT NULL DROP FUNCTION dbo.fnFormatDate GO CREATE FUNCTION dbo.fnFormatDate ( @MyDate DATETIME ,@Format NVARCHAR(50) ,@LANGUAGE INT = NULL ) RETURNS NVARCHAR(255) AS BEGIN /* SELECT dbo.fnFormatDate(GetDate(), ‘MMMM DDDD DD, YYYY HH:NN:SS AMPM’, NULL) –October Friday 03, 2013 00:13:28 PM SELECT dbo.fnFormatDate(GetDate(), ‘MMMM DDDD DD, YYYY HH:NN:SS AMPM’,…

Read More

UNIX – SED Replace Tab with Space(s)

Posted on December 20, 2017

sed ‘s/\t/ /g’ tab-file.txt > no-tab-file.txt Originally found at https://linuxconfig.org/replace-all-tab-characters-with-spaces All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
©2025 David Kittell | WordPress Theme by SuperbThemes