mardi 10 décembre 2019

powershell if condition to check multiple files are available

I want copy files only if all files are available in the directory. In this case i want check this in a if condition. It dont work.

$File1 = "C:\Users\xx\Desktop\test\1.txt"
$File2 = "C:\Users\xx\Desktop\test\2.txt"
$Ziel = "C:\Users\xx\Desktop\test\a"


if(Test-Path -Path $File1 -and Test-Path -Path $File2)
{
    Move-Item -Path $File1 -Destination $Ziel
    Move-Item -Path $File2 -Destination $Ziel
}

Aucun commentaire:

Enregistrer un commentaire