SHARE
TWEET

helloworld_final.ps1

a guest Sep 30th, 2014 261 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. .DESCRIPTION
  3.     My first script
  4.  
  5.     AUTHOR
  6.     Ben0xA
  7. .SYNOPSIS
  8.     This is my first script that I am writing at DerbyCon
  9.  
  10. .EXAMPLE
  11.     .\hellowworld.ps1
  12.  
  13. #>
  14. $files = Get-ChildItem "C:\psf" -Recurse
  15. $list = @()
  16.  
  17. #check to see if we have any files before we begin to work with them.
  18. if($files -ne $null) {
  19.     #loop over each file and check the LastWriteTime
  20.     ForEach($file in $files) {
  21.         if($file.LastWriteTime -ge "6/1/2014 00:00 AM" -and $file.LastWriteTime -le "6/30/2014 11:59 PM") {
  22.             #add the full path to the file to the $list array.
  23.             $list += $file.FullName
  24.         }
  25.     }
  26.  
  27.     if($list -ne $null -and $list.Length -gt 0) {
  28.         Write-Output $list
  29.     }
  30.     else {
  31.         Write-Output "No files were found matching that criteria."
  32.     }
  33. }
  34. else {
  35.     Write-Output "No files were found."
  36. }
RAW Paste Data
Pastebin PRO Autumn Special!
Get 40% OFF on Pastebin PRO accounts!
Top