92 lines
1.5 KiB
PowerShell
92 lines
1.5 KiB
PowerShell
Set-Variable -Name SourcePath -Value "E:\EDMServiceDebug" -Force
|
|
Set-Variable -Name DestinationsPath -Value "D:\ProgramFiles\Digital Data\SERVICES\EDM_SERVICE" -Force
|
|
Set-Variable -Name ServiceName -Value "Digital Data EDM Service" -Force
|
|
|
|
IF ($SourcePath -and $DestinationsPath -and $ServiceName) {
|
|
|
|
TRY {
|
|
|
|
$Items = Get-ChildItem -Path $SourcePath -Exclude "*.db, desktop.ini"
|
|
|
|
} #end try
|
|
|
|
CATCH {
|
|
|
|
Write-Host "Error getting SourcePath content!"
|
|
|
|
} #end catch
|
|
|
|
IF ($Items.count -gt 0) {
|
|
|
|
Write-Host "Found $($Items.count) File(s)"
|
|
Write-Host "Stopping Service: $ServiceName"
|
|
|
|
TRY {
|
|
|
|
Stop-Service -Name $ServiceName -Force
|
|
|
|
} #end try
|
|
|
|
CATCH {
|
|
|
|
Write-Host "Service could not be stopped"
|
|
pause
|
|
break
|
|
|
|
}#end catch
|
|
|
|
FOREACH ($Item in $Items) {
|
|
|
|
TRY {
|
|
|
|
$Item | Move-Item -Destination $DestinationsPath -Force -ErrorAction Stop
|
|
Write-Host "Moved File: $($Item.name)"
|
|
|
|
} #end try
|
|
|
|
CATCH {
|
|
|
|
Write-Host "Error moving File: $($Item.name)"
|
|
pause
|
|
|
|
} #end catch
|
|
|
|
} #end foreach
|
|
|
|
TRY {
|
|
|
|
Start-Service -Name $ServiceName
|
|
|
|
} #end try
|
|
|
|
CATCH {
|
|
|
|
Write-Host "Service could not be started"
|
|
pause
|
|
break
|
|
|
|
}#end catch
|
|
|
|
Start-Sleep 3
|
|
|
|
} #end if
|
|
|
|
ELSE {
|
|
|
|
Write-Host "No Files to Process!"
|
|
pause
|
|
|
|
} #end else
|
|
|
|
} #end if
|
|
|
|
ELSE {
|
|
|
|
Write-Host "Missing Values!"
|
|
pause
|
|
|
|
} #end else
|
|
|
|
Remove-Variable $SourcePath
|
|
Remove-Variable $DestinationsPath
|
|
Remove-Variable $ServiceName |