<#Below script is used to migrate user profiles between different Azure regions Source & Destination Azure file share storage are restricted to access only with in their VNET's hence copying(azopy) directly between storage shares may get fail due to storage firewall restrictions so trigger the below script at source VNET VM by mapping Source Azure file share as a Network map drive. Note that, if storage firewall do not have restriction then data can copied directly with azopy#> Set-Location "C:\Temp" $Lists = Import-csv -Path "C:\Temp\ProfileMigrationstest.csv" # In Input File, provide userlogon to search and copy data #Mapping Source share to localmachine as drive $storageaccountdetail = Get-AzStorageAccount -ResourceGroupName cws-weu-prod-mgmt -Name prdat41077afpwe $storageaccount = $storageaccountdetail.StorageAccountName $storageaccountkey = Get-AzStorageAccountKey -ResourceGroupName cws-weu-prod-mgmt -Name prdat41077afpwe $Keys = $storageaccountkey | Select-Object Value $key = $keys.Value[0] $filesharename = "profile2" $Stagingusername = "Azure\$storageaccount" $Stagingpassword = $key $Stagingpassword = ConvertTo-SecureString -String $Stagingpassword -AsPlainText -Force $StagingCredentials = New-Object System.Management.Automation.PSCredential $Stagingusername, $Stagingpassword #New-PSDrive -Name T -PSProvider FileSystem -Root \\$storageaccount.file.core.windows.net\$filesharename -Credential $StagingCredentials $source = \\$storageaccount.file.core.windows.net\$filesharename #### $destination = "//.file.core.windows.net/" $destinationSas = "" $items = Get-ChildItem -Path $source $report = @() foreach($item in $items){ $itemName = $item.Name foreach($list in $lists){ $UserName = $list.Users if($itemName -cmatch $UserName){ #azcopy $SourceFullPath = "$source\$itemName" $destinationFullPath = "https:$destination$destinationSas" $output = ./azcopy.exe copy $SourceFullPath $destinationFullPath --overwrite=true --preserve-smb-permissions=true --preserve-smb-info=false --recursive --trusted-microsoft-suffixes= --log-level=INFO; $output $No_Of_files_Transferred = $output[-9].split(":")[-1] $No_of_Folder_Property_Transfers = $output[-8].split(":")[-1] $Total_No_of_Transfers = $output[-7].split(":")[-1] $No_of_Transfers_Completed = $output[-6].split(":")[-1] $No_of_Transfers_Failed = $output[-5].split(":")[-1] $No_of_Transfers_Skipped = $output[-4].split(":")[-1] $TotalBytesTransferred = $output[-3].split(":")[-1] $Final_Job_Status = $output[-2].split(":")[-1] $report += @{ UserId = $UserName; No_Of_files_Transferred = $No_Of_files_Transferred; No_of_Folder_Property_Transfers = $No_of_Folder_Property_Transfers; Total_No_of_Transfers = $Total_No_of_Transfers; No_of_Transfers_Completed = $No_of_Transfers_Completed; No_of_Transfers_Failed = $No_of_Transfers_Failed; No_of_Transfers_Skipped = $No_of_Transfers_Skipped; TotalBytesTransferred = $TotalBytesTransferred; Final_Job_Status = $Final_Job_Status } } } } $json = @{Profile = $report}| ConvertTo-Json ($JSONData = $json | ConvertFrom-Json) $JSONData.profile | Export-Csv -Path "C:\Softwares\weutoapacoutput.csv" -Append -NoTypeInformation