Hi @Rafael Aguilar ,
maybe this helps:
$filename = "filename.txt"
$sourcefolder = "\\networkpath\share"
$targetfolder = "C:\Windows\PolicyDefinitions"
$logfile = "c:\junk\copyfilelog.txt"
if (Test-Path -Path "$targetfolder\$filename" -PathType Leaf) {
Write-Output "File $filename exists in folder $targetfolder"
Out-File -FilePath $logfile -Encoding utf8 -Append -InputObject "File exists in folder"
}
else {
Copy-Item -Path "$sourcefolder\$filename" -Destination $targetfolder
Write-Output "File copied to folder"
}
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten