Using a lookup from one CSV file to another CSV file errors with a name clash

Hi
I have a master CSV file created by querying the AD. I need to populate the "Team" attribute by doing a lookup using Name against  the Name Column any of 6 CSVs,  someone has prepared for me .  The problem is the data is inconsistent
in the 6 CSV files so Name can hold either the Name or Username i.e. SAmAccountName or LoginName
Now my ps script works when the data is good. but I have around 30 exception cases whereby there is a mismatch .  To explain:
is in this line ( see the big code block below) 
$userObject = $nameAndTeamCsvData | Where-Object {$_.Name -eq $masterUserName}
The $_.Name is using the top level masterCSVData Name but I was hoping that it was using the
$nameAndTeamCSVData.Name  as in only within the scope of the Where-Object {} ..I guess I have misunderstood the syntax of what I had written.
. A quick a dirty fix would be rename this column in all of the 4 spreadsheets or trying to fix the code.....
# now update the empty team value for user object
$csvMasterData | ForEach-Object `
$masterName = $_.Name
$masterUserName = $_.Username # to deal with exception cases
#force scope to as the properties in the outer with the same name should be out of scope
# lookup the Name to see if we can extract the user's Team
$userObject = $nameAndTeamCsvData | Where-Object {$_.Name -eq $masterName }
# deal with the situation where the name in the businesses spreadsheets is actually the Username (login name) in the master csv
if ( $userObject -eq $null )
# lookup the username (loginname) to see if we can extract the user's Team # !!!!error occurs here with the $_.Name !!!!!
$userObject = $nameAndTeamCsvData | Where-Object {$_.Name -eq $masterUserName}
if ( $userObject -eq $null )
$_.Team = "UNKNOWN"
else
# replace the mastercsv.Team with the one we have looked up
$_.Team = $userObject.Team
else
# Name matches so replace the mastercsv.Team with the one we have looked up
$_.Team = $userObject.Team
Daniel

I see your challenge.  How about collecting the column names in an array and looking for the potential names?  Following my example before, try this:
$dataColumns = $I | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name
Now, you can loop through the names and collect the appropriate data.
if ($dataColumns.Contains('Column1'))
    #add ForEach-Object { $_.Column1... }
HTH
~fr3dd
Hi I had to wait until Friday as I have someone  ( my boss) checking the business & team csv files against valid usernames and names. 
# now update the empty team value for user object
$nameAndTeamCsvData | ForEach-Object `
$nt_name = $_.Name
# $masterUserName = $_.Username # to deal with exception cases
# lookup the Name to see if we can extract the username and mobile from the masterCSV
$userObject = $null # Replace my original code: $csvMasterData | Where-Object {$_.SName -eq $nt_name } # with foreach code below
$uo = $null
foreach ($uo in $csvMasterData)
if ($uo.SName -eq $nt_name)
$userObject = $uo
# ouch can't break out of this even though I found it so have to move on to the next
}if ( $userObject -ne $null ){ #  Name matches so   replace the few propeerties in  mastercsv.Team with the ones we have looked up
         $_.Username =$userObject.SamAccountName
         $_.Mobile =$userObject.Mobile
This does work but is clearly not very efficient since I don't think I can
break or exit out of the foreach loop.  I am thinking I could quickly modify and add your code - my import is delayed as I am having a new property added to user class...  Let me know what you think.

Similar Messages

  • Why can´t I use original HPinkcartridges from one HP printer to another HPprinter it says use origin

    why can´t I use original HPinkcartridges from one HP printer to another HP printer, it says use original cartridges -
    but they are original?

    If the printers are identical that should not be a problem. If the printers are not identical then it simply will not work. Each printer uses different cartridges unless it is from the same model group as the other.  
    In analogy that would be like asking why the spark plugs from a Porsche don't work in your PT Cruiser. 
    ****Please click on Accept As Solution if a suggestion solves your problem. It helps others facing the same problem to find a solution easily****
    2015 Microsoft MVP - Windows Experience Consumer

  • HT4796 can i use migration assistant from one windows laptop to another

    I need to set up iTunes on a new laptop but I don't know how to do it. Migration assistant seems to be only from a windows p.c. to a mac laptop. I want to transfer all my music from old (vista) to new (7). Can I do this?

    No.  Migration Assistant only works when using OS X on one of the computers.  You would have to ask Microsoft Support.
    Hope this helps

  • Illegal dependency  while using a DC from one Software Component in another

    Hi
    <u><b>SCENARIO</b></u>
    I have a Software Product (<b>e.g. SP1</b>) with 2 Software Components (e.g. <b>SC1, SC2</b>) defined in the SLD. Now, we have defined a track with these software components (as per the correct procedure).
    This Development configuration was imported into NWDS and we have developed 2 WebDynPro Development Components under each of these Software Components  (e.g. <b>DC1 in SC1</b> ; <b>DC 2 in S</b>C2).
    All works fine and everything is smooth till now.
    <u><b>The ISSUE</b></u>
    When I try to use DC1 of SC1 as a used component in DC2 of SC2, I get an error.
    The exact step: In NWDS-> DC2, I go to USED DCs -> Add Used DC and try to add DC1's public part (all as per correct procedure),
    <b>I get the following error:
    Illegal dependency: The compartment of com.test/xss/dc2(com.test_SC1) must explicitly use compartment of com.test/xss/dc1</b>
    This error comes only if <b>DC1 is in SC1</b> and <b>DC2 is in SC2</b>. If 2 DCS are in the same SC (eg: <b>DC1 and DC2 to SC1</b>), then the error does not come.
    Should we configure any compartment or other data in CBS/CMS?
    Please help.
    Thanks in advance.

    Sandeep,
    In the SLD, has a dependency been setup between SC1 and SC2? If not, you will have to add this dependency, which is done in the same way as adding the initial SAP_JTECHS,
    SAP_BUILDT and SAP-JEE dependencies to the SC.
    Once the SC1 has been added to SC2, you will have to go to the Landscape Configurator (link is in the CMS), go to the Domain Data tab and click on “Update CMS”. Next, go to the Track Data tab, add the new SC and then click on “Synchronize SC Dependencies”. Click on the Save button and then do a "Save and Restore".
    Message was edited by:
            Stefan Thibeault (added a missing step!)

  • Stock transfer from one co.code to another.

    Hi,
    What is the process of stock transfer order from one co.cde to another co.code (not with in the plants of a co.cde)
    Also please explain the financial effects on each steps on both side.
    for Stock transfer order i need to configue the cross company code transaction.
    Regards

    Company code to company code u have to treat the another company as Vendor/Customer in each company code books. Then the process is same.  Sale order, delivery and billing to the Customer(2nd company code i.e. stock receiving company code).  Then in receiving company code based on the delivery document of other company code GR can be made. and IV.

  • Not able to copying files/folders from one Document Library to another Document Library using Open with Browser functionality

    Hi All, 
    We have SharePoint Production server 2013 where users are complaining that they are not able to copy or move files from one document library to another document library using “Open with Explorer” functionality.
    We tried to activate publishing features on production server but it did not work. We users reported following errors:  
    Copying files from one document library to another document library:
    Tried to map the document libraries and still not get the error to copy files: 
    In our UAT environment we are able to copy and move folders from using “Open with Explorer” though.
    We have tried to simulate in the UAT environment but could not reproduce the production environment.  
    Any pointers about this issue would be highly appertained.
    Thanks in advance
    Regards,
    Aroh  
    Aroh Shukla

    Hi John and all,
    One the newly created web applications that we created few days back and navigated to document library, clicked on “Open with Explorer”, we get this error.
    We're having a problem opening this location in file explorer. Add this website to your trusted and try again.
    We added to the trusted site in Internet Explorer for this web application, cleared the cache and open the site with same document library but still get the same above error.
    However, another existing web application (In same the Farm) that we are troubleshooting at the moment, we are able click on “Open with Explorer”,  login in credentials opens and we entered the details we are able to open the document
    library and tried to follow these steps:
    From Windows Explorer (using with Open with Explorer), tried to copy or move a files to
    source document library.
    From Windows Explorer moved this file to another destination document library and we got this error.
    What we have to achieve is users should be able to copy files and folders using
    Open with Explorer functionality. We don’t know why Open with Explorer
    functionality not work working for our environment.  
    Are we doing something wrong? 
    We have referred to following websites.
    we hope concepts of copying / Moving files are similar as SharePoint 2010. Our production environment is SharePoint 2013.   
    http://www.mcstech.net/blog/index.cfm/2012/1/4/SharePoint-2010-Moving-Documents-Between-Libraries https://andreakalli.wordpress.com/2014/01/28/moving-or-copying-files-and-folders-in-sharepoint/
    Please advise us. Thank you.
    Regards,
    Aroh
    Aroh Shukla

  • I have a Windows 7 laptop using I tunes 64 and all my music files are on an external disc. I rarely use I tunes and at one point moved all my files (including the music files) from one external disc to another without considering what affect this wou

    I have a Windows 7 laptop using I tunes 64 and all my music files are
    on an external disc. I rarely use I tunes and at one point moved all my files
    (including the music files) from one external disc to another without
    considering what affect this would have on the I tunes library. When I eventually
    attempted to use I tunes, every selected a song from the library resulted in a
    message stating that the file couldn't be located. After following some of the procedures
    explained in this community I was able to reconnect the library back to where
    the associated music files are presently stored. However, there are still 2
    problems that need to be corrected. 1) Every song file now has a duplicate. One
    file works and the other file will result in the same message stating that the
    file couldn't be located. Before there were 4,000 songs in the library, now
    there are 8,000 songs. I need to eliminate the 4,000 dead song files. 2) All
    the playlists are still associated with the dead song files which makes the
    playlists unusable. Can the playlists be reconnected to the usable files
    without manually having to recreate them? Thanks in advance for the help.
    sdkr

    So am I understanding correctly?
    You used your iPod as a hard drive (drag and drop) instead of having iTunes install the music?
    If you used drag and drop your choices are different than if you used iTunes to transfer.
    Good luck!

  • Move group of pages from one InDesign file to another InDesign File using VB.Script

    Dear team,
    I am trying to move group of InDesign pages from one indesign file to another indesign file using vb.script.
    I have written the code like
    Dim Pages=IndDoc.Pages
    Dim Mytype=TypeName(Pages)
    Pages.Move(InDesign.idLocationOptions.idBefore,IndDoc1.Pages.LastItem)
    but it is giving an error as method Move is not a member of Pages 
    please give mme the solution to move the Multiple pages or a group of page from one Indd to another Indd.

    Hey Peter, if I wan to move several page that part of Auto Flow text, I checked the "delete page after moving" but the content still there, not deleted.
    Is there any way to delete it automatically, just to make sure I have moved that autoflowed page?

  • I have a document made up of separate PDF files which reside in a folder and are linked to each other via hyperlinks. Each pdf file is set to open with bookmarks displayed, however if I link from one PDF file to another and use the "Previous View" button

    I have a document made up of separate PDF files which reside in a folder and are linked to each other via hyperlinks. Each pdf file is set to open with bookmarks displayed, however if I link from one PDF file to another and use the "Previous View" button to navigate back to my starting point the bookmarks are replaced by "page thumbnails". Is there anyway to stop this from happening?

    Hi Pusman,
    While setting up the links, if you choose to open the file in a new window then you won't face this issue, then you can simply switch to the previous file and bookmark view will remain as it is.
    Does that helps with your query?
    Regards,
    Rahul

  • Move Files from one document set to another document set using workflow

    Hi All,
    Env : SP 2013 Server - SPD 2013.
    I'm trying to make a SPD Workflow that must copy a  files from one Document Set to another Document set in the same library other document library  
    Does Someone already get success for Copy  files from one Document Set to another Document set?
    Thanks for your help.

    Hi,
    According to your post, my understanding is that you wanted to move Files from one document set to another document set using workflow.
    I recommend to use the custom workflow activity  Copy List Item Extended Activityto
    copy files to another document set.
    You can do this with codeless SharePoint Designer workflows as long as you can install the
    Codeplex Custom SharePoint Designer Workflow Activities. 
    These activities are also built-in to SPD2013. However, you can only use the custom activities in the SharePoint 2010 Platform.
    To install the custom activities, please follow the steps as below:
    Download the solution file form
    Useful Sharepoint Designer Custom Workflow Activities
    Copy the wps file to the Disk C.
    Open the SharePoint 2013 Management Shell.
    Run the command: add spsolution c:\ dp.sharepoint.workflow.wsp
    Open the Center Administration, click System Setting->Manage Farm Solution-> dp.sharepoint.workflow.wsp->Deploy to one or more Web Application.
    Open the SharePoint designer, create SharePoint 2010      Platform workflow, add action from Custom Actions.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How do i transfer migrated files from one user account to another

    Mac novice so please be kind!!!!

    Was this transfer from a Windows PC to your new Mac?
    It is that aspect of Migration Assistant that I find less than useful.  Even from one Mac to another, creating a new (old) account is like sorting through old boxes deciding what to put where. This is why I say MA is really only useful at the very outset where the account it creates is the one you will be using.
    Anyway you have a whole lot of content in a different account that you want to move into your main account.
    Not the only way, but a good way is to drag the folders of files and photos into your desired main user account, putting them in to the Drop Box ;
    Macintosh HD / Users / collies? / Public / Drop Box
    Then log into your main account and collect them from the same location.
    This method is a bit clunky but it will update the ownership permissions of the moved files to the extant account. 
    Set up your email in your new account from scratch.
    For general information, the following link has a great deal for the novice.
    http://www.apple.com/support/mac101/
    I forgot, its cricket season there in the UK at the moment. The media is all about Olympics here. I wonder if cricket will ever become an Olympic sport.

  • How do I copy a page from one Pages document to another using Pages 5.0?

    I posted this question on another page, and haven't recieved an answer to it yet. However I have found a temporary solution, so I am posting this here in case anyone else has a similar problem.
    The issue here is that I have just upgraded from Snow Leopard to Maverick (10.9.1), and my Pages also upgraded (to 5.0.1), altering my Pages documents. This is the issue, as as far as I can see the new Pages does not offer some of the basic needs that the old Pages did! In other words it is worse than the previous version.
    Using the upgraded new Pages 5.0.1 seems to result in some major editing problems for me. If you upgrade, make sure you KEEP the old version of Pages 09 (v 4.3). That is what has saved me!  If you have the same problems I have had - explained below, you will still be able to close the new version and open your Pages document in the old version, provided it is not a new Pages document. If it is, it will be possible to export it as a Pages 09 document and edit properly.
    After upgrading to the new Pages 5.0.1, when I open documents in Pages and try and copy a section from one document to another (easy before using the thumbnails) many of the Menu items previously available are visible but appear faded and are not possible, including Insert>Section Break/Page Break/Page Number and Edit>Cut/Copy/Delete/Undo/Redo
    This even happens if I duplicate the Pages document and try and do any of these from the Duplicate (which should be an easily editable copy).
    My solution has been to simply open all Pages documents that Iwant to edit (or may want to edit in future) in the old Pages app (v 4.3), which I never got rid of. That has meant I can continue editing and copying a section (of 1 or more pages) from one Pages document to another.
    If anyone reading this has figured out a way to edit Pages documents using the new version 5.0.1 please post an explanation, and I will try it!

    And there are those who don't like me repeating the same message over and over again in this forum!
    Apple has removed over 90 features from Pages 5.
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    Pages '09 should still be in your Applications/iWork folder.
    Archive/trash Pages 5, after Exporting your files to Pages '09, and rate/review it in the App Store, then get back to work.
    Peter

  • Lightroom - how to restore backed up files (not Lightroom catalogue) from one external drive to another?

    How to restore backed up files (not lightroom catalogue) from one external drive to another.
    I recently backuped my photo files from one external drive to another. The backup (carbon copy cloner) pointed to some corrupt files on the original drive.
    I have deleted those files and am finding good copies of them  in Time Machine backups.
    I want to get rid of the original external drive; use the recent backup as my main external and then back it up onto a brand new drive.
    What I am not sure about is how to point lightroom to the backups so it knows to look on the new drive instead of the old drive and all those exclamation marks and question marks go away.
    There are close to 60,000 images in numerous folders all with one 'parent folder.'
    My best guess is from Lightroom Help - Create and Manage Folders -  Locate Missing Folders
    Can I point to the one parent folder and all the subfolders will come back?
    Is this the process to recover files into lightroom and will there be a problem with so many photos?

    http://www.computer-darkroom.com/lr2_find_folder/find-folder.htm

  • Moving LR files from one external drive to another

    How do I move LR image files from one external drive to another external drive?

    Move the photos using your operating system and then re-connect in Lightroom following these instructions: Adobe Lightroom - Find moved or missing files and folders
    Do not use this as an opportunity to re-arrange folders or move photos from folder to folder. Just move the entire "tree" of folders.

  • HT2518 how do i or can i drag and drop files from one external drive to another ???HOW

    how do i drag and drop files from one external drive to another, i cannt get both drives to open up. only one at a time.. i have alot to learn i know but that is where i am at the time...

    You posted here so would assume you are also talking about running Windows.
    Are the drives NTFS and use on Windows?
    Are they Mac HFS formatted?
    You likely will need NTFS for OS X in one case. to mount PC and use under Mac OS Lion
    MacDrive to mount and WRITE to HFS drives under Windows

Maybe you are looking for