-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCopy-SDK.ps1
30 lines (27 loc) · 839 Bytes
/
Copy-SDK.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
# TODO: use robocopy instead of Copy-Item for efficiency
function Copy-SDK {
param(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]
$Source,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]
$Destination
)
Write-Output "Copying SDK from $Source to $Destination"
if (-not (Test-Path $Source)) {
throw "Source path not found: $Source"
}
if (-not (Test-Path $Destination)) {
New-Item -Path $Destination -ItemType Directory
}
$capturedErrors = @()
Copy-Item -Path $Source -Destination $Destination -Recurse -ErrorAction SilentlyContinue -ErrorVariable capturedErrors
$capturedErrors | ForEach-Object {
if ($_ -notmatch "already exists") {
Write-Error "Error: $_"
}
}
}