Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. # Setting path in environment variable
  2. $PATH = [Environment]::GetEnvironmentVariable("PATH")
  3. echo $PATH
  4. $app_path = "…"
  5. [Environment]::SetEnvironmentVariable("PATH", "$PATH;$winrar_path", "Machine")
  6.  
  7. # List files in descending order of their sizes
  8. PS C:\Users\...\scratch> Get-ChildItem -recurse | Select-Object Name, @{Name=MegaBytes”;Expression={$_.Length / 1MB}} | Sort -Descending -Property "MegaBytes"
  9.  
  10. # Download a file (wget alternative)
  11. Start-BitsTransfer -Source $url -Destination $output
  12.  
  13. # Unzip a file using Winrar
  14. winrar x .\ph-export--2016.tar.gz
  15.  
  16. # Show the contents of a file
  17. Get-Content file_name
  18.  
  19. # Count number of lines
  20. Get-Content .\xyz.csv | Measure-Object -Line
  21.  
  22. # Reload environment variables
  23. refreshenv
  24.  
  25. # Find number of lines for all files in a directory
  26. Get-ChildItem *.csv | ForEach-Object { Get-Content$_.FullName | Measure-Object -Line } | Format-Wide -Property Lines
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement