Forum Discussion
stanoh
Feb 18, 2020Copper Contributor
Solving Name conflict in excel
How do you solve name conflict in excel worksheet when copying worksheets?
Yes, You have some things to consider in your script.
First $uidnum is invalid as it return the user DN "CN=User,DC=MyDC ...." not the employeeID
Second , you need to cast the $empid to be Int not String otherwise the int conversion will fail.
Here is an update
Please Check and let me know
$allusers = Get-ADUser -Filter "employeeID -ge 0" -Properties Name,employeeID,uidNumber foreach ($user in $allusers) { [int]$empid = (Get-ADUser $user -Property EmployeeID).EmployeeID if ($user.uidNumber -eq $null) { $uidnum = "1"+'{0:d5}' -f $empid Set-ADUser -Identity $user.SamAccountName -Replace @{uidNumber=$uidnum} } }
7 Replies
Sort By
- JKPieterseSilver Contributor
stanoh I suspect that you have copied a series of cells from workbook 1, worksheet A to workbook 2 worksheet B where both workbooks contain the same range name. When that happens, prior to the dialog you showed you get a dialog like the attached one on which you appear to have clicked "No".
That means that you want to KEEP the now duplicated range name, therefore Excel prompts for a new name as two global range names cannot be the same.
- stanohCopper ContributorThanks i did get the results as shown, unfortunately i wasn't able to move the worksheet to the new workbook. Unfortunately no other excel operation can go on unless i close excel using the task manager and stop all excel tasks running, a solution would be welcome.
- JKPieterseSilver ContributorYou could simply click the Yes to All button I showed above. You can get back to that dialog by cancelling the one you displayed in your first message.