Advertisement
D0cEvil

PowerShell - Lab 2

Sep 23rd, 2022
106
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 1.40 KB | Cybersecurity | 1 0
  1. Start-Transcript -Path C:\_lab2_transcript.txt -NoClobber
  2.  
  3. #Outputting a command "Get-ChildItem" to a file "MyWinLogFile.txt"
  4. # -Filter *.log - file selection filter
  5.  
  6. Get-ChildItem -Path C:\Windows\ -Filter *.log | Out-File D:\MyWinLogFile.txt
  7.  
  8. #Displaying the contents of a file
  9.  
  10. Get-Content D:\MyWinLogFile.txt
  11.  
  12. #Adding results to a file "MyWinLogFile.txt"
  13.  
  14. Get-ChildItem -Path C:\Windows\System32 -Filter *.dll | Out-File D:\MyWinLogFile.txt -Append
  15.  
  16. #Displaying the contents of a file
  17.  
  18. Get-Content D:\MyWinLogFile.txt
  19.  
  20. #Renaming a file MyWinLogFile.txt to MyWinLogDLLFile.txt
  21.  
  22. Rename-Item -Path D:\MyWinLogFile.txt -NewName MyWinLogDLLFile.txt
  23.  
  24. #Create directory Lab2Output
  25.  
  26. New-Item -Path C:\Lab2Output -ItemType "directory"
  27.  
  28. #Copyng file D:\MyWinLogDLLFile.txt to directory C:\Lab2Output
  29.  
  30. Copy-Item "D:\MyWinLogDLLFile.txt" -Destination "C:\Lab2Output"
  31.  
  32. #Deleting file D:\MyWinLogDLLFile.txt
  33.  
  34. Remove-Item "D:\MyWinLogDLLFile.txt"
  35.  
  36. #Write a list of active processes to a file
  37. # -Append - adding new information to a file
  38.  
  39. Get-Process | Out-File C:\Lab2Output\MyWinLogDLLFile.txt -Append
  40.  
  41. #Renaming a file MyWinLogDLLFile.txt to MyWinLogDLLProcsFile.txt
  42.  
  43. Rename-Item -Path C:\Lab2Output\MyWinLogDLLFile.txt -NewName MyWinLogDLLProcsFile.txt
  44.  
  45. #Displaying the contents of a file MyWinLogDLLProcsFile.txt
  46.  
  47. Get-Content C:\Lab2Output\MyWinLogDLLProcsFile.txt | more
  48.  
  49. Stop-Transcript
  50.  
  51. #END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement