# Funktion: speichert den aktuellen Pfad(vgl. pwd) in Get-ScriptDirectory function Get-ScriptDirectory { $Invocation = (Get-Variable MyInvocation -Scope 1).Value Split-Path $Invocation.MyCommand.Path } # Funktion: setze Timestamp, mit Rückgabewert function get-timestamp{ $timestamp = (get-date -Format yyyy_MM_dd__HH_mm_ss) return $timestamp } # restliche Variablen $timestamp = get-timestamp # Ruft Funktion get-timestamp auf $scriptpfad = Get-ScriptDirectory # setzt $scriptpfad auf den Wert von Get-ScriptDirectory # Hostname $hostname_ist = $env:computername $hostname_soll = "irantu" # Ziele/Quellen $quelle1 ="\\fileserver3.grote.lan\videos" $quelle1_name= "videos" $ziel1="$scriptpfad\backup\videos" # Hostname prüfen if ($hostname_ist -eq $hostname_soll) { Write-Host "Host = $hostname_ist" } else { Write-Host "Falscher Host(SOLL: '$hostname_soll' IST:$hostname_ist)" start-sleep 5 Exit 1 } # logs Ordner erstellen If(!(test-path $scriptpfad\logs)) { New-Item -ItemType Directory -Force -Path $scriptpfad\logs } robocopy $quelle1 $ziel1 /MIR /R:3 /W:10 /DST /TEE /UNILOG+:"$scriptpfad\logs\$timestamp-$quelle1_name.log"