I have developed the power shell to copy your data from one location to another location with the help of windows inbuilt ROBOCOPY utility.This logic help you to copy data from one location to another locations.
I Hope this will help you..
################################################################################
$Script:sScriptFolder = (Get-Item $($MyInvocation.MyCommand.Path)).DirectoryName
$Script:sSystemDrive = "$Env:SystemDrive"
$sVDIMSTName1 = Get-Content "c:\SWKSoftware\VDIComputers.txt"
$sgetDateTime = Get-Date -Format g
$strSourcePath = "C:\Temp\Dir1\" # Enter your source Dir path here
$sDestinationPath = "C:\Temp\Dir2\" # Enter your Destination Dir path here
If ((Test-Path -Path $strSourcePath) -AND (Test-Path -Path $sDestinationPath))
{
#Copy-Item "$strSourcePath\*.*" -Destination "$destinationPath" -Force -Recurse
$sScrParentFolder = split-Path -path $strSourcePath -Leaf
#$sgetDateTime = Get-Date -Format s
$sgetDateTime1 = $(get-date -f yyyyMMdd_HH-mm-ss)
$sDateTimeFolderName = $sScrParentFolder + "-" + $sgetDateTime1
$sDestinationPath = New-Item -ItemType Directory -Path "$sDestinationPath\$sDateTimeFolderName"
ROBOCOPY.EXE $strSourcePath $sDestinationPath /COPYALL /B /SEC /MIR /R:0 /W:0 /NFL /NDL
}
Else
{
Write-host " Source or Destination is not reachable or does not exist..."
}
################################################################################
Note:- Please test script in your test environment before running in production directly.
Note:- Please test script in your test environment before running in production directly.
No comments:
Post a Comment