$PS1Path = “D:\Daten1”
$ShareUserName = “Daten1”
$PS1SharePath = “\\Worker\Daten1Backup”
$PSEventSourceName = “Mein Daten Backup”
if (![System.Diagnostics.Eventlog]::SourceExists($PSEventSourceName))
{
New-EventLog -LogName Application -Source $PSEventSourceName
}
if (-Not (Get-PSDrive -Name PS1Share -ErrorAction SilentlyContinue))
{
New-PSDrive -Name PS1Share -Root $PS1SharePath -PSProvider FileSystem -Credential $ShareUserName | Out-Null
}
Write-EventLog -LogName Application -Source $PSEventSourceName -EntryType Information -EventId 100 -Message “Backup wird gestartet.”
Write-Verbose -Message “Backup wird gestartet.”
$CopyResult = Get-ChildItem -Path $PS1Path -File -Include *.txt -Recurse | Copy-item -Destination PS1Share: -PassThru
Write-EventLog -LogName Application -Source $PSEventSourceName -EntryType Information -EventId 100 -Message “Backup wurde abgeschlossen – $($CopyResult.Count) Dateien wurden gesichert.”
Write-Verbose -Message “Backup wurde beendet”
$VerbosePreference = “SilentlyContinue”