PoswerShell - Compare 2 x CSV files, only if data matches in column 1 add all data from file 2 to file 1 or output collated results

OK, 1st the background...
I have been provided a list of users of a particular group.
We needed to know what computers (or IP's) the users are connected to...
So, using Shared Folders, I have exported a list of all users connected to H drives (everyone on the domain) and I need to match their computernames (or IP) to the specific list of users I have...
That gives me 2 x CSV files. 1 x master list of users, I list of all users PC or IP names.
I need to be able to match the usernames on the master list (File1) with the usernames on File2 and append the computernames and connected times to File1 omitting the usernames that are not required...
This is to determine what PC's the user is logged into and what site their computers are at.
I also need to capture if they are logged into more than one computer (info is contained in File2)
File1 Example:
User
FirstName
LastName
ADSite
HDriveLocation
HDriveLocationTS
Office2010FAT
XY123456
BOB
BUILDER
LONDON 
\\SERVER\%USERNAME%
\\SERVER\USERNAME
TRUE
ABC09876
JIM
INYCRICKET 
CHICAGO 
\\SERVER\USERNAME
\\SERVER\USERNAME
TRUE
ADD11223 
SALLY
METLARRY
TOKYO
\\SERVER\USERNAME
\\SERVER\USERNAME
FALSE
File2 Example:
User
Computer
 Connected
Idle
XY123456 
192.168.1.216 
3 days 06:13:18
0:00:03
XY123456
192.168.1.254 
1 day 01:21:30
23:08:39
WXY46810 
PCNAMEXYZ  
6:44:19
0:00:05
I have found a PS script which "might" do what I need it to, but I haven't been able to "tweak" it right - it's omitting the details from File2 - http://powergui.org/thread.jspa?threadID=19522
Also I can't figure out how to collect multiple computernames (that users are logged into) from File 2 and add this to File1
Working with Powershell, but happy to consider any other options (EG: Excel, Macros, VBS, etc)
Here's what I have got so far: (PS)
$File1 = Import-Csv "C:\Users.csv"
$File2 = Import-Csv "C:\Shares.csv"
$Output = @()
ForEach ($Item in $File1)
{ $Result = $File2 | Where { $Item.User -eq $_.User }
$Output += New-Object PSObject -Property @{
USER = $Item.User
FirstName = $Item.FirstName
LastName = $Item.LastName
ADSite = $Item.ADSite
Computer = $_.Computer
Connected = $_.Connected
Idle = $_.Idle
Office2010FAT = $Item.Office2010FAT
HDriveLocation = $Item.Connected
HDriveLocationTS = $Item.Idle
$Output | Select User,FirstName,LastName,ADSite,Computer,Connected,Idle,Office2010FAT,HDriveLocation,HDriveLocationTS | Export-Csv C:\Users\a1033965\Desktop\result.csv -NoTypeInformation
However, the output I'm getting is missing the results from File2 and I NEED multiple computers listed if a user is logged into them:
Current Output:
USER
FirstName
LastName
ADSite
Computer
Connected
 Idle 
Office2010FAT
 HDriveLocation
 HDriveLocationTS
XY123456
BOB
BUILDER
LONDON
TRUE
ABC09876
JIM
INYCRICKET
CHICAGO
TRUE
ADD11223 
SALLY
METLARRY
TOKYO
TRUE
(TRUE is actually in the right column, under Office2010FAT as it should be - just doesn't look like it as I post this)
Any help with this would be much appreciated. Cheers

Please verify that your files look exactly like this:
#file1 format
User,FirstName,LastName,ADSite,HDriveLocation,HDriveLocationTS,Office2010FAT
XY123456,BOB,BUILDER,LONDON,\\SERVER\%USERNAME%,\\SERVER\USERNAME,TRUE
ABC09876,JIM,INYCRICKET,CHICAGO,\\SERVER\USERNAME,\\SERVER\USERNAME,TRUE
ADD11223,SALLY,METLARRY,TOKYO,\\SERVER\USERNAME,\\SERVER\USERNAME,FALSE
#file2 format
User,Computer,Connected,Idle
XY123456,192.168.1.216,3 days 06:13:18,0:00:03
XY123456,192.168.1.254,1 day 01:21:30,23:08:39
WXY46810,PCNAMEXYZ,6:44:19,0:00:05
¯\_(ツ)_/¯

Similar Messages

  • I am receiving the data through the rs232 in labview and i have to store the data in to the word file only if there is a change in the data and we have to scan the data continuasly how can i do that.

    i am receiving the data through the rs232 in labview and i have to store the data in to the word or text file only if there is a change in the data. I have to scan the data continuasly. how can i do that. I was able to store the data into the text or word file but could not be able to do it.  I am gettting the data from rs232 interms of 0 or 1.  and i have to print it only if thereis a change in data from 0 to 1. if i use if-loop , each as much time there is 0 or 1 is there that much time the data gets printed. i dont know how to do this program please help me if anybody knows the answer

    I have attatched the vi.  Here in this it receives the data from rs232 as string and converted into binery. and indicated in led also normally if the data 1 comes then the led's will be off.  suppose if 0 comes the corresponding data status is wrtten into the text file.  But here the problem is the same data will be printed many number of times.  so i have to make it like if there is a transition from 1 to o then only print it once.  how to do it.  I am doing this from few weeks please reply if you know the answer immediatly
    thanking you 
    Attachments:
    MOTORTESTJIG.vi ‏729 KB

  • How can i get the all values from the Property file to Hashtable?

    how can i get the all values from the Property file to Hashtable?
    ok,consider my property file name is pro.PROPERTIES
    and it contain
    8326=sun developer
    4306=sun java developer
    3943=java developer
    how can i get the all keys & values from the pro.PROPERTIES to hashtable
    plz help guys..............

    The Properties class is already a subclass of Hashtable. So if you have a Properties object, you already have a Hashtable. So all you need to do is the first part of that:Properties props = new Properties();
    InputStream is = new FileInputStream("tivoli.properties");
    props.load(is);

  • Need to Convert Comma separated data in a column into individual rows from

    Hi,
    I need to Convert Comma separated data in a column into individual rows from a table.
    Eg: JOB1 SMITH,ALLEN,WARD,JONES
    OUTPUT required ;-
    JOB1 SMITH
    JOB1 ALLEN
    JOB1 WARD
    JOB1 JONES
    Got a solution using Oracle provided regexp_substr function, which comes handy for this scenario.
    But I need to use a database independent solution
    Thanks in advance for your valuable inputs.
    George

    Go for ETL solution. There are couple of ways to implement.
    If helps mark

  • How to insert data in a column with uniqueidefier data type

    Guys,
    I need insert data in a column with uniqueidefier data type, when i am trying to that getting error.
    error message says: "Conversion failed when converting from a character string to uniqueidentifier."
    I have data in table a col1,col2,col3,col4 - col3,col4 has datatype as varchar and i am updating table b columns col1,col2 with table a col3 and col4.
    Please guide how to do it.

    Hi,
    Not any String can be convert to uniqueidentifier.
    1. you have to make sure u use a value which is fir to be uniqueidentifier
    2. Use convert or cast in the insert query in order to convert the string into uniqueidentifier
    insert X ... convert(uniqueidentifier, 'string which fit to be convert to uniqueidentifier')
    Please post DDL+DML for more specific help
    DDL = Data Definition Language. In our case that is, CREATE TABLE statements for your tables and other definitions that are needed to understand your tables structure and there for let us to test and reproduce the problem in our server. Without DDL no one
    can execute any query.
    How to get DDL: Right click on the table in Object Explorer and select script table as CREATE. Post these create table scripts here.
    DML = data manipulation language is a family of queries used for manipulating the data it self like: inserting, deleting and updating data. In our case we need some sample data in order to check the query and get result, so we need some indert query for
    sample data.
    If you post a "create query" for the tables and "insert query" with some sample, then we could help you without Assuming/Guessing. There is a reason that DDL is generally asked for and expected when discussing query problems - it helps
    to identify issues, clarify terminology and prevent incorrect assumptions.  Sample data also provides a common point of reference for the discussion. A script that can be used to illustrate or reproduce the issue you have, will encourage others to help.
    [Personal Site] [Blog] [Facebook]

  • How to insert data into datagrid dynamically and also programatically with data and column names being retrived from a xml file..

    iam not able to insert data into datagrid corresponding to the column names..as iam inserting both data and column names programatically..ie iam not able to co relate the data with the column names.plzzz help me asap

    A DataGrid is row-based rather than cell-based with each row
    corresponding to an item in an underlying collection (specified in the
    dataProvider property). In order to add data to a DataGrid you
    manipulate the underlying collection, rather than the grid directly.
    Based on the limited description of your problem I would imagine you
    would need to create dynamic objects with property names that correspond
    to the dataFields of your dynamically created datagrid columns.
    So if you had created columns with dataFields "alpha", "beta" and
    "gamma" on your datagrid, you could create an item in your grid by
    adding the following object to your dataProvider:
    var gridItem : Object = new Object();
    gridItem.alpha = "alphaValue";
    gridItem.beta = "betaValue";
    gridItem.gamma = "gammaValue";

  • PLEASE HELP - Unable to restore all messages from my backup file (.bbb) - 21800 messages and I need them all

    Hi.
    This is not the first time I encountered this issue. The backup file itself is 18.5MB in size. The critical stuff is my 21800 messages (emails for 7 different email accounts). Whenever I do a restore, the DM only reads 13859 messages and unfortunately not in reverse order. So I end up with no emails for the last 7 months! BIG PROBLEM for me! I have done a selective restore. I have done a complete wipe and then a full restore (no success), then deleted all data and tried a selective restore and only selected the messages (still only around 13,500 messages).
    There appears to be a limitation around the 13500 mark for messages.
    PLEASE, PLEASE, PLEASE help.

    It's been a while since I used Apple's Backup, but you should be able to select "Restore" from within the app to find an iCal backup file. When you find your most recent backup file restore it to your main computer. An iCal backup should look like this: "iCal - 10/31/06.icbu". Once you have the file you can just double click on it and iCal will open and give a warning about overwriting your current database file. You can just select "Revert" to overwrite the current file since you have nothing in it now. Everything should then go back to the state it was in since your last backup. You might lose some of your most recent entries if they were not in the backup, but you should get back most of what you lost. Good Luck!!

  • Read all cells from an Excel file?

    Hi!
    I'm trying to read every cell from an Excel spreadsheet file, e.g.
    test.xls. The example in the NI Dev Zone (ActiveX Read Cells from
    Excel2000 VI) works if you know in advance what the first and last cell
    are, e.g. A1 and E453.
    The trouble is that the number of rows & columns in the file will vary;
    the last cell of 1 file might be E453, another might end at F29.
    How can I programmatically read every cell in the file? I thought of 2
    approaches:
    1: Find an ActiveX property that returns the last cell (or last row and
    last column).
    2: Use some other way to read an .xls file, maybe not by launching Excel
    but by using another program ...
    The NI applications engineer couldn't find a reasonably easy solution,
    so I'd w
    elcome any input.
    Thanks! Mark

    Mark,
    I haven't been able to find out if there is an ActiveX property or method the excel exposes to be able to do this ... searching on http://msdn.microsoft.com didn't return anything particularly useful.
    I've tried this sort of thing a couple of different ways. The simplest is if I have control over the file generation code, in that case I've just used the first row A1 and B1 to contain the number or rows and columns respectively and moved on from there.
    If that isn't a possibility then you could enter nonsense data around the acutal data and then look for that and then resize the array. This could get pretty slow if you read row by row, I've somtimes read chuncks of rows and then adjusted the next read and and combined arrays. With a large data set the memory and s
    peed implications do need to be looked at.
    The last thing is what you are referring to in 2. You should be able to save the .xls file as a comma delimited file. In this case the "Read for Spreadsheet File" vi should be able to just read all the data in. I'm not sure how easy it is to export an .xls file to a comma delimited format programatically.
    I think this should work all though I haven't tried it. If it doesn't then you could just read one row and then count the number of commas to determine the number of columns. You can then read the entire file and convert the data into an array, as every comma would separate each column and a carriage return would seperate each row.
    Haven't got LabVIEW on this machine so if I find anything new tomorrow I'll post again.
    Kamran

  • How to get all TextFrame from ImportedPage INDD Files?

    Hi everyone!
    Do you know the javascript scripts to get all textFrames in importedPage (.indd file)? Is it posible to do that or have some trick to do it?

    Use
    JDR_UTILS.LISTDOCUMENTS
    Use this API to list of all OA Framework the documents in a path/module. This script is very handy, as it provides a list of all the desired documents/extensions/personalizations in one go.
    DECLARE
    BEGIN
    jdr_utils.listdocuments('/oracle/apps/po/setup', TRUE);
    END;
    Thanks
    --Anil
    oracleanil.blogspot.com

  • Can't Open File Explorer -- How can I reset the Quick Access Toolbar from outside of File Explorer?

    First of all, this is not a virus. This is my a bug within windows explorer itself.
    So, I added the properties button to the QAT, and it displayed it as an expandable menu, like this: ";" but with small arrows like this: ">". didn't want this, I wanted to click on it and immediately display the properties of the file
    to me. So, I hovered over it, right-clicked on "Properties" in this menu and added it to the QAT. Of course, this crashes File Explorer. Now whenever I try and open it, it crashes, so I have to assume that the corrupted button has been saved.
    So, my question is: How do I reset the QAT from OUTSIDE of file explorer? Regedit magic? Any ideas?
    Thanks for stopping by,
    Trolleyman.
    Edit: Just so you know, I can navigate through my systems files using the 7-zip file manager. Phew.

    Thanks from me  too, Niki. This first happened with Windows 8.0 File Manager a week ago,, and despite much research I couldn't  discover the cause so eventually I resorted to restoring  the system drive from backup (luckily I make daily backups, 
    so didn't lose   much  work).
    Without  knowing the cause  a  few days later I again tried to alter  the Quick Access  Toolbar  and the problem reappeared.  Should  I again resort to restoring the entire system drive, the thought horrified me. But
    luckily while doing a bit more research prior to resorting to the same drastic recovery, I cane  across this post  of yours and it worked!
    It doesn't  seem  to be  happening with Office 2007's   or  Wordpad's  Quick Access Toolbar,  so presumably it's a File Explorer bug  (a.k.a. Windows Explorer in Windows 7, of course). Have Microsoft recorded this as
    a  bug -- if not,  why not  -- and when  are they coming up with a fix?

  • I am finding that a new business is requiring lots of files, photos and video and it seems to be slowing down my older imac. I am wondering if a 1TB mini can be used as a dedicated machine to house these files only and if I can simply keep all biz files

    Will a 1TB mac mini be a good solution to separate media rich biz files from personal home type files and will the uSB3 be a problem connecting to an older 1mac?

    A USB3 drive can connect to an older iMac by simply substituting a USB2 drive cable. Or enabling File Sharing between machines.
    There are organizational and legal reasons why you want personal and business content separate. Since you mention USB3, may I infer you are looking at the late 2012 Mac mini? It has four, USB3 ports.
    I would purchase three, identical external USB3 drives and configure two of them in a RAID 1 (mirror) configuration. This means that data that is written to drive 1, is simultaneously duplicated (mirrored) to drive 2. Drive 3 would be an additional fail-safe backup drive. Using Time Machine, back up drive 2 to drive 3. If you turn off the Mac mini at night, put drive 3 in a fireproof safe until morning when you reattach it to the mini. Rotate the USB3 port that you use for drive 3 to reduce wear.

  • HT1171 I have the apple wireless key board.  There is only one delete key and it deletes all data to the  left side of the cursor.  Where is the delete function for deleting letters that are on the RIGHT side of the cursor?

    I have a new wireless apple keyboard. I can only delete items that are to the left of the cursor using the delete key.  What key do I use to delete items that are to the right side of the cursor?  I have only one delete key.
    My old apple wired keyboard has 2 delete keys that enabled me to easly delete data on either side of the cursor.
    Thanks

    Fn + Delete

  • Data Merge not picking up all data fields

    Hi,
    I've been having a problem, posted here: http://forums.adobe.com/thread/1217090
    Essentially, I have been using the script 'CSV2Tables' to prepopulate simple 2 column tables with information drawn from a CSV data source.
    The tables consist of a title, and a block of information about that specific subject. Many of the blocks of information I am importing also contain data tags (<<DataTag>>)
    The plan is to use CSV2Tables to populate the tables, then change data source and run a normal ID Data Merge to replace all of the <<tags>> within the tables with information from a second CSV data source.
    The problem is, CSV2Tables is importing the data and prepopulating the tables just fine, but the data tags that are found within each body of text are being picked up as plain text (as Peter Spier has pointed out, they are being drawn from a plain text stream rather than being dragged from the Mail Merge panel) so when I try to run the ID Mail Merge, none of the fields are found within my document.
    My question is - is there a method, or script available out there that can essentially do a Find/Change within a document, and replace plain text that appears like this <<PlainText>> with a Data Tag that is recognised by ID, which will allow me to run a Data Merge?
    I have been told to check out some of the commercial plugins available out there, but registering and setting up demo's would require me to contact our IT provider for each, and that would be an exhaustive process.
    Any help is much appreciated.

    Hi,
    is modyfied
    Array.prototype.find = function (string) {
        for (var s = 0; s < this.length; s++)
            if (this[s] == string) return s;
            return -1;
    var mFrames, mFile, mDoc, mFields, mFieldsNames, mStory,
         mPlainTxt, mNameToCompare, mField_ID;
    // edit this with proper .csv path
    mFile = File(Folder.myDocuments + "/" + "Merge.csv");
    mDoc = app.activeDocument;
    mDoc.dataMergeProperties.selectDataSource(mFile);
    mFields = mDoc.dataMergeProperties.dataMergeFields;
    mFieldsNames = mFields.everyItem().fieldName;
    mFrames = mDoc.textFrames.everyItem().getElements();
    for (var i = 0; i < mFrames.length; i ++) {
        if (!mFrames[i].name.match(/TF\d*$/) ) continue;
        // script assumes a targered text boxes are named like: TF1, TF2...
         // (TF plus any integer) or just TF (no integer)
        // - they could have the same name
        // any other name exludes frame from this loop
        mStory = mFrames[i].parentStory;
        app.findGrepPreferences = null;
        app.findGrepPreferences.findWhat = "<<.+?>>";
        mPlainTxt = mStory.findGrep(true);
        for (var k = 0; k < mPlainTxt.length; k++) {
            mNameToCompare = mPlainTxt[k].contents.slice(2,-2);
            mField_ID = mFieldsNames.find(mNameToCompare);
            if (mField_ID > -1) {
                  mField = mFields[mField_ID];
                mDoc.dataMergeTextPlaceholders.add (
                    mStory,
                    mPlainTxt[k].insertionPoints[0],
                    mField
            mPlainTxt[k].remove();
    script assumes a targered text boxes are named like:
    TF1, TF2... (TF plus any integer) or just TF (no integer) -
    - they could have the same name.
    Jarek

  • The size of files on my hard drive don't add up? where are my files?

    when I open a finder window it shows my hard drive as containing 235 Gb used out of 320GB available but when I add up the files inside the HDD it only adds up to about half of that. Where is all my storage space gone?

    I know there's some way to do that but I couldn't figure out how. That's probably exactly what my problem is! That just makes me wonder why I have so darn many hidden files? And could this be why it slowly seems to lose speed the older it gets-like myself, just dragging around a bunch of invisible baggage?

  • Will Keynote keep all animations from a PPT file?

    I have a PPT file on my Mac that I created. Having an insanely hard time getting it to convert to DVD.
    I have 2 questions  - 1. If I purchase keynote will it bring in all the animations/transistions that I have created
                                  2. Will it be able to save it with all the animiations/transisitions as a DVD?
    thanks!

    If I purchase keynote will it bring in all the animations/transistions that I have created
    2. Will it be able to save it with all the animiations/transisitions as a DVD?
    Only if the fonts, animations and transitions used in the PowerPoint file are compatible with Keynote. Many are not so you will need to test it thoroughly.

Maybe you are looking for

  • Creative Cloud Desktop App Shows Incorrect Free Space Remaining

    Hello, I have a technical issue with my creative cloud account.  My CC desktop application (Windows) shows as having 46.7% of the available space used, and at present I have no files stored or in my creative cloud archive.  Something is definitely am

  • Security Update 2010-001---   So secure I lost Admin Access!

    I am running a Snow Leopard Server on a Mac Mini (I bought into the dual 500GB model) to host some documents and act as a small cross-platform dropbox for any kind of files that need to be shared over a biomedical research-related network. A little o

  • [svn:fx-trunk] 12994: * Fixes for two issues that were showing up in FB.

    Revision: 12994 Revision: 12994 Author:   [email protected] Date:     2009-12-16 06:44:45 -0800 (Wed, 16 Dec 2009) Log Message: Fixes for two issues that were showing up in FB. QE notes: Doc notes: Bugs: SDK-24669, SDK-24686 Reviewer: Corey Cycloner:

  • Crystal reports version 12 vs version 11

    my company purchased crystal reports version 11 and got version 12 in error of course version 12 is an upgraded version so it was a keeper-----our hosting payroll site only works with version 11 and they said it would not be a problem if we created r

  • Setting Component rendered property On Page-Load

    I am using Jdeveloper 11g - fusion- web application. What I am trying to do is, onpageload, I am trying to over-ride some default properties of my uiComponents like rendered or read-only programatically.. I was referring to Steve Muench's Example no