Combreal

spoolit.ps1

Feb 7th, 2021 (edited)
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $date = Get-Date -Format "ddMMyyyy"
  2.  
  3. $files = Get-ChildItem "C:\Temp\spooler" | Where {! $_.PSIsContainer}
  4. ForEach ($file in $files)
  5. {
  6.     If($file.Name -Match $date)
  7.     {
  8.         wscript.exe $file.FullName
  9.     }
  10. }
  11.  
  12. #Scheduled Task :
  13. #schtasks.exe /CREATE /TN SpoolerCheck-SendMail01 /RU system /SC daily /ST 10:00:00 /TR "Powershell.exe D:\Documents\Scripts\spoolit.ps1"
  14.  
  15. #date-id.vbs
  16. #CreateAFile()
  17. #DiscardScript()
  18. #
  19. #Function CreateAFile
  20. #   Dim fso, MyFile
  21. #   Set fso = CreateObject("Scripting.FileSystemObject")
  22. #   Set MyFile = fso.CreateTextFile("C:\Temp\spooler\dummy.txt", True)
  23. #   MyFile.WriteLine("This is a test.")
  24. #   MyFile.Close
  25. #End Function
  26. #
  27. #Function DiscardScript()
  28. #    Set objFSO = CreateObject("Scripting.FileSystemObject")
  29. #    strScript = Wscript.ScriptFullName
  30. #    objFSO.DeleteFile(strScript)
  31. #End Function
Add Comment
Please, Sign In to add comment