Pulling hash out of loops (foreach)

Hi,
Hope this is the right group.  I have encountered variants of this off and on for some time, and would like to find a good explanation of what is going on.  In this case, I have a file with what I'll call "userid" on it, one per line:
user01
user02
user03
Right now, I'm reading it with import-csv, but get-content should work as well.  I read the file, then pass each userid to the get-mailbox cmdlet to obtain the PrimarySMTPAddress and DisplayName. 
$list = Import-Csv -Path path/file.csv -header "address"
ForEach ($address in $list) {
$address
# get-mailbox -identity $address |select-object PrimarySMTPaddress,displayName
If I execute as above, using $address, I will get
address
user01
user02
user03
If I uncomment the Get-Mailbox cmdlet and use $address as the Identity parm, I get:
Cannot process argument transformation on parameter 'Identity'. Cannot convert value "@{Address=user01}"
to type "Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter".
Error: "Cannot convert hashtable to an object of the following type: Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter. Hashtable-to-Object conversion is not supported
in restricted language mode or a Data section."
I am sure I am just overlooking something here, but shouldn't it be fairly straightforward to pass these? I realize that data types gives powershell a lot of power.  Most examples I see of Foreach provide examples more like the "$address"
above, but how to pull the value out of the hash?  While I may be overlooking something, this might also be a more complex topic than it seems, so any links on the subject are appreciated.
Thanks,
--Joe 

Of course; just use the column name as the property of the object. For example:
$csvData = @(
new-object PSObject -property @{
"Name" = "Value 1"
new-object PSObject -property @{
"Name" = "Value 2"
foreach ( $row in $csvData ) {
$row.Name
# Output:
# Value 1
# Value 2
-- Bill Stewart [Bill_Stewart]

Similar Messages

  • Program times out while looping at internal table with huge records - Needs fine tuning suggestions

    Hi,
    I am trying to execute a report. It times out while looping at vbap internal table. This internal table has 140000  records and does the validation within this loop and geenrates data for the output. Due to this huge volume, the program times out when executed foreground.
    There are no nested loops, so I cannot apply 'Parallel Cursor' here.
    Is there any way I can fine tune the program so that it doesn't timeout? Is it possible to apply 'Parallel Processing' . If yes, how?
    Thanks,
    Pavan

    Hi Pavan ,
                  ->sort your internal table by all primary key for vbap.
                  ->Read a Record from the table (use your condition here)
                  ->if record satisfys your where condition ,get that record index .
                  ->loop the table from the index (without condition) .
                  its like parallel cursor only but for single loop .;-)
                  ->use field symbols ,wherever possible .
               if still dump is coming ,contact your basis team .
    regards,
    Krishna.

  • I placed my ipad on top of my CPU with a music playing,i heard a crack on the sound and when i checked it,i can no longer hear a sound playing on my ipad.i tried to check place a headphone its still playing a sound but when i pull it out,wont play at all.

    i placed my ipad on top of my CPU with a music playing,i heard a crack on the sound and when i checked it,i can no longer hear a sound playing on my ipad.i tried to check place a headphone its still playing a sound but when i pull it out,wont play at all.

    I don't know if this will work but it's worth a try. I wonder if somehow you ended up with a short inside of your iPad. Give the things below are trying to see if that helps. Good luck.
    Try a Restart. 
    Press and hold the Sleep/Wake button for a few seconds until the red "slide to power off" slider appears, and then slide the slider. Press and hold the Sleep/Wake button until the Apple logo appears.
     Resetting your settings
    You can also try resetting all settings. Settings>General>Reset>Reset All Settings. You will have to enter all of your device settings again.... All of the settings in the settings app will have to be re-entered. You won't lose any data, but it takes time to enter all of the settings again.
    Resetting your device
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears. Apple recommends this only if you are unable to restart it.
    Or if this doesn't work and nobody else on the blog doesn't have a better idea you can contact Apple. 
    Here is a link to their contacts with most of the information below. 
    http://www.apple.com/contact/

  • I just tried to copy a folder to a pen drive from my mac. It transferred fine. I then ejected the pen drive then pulled it out. When I pulled it out it said it had not ejected correctly despite me just Doing this. The folder is now missing from both! Help

    I just copied a folder from my desktop to my pen drive. It transferred fine. I then ejected the pen drive then pulled it out. On doing so it said it had not been ejected properly!!!!! The folder is now missing from my computer and the pen drive. Pulling my hair out please help!

    When youi say Eject, the RAM copy of the Directory is written back to the drive. On a pen drive, this can take several seconds.
    If you get too excited and don't wait those few seconds, the directory write will be incomplete, and the drive will lose its integrity or lose files or both.

  • The other day I had to reset my phone because i pulled it out from my laptop when it was updating. I then tried to restore it but i clicked the wrong option and it has restored all of my stuff from 2 years ago, is there any way to get back the stuff I had

    The other day I had to reset my phone because i pulled it out from my laptop when it was updating. I then tried to restore it but i clicked the wrong option and it has restored all of my stuff from 2 years ago, is there any way to get back the stuff I had

    maggielou wrote:
    I thought that I had backed up my pictures to icloud, but when I looked online at icloud, I don't see pictures listed.  However, a few of the recent pictures have shown up on my phone.
    IHow could I get these from my MacBook to my phone?
    Thanks again.
    When you log into you icloud account on your computer you are viewing data that you sync to icloud not the backups.  You can't view the backups.
    Look at the two links I provided.
    You still didn't answer any of my two questions I asked.

  • How to cast vector to vector with out using loop. and how to override "operator =" of vector for this kind of condition.

    Hi All How to TypeCast in vector<>...  typedef  struct ...  to class... 
    //how to cast the vector to vector cast with out using loop
    // is there any way?
    //================ This is Type Definition for the class of ClsMytype=====================
    typedef struct tagClsMytype
    CString m_Name;
    int m_Index;
    double m_Value;
    } xClsMytype;
    //================ End of Type Definition for the class of ClsMytype=====================
    class ClsMytype : public CObject
    public:
    ClsMytype(); // Constructor
    virtual ~ClsMytype(); // Distructor
    ClsMytype(const ClsMytype &e);//Copy Constructor
    // =========================================
    DECLARE_SERIAL(ClsMytype)
    virtual void Serialize(CArchive& ar); /// Serialize
    ClsMytype& operator=( const ClsMytype &e); //= operator for class
    xClsMytype GetType(); // return the typedef struct of an object
    ClsMytype& operator=( const xClsMytype &e);// = operator to use typedef struct
    ClsMytype* operator->() { return this;};
    operator ClsMytype*() { return this; };
    //public veriable decleare
    public:
    CString m_Name;
    int m_Index;
    double m_Value;
    typedef struct tagClsMyTypeCollection
    vector <xClsMytype> m_t_Col;
    } xClsMyTypeCollection;
    class ClsMyTypeCollection : public CObject
    public:
    ClsMyTypeCollection(); // Constructor
    virtual ~ClsMyTypeCollection(); // Distructor
    ClsMyTypeCollection(const ClsMyTypeCollection &e);//Copy Constructor
    DECLARE_SERIAL(ClsMyTypeCollection)
    virtual void Serialize(CArchive& ar);
    xClsMyTypeCollection GetType();
    ClsMyTypeCollection& operator=( const xClsMyTypeCollection &e);
    ClsMyTypeCollection& operator=( const ClsMyTypeCollection &e); //= operator for class
    void Init(); // init all object
    CString ToString(); // to convert value to string for the display or message proposed
    ClsMyTypeCollection* operator->() { return this;}; // operator pointer to ->
    operator ClsMyTypeCollection*() {return this;};
    public:
    vector <ClsMytype> m_t_Col;
    //private veriable decleare
    private:
    //===================================================
    ClsMytype& ClsMytype::operator=( const xClsMytype &e )
    this->m_Name= e.m_Name;
    this->m_Index= e.m_Index;
    this->m_Value= e.m_Value;
    return (*this);
    //==========================Problem for the vector to vector cast
    ClsMyTypeCollection& ClsMyTypeCollection::operator=( const xClsMyTypeCollection &e )
    this->m_t_Col= (vector<ClsMytype>)e.m_t_Col; // how to cast
    return (*this);
    Thanks in Advance

    Hi Smirt
    You could do:
    ClsMyTypeCollection* operator->() {
    returnthis;};
    // operator pointer to ->
    operatorClsMyTypeCollection*()
    {returnthis;};
    public:
    vector<ClsMytype>
    m_t_Col;//??
    The last line with "vector<xClsMytype>
    m_t_Col;". It compiles but I doubt that is what you want.
    Regards
    Chong

  • HT4061 I am traveling from Ontario to BC and had my iPad in my bag and no banging or anything out of the ordinary and when I pulled it out I noticed it was cracked what can be done

    I'm traveling from Ontario to BC via car and had my iPad in my bag with me in the back seat? Nothing out of the usual stopping for gas and when I
    Pulled it out I noticed a huge crack and not sure what happen or what can be done please help

    Accidental damage is not covered by warranty.
    It will cost you approximately US$219.00 to US$299.00 depending on the model.
    Apple will replace the entire iPad; they don't repair.
    http://support.apple.com/kb/index?page=servicefaq&geo=United_States&product=ipad

  • Hi, I have a freecom 1TB hard drive which was working fine until it froze.  I pulled it out (mistake I now know) and now it doesn't mount.  It shows up in Disk Utility but won't manually mount.  When I try to repair it gives message 'failed on exit'.  hel

    Hi, I have a freecom 1TB hard drive which was working fine until it froze.  I pulled it out (mistake I now know) and now it doesn't mount.  It shows up in Disk Utility but won't manually mount.  When I try to repair it gives message 'failed on exit'. Some people have said to try Disk Warrior, but at $100 it's quite expensive maybe fix.  help!

    You likely need to reformat the drive which will destroy all data and you need a backup to restore it. If no backup is present then a data retrieval service can be more expensive than DiskWarrior. There is software that can rescue the data but I can not vouch for it's effectiveness as I have always maintained backups. .
    http://www.prosofteng.com/
    http://www.wondershare.net/ad/data-recovery-mac.html?gclid=CLTp3Mj07rkCFevm7AodL lUAHw
    http://diskdoctors.com/software/mac-data-recovery/utility.asp?gclid=CMyf_MH17rkC Fcvm7AodSE0A8A
    http://www.cleverfiles.com/

  • Pulling info out of service

    I found a quick cfc for creating a service in CF8:
    <cfcomponent>
    <cffunction name="sayHello" access="remote" hint="I say
    hi!" returntype="string">
    <cfargument name="to" hint="Whom to say hi to."
    required="false" default="world" type="string" />
    <cfreturn "Hello, #arguments.to#" />
    </cffunction>
    </cfcomponent>
    After I view the page (
    http://localhost:8500/TestingCF/service2.cfc?wsdl) it shows
    up with xml tags.
    My question is how do I pull info out of the xml tags into a
    user friendly view?

    what sort of 'user-friendly view' are you talking about?
    you want to present the ws structure details to the user?
    or you want the user to enter a name and receive "Hello,
    [name]!"
    response on the page?
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

  • Pulling Objects out of a Vector

    Hi, all:
    I am trying to pull Objects out of this vector, and the given method only wants to let me get integers. How do I go about getting Objects out of a vector like this one? The problem comes in with the last line, where the "get" method complains that it wants an integer. The API says the same; I just can't find a method that lets me pull an Object out of a vector instead of an integer. Any ideas?
              neighborList = new Vector();
              soldierNeighbors = new Vector();
              neighborList = world.getMooreNeighbors(x, y, false);
              for (int i = 0; i < neighborList.size(); i++){
              Soldier soldier = neighborList.get (soldier);

    Soldier soldier = neighborList.get (soldier);You'll want to use "i" as your index, not "soldier", since you presumably want to get the soldier reference at element 'i'. Note that since you're not using generics, the get() method returns an Object reference. You'll need to cast it to Soldier. Example:
    Soldier soldier = (Soldier) neighborList.get(i);Read more here: http://java.sun.com/docs/books/tutorial/collections/
    ~

  • I reinstalled my computer because it was too slow, and Safary icon has a ? question mark on it in the dock, i  pulled it out with the hope that  i can bring it back from the application, but the icon could not be found in the application. Pls help me.

    Could you pls help me? i reinstalled my computer and the Safari Icon has a ? mark on it in the dock, I pulled it out and it disappeared, I checked for this icon in the application folder but couldnt find it there.  So for me to go on Internet i have to open Firefox first. 2. The message Java Plug in has been disable appeared immediatle after the reinstallation. I need help from the community pls.

    Welcome to the Apple Support Communities
    I think that your Mac detects your hard disk, but the problem is that your new hard disk doesn't contain any operating system, so your Mac doesn't find any bootable partition and you see a question mark.
    If your Mac came with DVDs, insert the Mac OS X Install DVD and hold the C key while your Mac is starting. Then, just install Mac OS X. If the hard disk isn't prepared to install Mac OS X, you will have to erase it using "Mac OS Extended (Journaled)". See > http://pondini.org/OSX/DU1.html

  • Best Practices for pulling data out of Documentum (w/Crystal and Universe)

    I was curious to see if we had any best practices to see if we can pull data out of Documentum.
    Thanks
    Ian S

    None, use what works.

  • Never get out of loop

    With the below example, Im never getting to the "Out of loop message".It iterates through loop alrite but never comes out of it.
    Any ideas anyone?
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ((line = br.readLine()) != null) {
    System.out.println("In loop");
    System.out.println("Out of loop");

    I think it something to do with the fact that the readline method reads to a '/n' and the stream may not have this termination point.

  • Saving image file as binary into database + pulling it out + displaying

    Hi guys, this is exactly I have to do, and have no ideal how to do.
    It will be greatly appreciated if you can offer help on this.
    I don't have a problem putting it into and pulling it out fo the database, it is really the jpg-> binary, and binary->display part that I need help on.
    Btw, I am currently using "draw Flatten PixMap.VI" to display a picture in labview, from a jpg file. Can I still use this VI to achieve what I intend to do?

    Have you tried this:
    Saving a binary file to a database with the Database Connectivity Toolset
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • Pulling photos out of finder for creating a slideshow

    Is it possible to pull photos out of the Finder to create a slideshow?

    On the machine on your signature yes.  You can use the Preview application to open all the photos in a folder, and create a slideshow once they have loaded.
    On a Classic Mac operating system from 14 years ago, I recommend using http://www.lemkesoft.com/ GraphicConverter, or the postcard ware:
    http://www.mac.org/graphics/jpegview/

Maybe you are looking for

  • Problems with BBC iPlayer Desktop and Adobe Air for Mac

    I would be grateful for anyone who can help me with a problem I have on my Laptop running Mac OS X Lion 10.7.3.I am having difficulty running BBC iPlayer Desktop and I suspect it is caused by Adobe Air. Recently I was prompted to update Adobe Air to

  • How can I improve the terrible results from Type in Photoshop?

    Hello all, I have a blog on which I need to add type to each and every photos for copyright purposes. The trouble is that the post photos are maxed out @ 144 dpi, and thus I use only sizes 6-8 for my fonts. The reason for the small font size is propo

  • How to disable the link for Credit -check at item level

    Hi Experts, I have an issue tht we want to make a block to the link available for credit-release at item level. In the view of the item, when we select the item in edit view we have a button saying MORE and in tht we have CHEC CREDIT RELEASE. We want

  • Timeout problem using HTTP connection in MIDP

    Hi, I have one thread that does a HTTP connection (StreamConnection)with the server. In some cases, the connection is established to the server and request is sent to server, then connection hangs. I cannot check the response code since the response

  • What dpi should I use when making a file for a HD (1920x1080px) in Photoshop??

    I am making a graphic for an HD (1920x1080px) in Photoshop and I wanted to know which dpi Should I use? 72dpi?100dpi?300dpi? I dont want this to bee seen bad in a big screen...=S Thanks in Advance, Orangejuice.-