Posted on

Powershell if statement syntax:

   1: If (condition) {statement}

Example 1 – Checking file or directory existence and copying file if it is exists

   1: $iis ="C:\logs\test.log"
   2: $file = "\\netshare\destination.log"
   3: if(Test-Path $iis){ Copy-Item $iis $file -force}