Skip to content

Commit e1b12ea

Browse files
authored
ix for empty username or address in source in Migration module (cyberark#433)
* Fix to allow OAuth and override to use CustomURLs * Trim token response * Updates to allow for both PS 5 and 6+ to be used * RegEx updates for PCloudURL * RegEx fixes * Fixes for merge * Fix for empty username or address in source
1 parent c35207b commit e1b12ea

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Migration/Migration via REST/Migrate.psm1

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Function Get-CPMUsers {
4747
[OutputType([System.Boolean])]
4848
[CmdletBinding()]
4949
[OutputType([String[]])]
50-
param([switch]$SuppressCPMWarning)
50+
param([switch]$SuppressCPMWarning)
5151
$URL_GetCPMList = "$script:srcPVWAURL/API/ComponentsMonitoringDetails/CPM/"
5252
Try {
5353
$CPMList = Invoke-RestMethod -Method Get -Uri $URL_GetCPMList -Headers $Script:srcToken -ErrorVariable ErrorCPMList
@@ -567,7 +567,7 @@ Switch to prevent running in powershell job
567567
Initialize-Function
568568
Test-SessionsValid
569569
Test-AccountList
570-
$global:DomainList = $script:DomainList
570+
$global:DomainList = $script:DomainList
571571
#region Safe Work
572572

573573
$cpmUsers = Get-CPMUsers -SuppressCPMWarning:$SuppressCPMWarning
@@ -708,7 +708,7 @@ Switch to prevent running in powershell job
708708
}
709709
else {
710710
Write-LogMessage -type Verbose -MSG "Final `$SafeStatus $($SafeStatus |Select-Object -Property Id,SafeName,createSkip,Success,UpdateMembersFail | ConvertTo-Json -Depth 1 -Compress)"
711-
}
711+
}
712712
$SafeStatus
713713
$process.Completed = $true
714714
}
@@ -759,7 +759,7 @@ Switch to prevent running in powershell job
759759
$i++
760760
}
761761
}
762-
762+
763763
$SafeFailed.SafeData | Export-Csv .\FailedSafes.csv
764764
}
765765
Write-LogMessage -type Info "Safes succesfully processed: $($SafeSuccess.success.count)"
@@ -987,6 +987,11 @@ To get further information about the paramaters use "Get-Help Sync-Accounts -ful
987987
Write-LogMessage -type Debug -MSG 'Found source account'
988988
Write-LogMessage -type Verbose -MSG "Source account: $($srcAccount |ConvertTo-Json -Compress)"
989989
Write-LogMessage -type Debug -MSG "Searching for destination account with username `"$($srcAccount.userName)`" and address `"$($srcAccount.address)`" in safe `"$($srcAccount.safeName)`""
990+
If([string]::IsNullOrEmpty($srcAccount.userName) -or [string]::IsNullOrEmpty($srcAccount.address)) {
991+
Write-LogMessage -type Error -MSG "Source account with username `"$($srcAccount.userName)`" and address `"$($srcAccount.address)`" in safe `"$($srcAccount.safeName)`" is missing username or address. Skipping account."
992+
$AccountStatus.success = $false
993+
continue
994+
}
990995
[array]$dstAccountArray = Get-Accounts -url $dstPVWAURL -logonHeader $dstToken -safename $($srcAccount.safeName) -keywords "$($srcAccount.userName) $($srcAccount.address)" -startswith $true
991996
if ((0 -ne $($dstAccountArray.count))) {
992997
Write-LogMessage -type Verbose -MSG "Results array from destination: $($dstAccountArray | ConvertTo-Json -Compress)"
@@ -1180,7 +1185,7 @@ To get further information about the paramaters use "Get-Help Sync-Accounts -ful
11801185
[array]$AccountFailed.accountData | Add-Member -MemberType NoteProperty -Name FailReason -Value $null -Force
11811186
$i = 0
11821187
foreach ($id in $AccountFailed) {
1183-
$AccountFailed[$i].accountData.FailReason = $AccountFailed[$i].Error
1188+
$AccountFailed[$i].accountData.FailReason = $AccountFailed[$i].Error
11841189
$i++
11851190
}
11861191
$AccountFailed.accountData | Export-Csv -Force .\FailedAccounts.csv
@@ -1199,7 +1204,7 @@ Function Set-DomainList {
11991204
}
12001205

12011206

1202-
Function New-DomainList
1207+
Function New-DomainList
12031208
(
12041209
[Parameter(Mandatory)]
12051210
$DomainName,
@@ -1209,7 +1214,7 @@ Function New-DomainList
12091214
[hashtable]$script:DomainList = @{}
12101215
$script:DomainList.add($DomainBaseContext, $DomainName)
12111216
}
1212-
Function New-DomainEntry
1217+
Function New-DomainEntry
12131218
(
12141219
[Parameter(Mandatory)]
12151220
$DomainName,
@@ -1230,7 +1235,7 @@ Function New-DomainEntry
12301235
}
12311236
}
12321237

1233-
Function Remove-DomainEntry
1238+
Function Remove-DomainEntry
12341239
(
12351240
[Parameter(Mandatory)]
12361241
$DomainName,

0 commit comments

Comments
 (0)