-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoboCopy.ps1
98 lines (67 loc) · 4.03 KB
/
RoboCopy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
net use \\100.64.206.13\d$ /user:100.64.206.13\Administrator *
$logfile = "{0}\desktop\robocopy_{1}_.log" -f $env:USERPROFILE,$((get-date).tostring('ddmmyyThhMM'))
robocopy \\100.64.206.13\d$ d:\ /NOOFFLOAD /LOG:$logfile /ZB /Z /B /J /MT:16 /V
net use \\100.64.206.13\d$ /delete
$logfile = "{0}\desktop\robocopy_{1}_.log" -f $env:USERPROFILE,$((get-date).tostring('ddmmyyThhMM'))
$source = '\\100.64.206.13\d$'
$destination = 'd:\'
#Clear directory:
Get-ChildItem d:\ -Recurse | Remove-Item -Force
#Create 100GB as 1 file
$filestr = "D:\TestFile";$file = [io.file]::Create($filestr);$file.SetLength(50gb);$file.close()
#Create 100GB split into 10GB Files
1..10 | ForEach-Object{$filestr = "d:\10GBtest_$_";$file = [io.file]::Create($filestr);$file.SetLength(10gb);$file.close()}
#Create 100GB split into 1GB Files
1..20 | ForEach-Object{$filestr = "d:\1GBtest_$_";$file = [io.file]::Create($filestr);$file.SetLength(1gb);$file.close()}
#Define Variables first
$logfile = "{0}\desktop\robocopy_{1}_.log" -f $env:USERPROFILE,$((get-date).tostring('ddmmyyThhMM'))
$source = '\\100.64.206.13\d$'
$user = '100.64.206.13\Administrator'
$destination = 'd:\'
#Open File Share between servers:
Invoke-Expression ( "net use {0} /user:{1} *" -f $source,$user)
#Copy Command
Invoke-Expression ( "robocopy {0} {1} /tee /LOG:{2} /NOOFFLOAD /ZB /Z /B /J /MT:20 /V /ETA /R:5 /W:5" -f $source,$destination,$logfile )
#Close File share:
Invoke-Expression ( "net use {0} /delete" -f $source)
########################################
########################################
########################################
########################################
#Local File Transfer
$logfile = "{0}\desktop\robocopy_{1}_.log" -f $env:USERPROFILE,$((get-date).tostring('ddmmyyThhMM'))
$source = 'D:\Folder1'
$destination = 'D:\Folder2'
Invoke-Expression ( "robocopy {0} {1} /tee /LOG:{2} /NOOFFLOAD /ZB /Z /B /J /MT:20 /V /ETA /R:5 /W:5" -f $source,$destination,$logfile )
#Transfer from source:gen4phx1 to destination:gen34vm1 via L2L. Initiated from gen34vm1
$logfile = "{0}\desktop\robocopy_{1}_.log" -f $env:USERPROFILE,$((get-date).tostring('ddmmyyThhMM'))
$source = '\\100.64.206.13\d$'
$user = '100.64.206.13\Administrator'
$destination = 'd:\'
Invoke-Expression ( "net use {0} /user:{1} *" -f $source,$user)
Invoke-Expression ( "robocopy {0} {1} /tee /LOG:{2} /NOOFFLOAD /ZB /Z /B /J /MT:20 /V /ETA /R:5 /W:5" -f $source,$destination,$logfile )
Invoke-Expression ( "net use {0} /delete" -f $source)
#Transfer from source:gen4phx1 to destination:gen34vm1 via L2L. Initiated from gen4phx1
$logfile = "{0}\desktop\robocopy_{1}_.log" -f $env:USERPROFILE,$((get-date).tostring('ddmmyyThhMM'))
$source = 'd:\'
$user = '100.64.164.45\Administrator'
$destination = '\\100.64.164.45\d$'
Invoke-Expression ( "net use {0} /user:{1} *" -f $destination,$user)
Invoke-Expression ( "robocopy {0} {1} /tee /LOG:{2} /NOOFFLOAD /ZB /Z /B /J /MT:20 /V /ETA /R:5 /W:5" -f $source,$destination,$logfile )
Invoke-Expression ( "net use {0} /delete" -f $destination )
#Transfer from Source:gen34vm1 to destination:gen4phx1 via L2L. Initiated from gen4phx1
$logfile = "{0}\desktop\robocopy_{1}_.log" -f $env:USERPROFILE,$((get-date).tostring('ddmmyyThhMM'))
$destination = 'd:\'
$user = '100.64.164.45\Administrator'
$source = '\\100.64.164.45\d$'
Invoke-Expression ( "net use {0} /user:{1} *" -f $source,$user)
Invoke-Expression ( "robocopy {0} {1} /tee /LOG:{2} /NOOFFLOAD /ZB /Z /B /J /MT:20 /V /ETA /R:5 /W:5" -f $source,$destination,$logfile )
Invoke-Expression ( "net use {0} /delete" -f $source)
#Transfer from Source:gen34vm1 to destination:gen4phx1 via NAT. Initiated from gen4phx1
$logfile = "{0}\desktop\robocopy_{1}_.log" -f $env:USERPROFILE,$((get-date).tostring('ddmmyyThhMM'))
$destination = 'd:\'
$user = '147.75.0.100\Administrator'
$source = '\\147.75.0.100\d$'
Invoke-Expression ( "net use {0} /user:{1} *" -f $source,$user)
Invoke-Expression ( "robocopy {0} {1} /tee /LOG:{2} /NOOFFLOAD /ZB /Z /B /J /MT:20 /V /ETA /R:5 /W:5" -f $source,$destination,$logfile )
Invoke-Expression ( "net use {0} /delete" -f $source)