powershell_file_operations

Powershell File Operations

Example of searching for files with cmd

#search

cmd /r dir /s /b c:\tmp\*.xml
get-childitem .\ -recurse | where {$_.extension -eq ".txt"} | foreach-object {
     Write-Host $_.FullName
}

Delete file if exists and recreate it

$filename = "c:\tmp\webapp1.zip"; If (Test-Path $filename) {Remove-Item $filename}; Compress-Archive -Path .\* -DestinationPath c:\tmp\webapp1.zip
  • powershell_file_operations.txt
  • Last modified: 2022/02/23 17:45
  • by mgupton