Software_Outlook_Backup_PST.ps1
|
function Outlook-BackupPST { param ( [string]$FileServerAddress ) $sourceDirectory = "C:\Outlook_Files" if (-Not (Test-Path -Path $sourceDirectory -PathType Container)) { Write-Host "Source directory '$sourceDirectory' does not exist." return } if (-not $FileServerAddress) { Write-Host "Please provide the file server address as a parameter." return } if (-not $FileServerAddress.EndsWith("\")) { $FileServerAddress += "\" } $pstFiles = Get-ChildItem -Path $sourceDirectory -Filter "*.pst" -File foreach ($pstFile in $pstFiles) { $destinationPath = Join-Path -Path $FileServerAddress -ChildPath $pstFile.Name Copy-Item -Path $pstFile.FullName -Destination $destinationPath -Force Write-Host "Copied $($pstFile.FullName) to $destinationPath" } Write-Host "Backup of .pst files completed." } |