mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 Excel Scirptography

Author Message
djrevelation

  • Total Posts : 17
  • Scores: 0
  • Reward points : 0
  • Joined: 3/11/2009
  • Status: offline
Excel Scirptography Wednesday, June 10, 2009 5:58 AM (permalink)
0
I am still working on a stupid script to compare data from muliple cells to another file and multiple cells.

I have been trying to figure out how to write:

If cell a1 has a servername in it, and that server name is in the same as in a1 cell in another excel file, then look at the data in cells C (as long at there is the same server name in cell A...

Does this make sense? I am so frustrated with this one.
All I want is a simple script that I can compare my local admin group (on local srvrs) permissions, to another document with the same information. I have tried import-csv and compare-object, but have had issues with it. It is so plain. I need the script to be smarter.
#1
    mcds99

    • Total Posts : 515
    • Scores: 4
    • Reward points : 0
    • Joined: 2/28/2006
    • Status: offline
    Re:Excel Scirptography Thursday, December 10, 2009 10:02 AM (permalink)
    0
    Does this have to be in PowerShell?
     
    VBScript will do this.  Do a search in the forum for Excel there are many Excel scripts that are close to what you want to do.
    Sam

    Keep it Simple Make it Fun KiSMiF
    #2
      ebgreen

      • Total Posts : 8088
      • Scores: 95
      • Reward points : 0
      • Joined: 7/12/2005
      • Status: offline
      Re:Excel Scirptography Thursday, December 10, 2009 12:38 PM (permalink)
      0
      Could you give a couple of small samples of the data in the file?
      "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
      Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
      http://www.visualbasicscript.com/m_47117/tm.htm
      #3
        ebgreen

        • Total Posts : 8088
        • Scores: 95
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        Re:Excel Scirptography Friday, December 11, 2009 6:40 AM (permalink)
        0
        Ok, without samples of your data, I just made up a couple of csvs to demonstrate how I would do this.

        In the first one (one.csv) I put this:

        Server,something,Permissions
        ServerOne,foo,permissionsOne
        ServerTwo,foo,permissionsTwo
        ServerThree,foo,permissionsThree

        In the second one (two.csv) I put this:

        Server,something,Permissions
        ServerOne,foo,permissionsOne
        ServerTwo,foo,permissionsTwoAltered
        ServerFour,foo,permissionsFour


        So serverOne is in both and has the same permissions in both, serverTwo is in both but has different permissions in each one, serverThree is only in one.csv, and serverFour is only in two.csv.

        Note that this is just a rough demo. There is nothing in it to handle case sensitivity for instance.

        $hashOne = @{}
        $csvOne = Import-CSV one.csv
        $csvTwo = Import-CSV two.csv
        $hashTwoOnly = @{}
        $hashBothDifferent = @{}
        $hashBothSame = @{}
        foreach ($item in $csvOne)
        {
         $hashOne[$Item.Server] = $item.Permissions
        }
        forEach ($item in $csvTwo)
        {
         if ($hashOne.ContainsKey($item.Server))
         {
          if ($hashOne[$item.Server] -eq $item.Permissions)
          {
           $hashBothSame[$item.Server] = $item.Permissions
          }else
          {
           $hashBothDifferent[$item.Server] = @{}
           $hashBothDifferent[$item.Server]['FileOne'] = $hashOne[$item.Server]
           $hashBothDifferent[$item.Server]['FileTwo'] = $item.Permissions
          }
          $hashOne.Remove($item.Server)
         }else
         {
          $hashTwoOnly[$item.Server] = $item.Permissions
         }
        }
        'The following servers were in both files and had identical permissions:'
        foreach($name in $hashBothSame.Keys)
        {
         "$name -> $($hashBothSame[$name])"
        }
        ''
        ''
        'The following servers were only in file one:'
        foreach($name in $hashOne.Keys)
        {
         "$name -> $($hashOne[$name])"
        }
        ''
        ''
        'The following servers were only in file two:'
        foreach ($name in $hashTwoOnly.Keys)
        {
         "$name -> $($hashTwoOnly[$name])"
        }
        ''
        ''
        'The following were in both files but had different permissions listed:'
        foreach ($name in $hashBothDifferent.Keys)
        {
         "$name ->"
         "`tFile One -> $($hashBothDifferent[$name]['FileOne'])"
         "`tFile Two -> $($hashBothDifferent[$name]['FileTwo'])"
        }

        The output from this is:

        The following servers were in both files and had identical permissions:
        ServerOne -> permissionsOne
        The following servers were only in file one:
        ServerThree -> permissionsThree
        The following servers were only in file two:
        ServerFour -> permissionsFour
        The following were in both files but had different permissions listed:
        ServerTwo ->
                File One -> permissionsTwo
                File Two -> permissionsTwoAltered
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.8
          mbt shoes www.wileywilson.com