PowerShell - File System

1 - Management

1.1 - Traverse

  • finds all .jpg files in the current user's directories
get-childitem -path $env:userprofile\* -include *.jpg -recurse

1.2 - Create

  • a file in the current directory
New-Item fileName.ext 
# in a dir with content
New-Item -Path C:\path -Name "testfile1.txt" -ItemType "file" -Value "This is a text string."
  • A directory
New-Item -ItemType Directory -Force -Path C:\Whatever

1.3 - Current Location

$loc = Get-Location
$loc = $pwd

See managing-current-location

1.4 - Rename

rename-item –path '.\.htaccess.dist' -newname '.\.htaccess'

2 - Documentation / Reference

lang/ps/fs.txt · Last modified: 2018/06/11 20:22 by gerardnico