Aklımda Kalası Kelimeler

* давайте работать вместе
* Zarf ve Mazruf, Zerafet(xHoyratlık) ile aynı kökten(za-ra-fe) gelir
* Bedesten
* Suç subuta ermiştir - Suç sabit olmuştur
Copy-Item etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Copy-Item etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

9 Eylül 2014 Salı

Powershell ile dosya kopyalama

Niyetim SAP nin xml olarak attığı uzak sunucu dosyalarını iis sunucusuna almak
Powershell dosyası şöyle:

$source =  "C:\Temp\"
$dest = "C:\Temp\Dest\"
$kopyalanacakDosyalar = "*.xml"

Write-Host  "Kaynak Dizin => " $source
Write-Host  "Hedef Dizin => " $dest
Write-Host  "Kopyalanacak Dosyalar => " $kopyalanacakDosyalar

$TestPath = Test-Path $dest
IF (!$TestPath) {
 
 Write-Host "Hedef dizin mevcut degil"
 Copy-Item $source $dest -Verbose
 PC1 - no file found. Copying

} ELSE {

 Write-Host "Hedef mevcut dosyalar taranarak hedefte olmayan kopyalanacak"
 
 $files = (Get-ChildItem $source -recurse -filter $kopyalanacakDosyalar | where-object {-not ($_.PSIsContainer) -AND $_.lastwritetime -gt (get-date).addminutes(-10)});
 
 $files|foreach($_){
  if (!([system.io.file]::Exists($dest+$_.name))){
            cp $_.Fullname ($dest+$_.name)
  };
 }
}