AwsFunctions.ps1
Function GetAwsCopyArgs([string]$file, [string]$awsProfileName, [string]$awsRegion, [string]$description, [HashTable]$tags, [int]$threads, [string]$logFileName) { $copyArgs = @{File = $file; Description = $description; Tags = $tags; Threads = $threads} if (-not [String]::IsNullOrWhiteSpace($awsProfileName)) { $copyArgs["ProfileName"] = $awsProfileName } if (-not [String]::IsNullOrWhiteSpace($awsRegion)) { $copyArgs["Region"] = $awsRegion } if (-not [String]::IsNullOrWhiteSpace($logFileName)) { $copyArgs["LogFileName"] = $logFileName } return $copyArgs } Function UploadToAws([string]$path, [string]$awsProfileName, [string]$awsRegion, [string]$description, [HashTable]$tags, [int]$threads, [string]$logFileName) { Log ("Copying disk '$path' to AWS " + $(if ($threads -le 0) {"(threads=default)"} else {"(threads=$threads)"})) $copyArgs = GetAwsCopyArgs $path $awsProfileName $awsRegion $description $tags $threads $logFileName $snapshotId = Copy-ToAwsDisk @copyArgs Log "Copied disk to AWS snapshot $snapshotId" return $snapshotId } |