Is it possible to add a property using variable in variable name?

I want to query for a list of virtual machines within a folder, then create a menu of the host names using forms.  Since the list of machines is subject to change, I want to build the list each time the script is run, rather than build off a static
list. 
For each virtual machine I need to create the list of variables below:
$hostnameX = New-Object System.Windows.Forms.checkbox
$hostnameX.Location = New-Object System.Drawing.Size(10,20)
$hostnameX.Size = New-Object System.Drawing.Size(100,20)
$hostnameX.Checked = $true
$hostnameX.Text = "Type"
$hostnameX.Controls.Add($hostnameX)
The location and size values need to be incremented but I think I can figure that part out.
I can use New-Variable to generate the initial variable. But I receive errors using the same method to try to create a new property for the variable.
$VMS = Get-Cluster MyCLUS | Get-vApp "My vApp" | Get-VM | Select Name,PowerState | Sort Name
For ($i=0; $i -lt ($VMS.count); $i++)
$VMS[$i].Name
$VMGUEST = "$($VMS[$i].Name)" -replace("-","")
New-Variable "CB$VMGUEST" "New-Object System.Windows.Forms.checkbox"
New-Variable "CB$VMGUEST.Location" "New-Object System.Drawing.Size(10,20)"
In the above, $CBVMGUEST1 =  New-Object System.Windows.Forms.checkbox which is what I want,  but $CBVMGUEST1.Location is not set.
Is there way to add a property using a variable in the variable name?  Or any other suggestions on how to tackle this issue?

Hi,
maybe another approach is a bit easier.
Use a hash-array like
$CB = @{}
$CB[$VMGUEST] = New-Object System.Windows.Forms....
$CB[$VMGUEST].Location = New-Object System.Drawing....
Mit freundlichen Grüßen Jens Kalski
That's the correct answer.  Anytime you find yourself wanting to create variables named "Widget1", "Widget2", "Widget3", etc... it's a pretty clear indication that what you really need is a collection object of some sort.  That might be an array,
a hashtable, or any other data structure for holding other objects, depending on your specific needs.

Similar Messages

  • Is it possible to add a user using the RESTful Web Services SDK

    Others have asked before about user management features in the RESTful Web Services SDK.  However I can find no answers or links which provide an answer to the question 'Is it possible to add a user using the BI 4.1 SP2 RESTful Web Services SDK'?
    Any help would be appreciated.
    Regards,
    Steve

    Hi Steve
    Unfortunately, not possible. The BI RESTful can only get "stuff" that is already there. I suppose this would fall under some sort of "Object Creation" API and that is not there. Yet. Rumors abound, but nothing firm. Just as a BTW.; the Business Intelligence platform RESTful Web Service Developer Guide 4.1 is here:
    http://help.sap.com/businessobject/product_guides/sbo41/en/sbo41_bip_rest_ws_en.pdf
    SAP Web Intelligence RESTful web service SDK User Guide, SAP BusinessObjects Business Intelligence platform 4.1
    SAP Crystal Reports RESTful web services - SAP Crystal Reports RESTful web services
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Is it possible to add tooltip when using REUSE_ALV_GRID_DISPLAY

    All,
    Is it possible to add tool-tip when using REUSE_ALV_GRID_DISPLAY. I am using
    i_fieldcat_alv  TYPE slis_t_fieldcat_alv.
    slis_t_fieldcat_alv does not have a tool tip option.
    Your earlier response is much appreciated.
    Regards
    Kasi

    Looks like it is NOT possible to add our own text for tooltip when using REUSE_ALV_GRID_DISPLAY.
    See attached thread
    Re: quickinfo in ALV

  • How can I use variable name as a prameter value in HOST Command ???

    Hi All,
    How can it possible to use variable value in parameter in HOST command ??
    Following in my code:
    host('rwclient server=reptest report=c:\cust_print.rdf p_1= s_sam_cust_id userid=wh1/wh1@dwh desformat=pdf desty=file desname=c:/temp/'||v_sam_cust_id||'.pdf');
    Regards

    Hello,
    The Syntax of the builtin HOST is :
    SyntaxPROCEDURE HOST
    (system_command_string VARCHAR2);
    PROCEDURE HOST
    (system_command_string VARCHAR2,
    screen_action NUMBER);
    So , you can build the system_command_string as any VARCHAR2
    Example are provided in online help :
    http://www.oracle.com/webapps/online-help/forms/10g/topics/f1_help/builth_m/host.html?tp=true
    Regards

  • Using variable name for Netstream Publish() (actionscript)

    Relatively new to Actionscript.  In the netstream publish() or play() methods, can I pass variable names to the methods instead of hard-coding the stream name?
    Example:
    private function publishLiveStream():void
                ns = new NetStream(nc);
                ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                ns.client = this;
              // blah blah other stuff...
               ns.publish("thefilename", "record");
    I want to replace "thefilename" with a value passed from an input box or use dynamic naming (i.e. current date & time).

    you can use in procedure using sunopisis technology
    OdiExportMaster "-TODIR=/temp/" "-ZIPFILE_NAME=export.zip" "-XML_CHARSET=ISO-8859-1" "-JAVA_CHARSET=ISO8859_1" "-EXPORT_VERSIONS=YES"
    or you can use (unix System)
    OdiExportMaster "-TODIR=/#v_FileName" "-ZIPFILE_NAME=export.zip" "-XML_CHARSET=ISO-8859-1" "-JAVA_CHARSET=ISO8859_1" "-EXPORT_VERSIONS=YES"
    Hope it will work
    Thanks

  • How to find Query name using Variable name (by Customer exit code in CMOD).

    Dear SDN,
    Enhancement name RSR00001.....Function Module name.....EXIT_SAPLRRSO_001...Include ZXRSRU01...
    Some x variable coding in done here.
    How can I find out the Query name for the X variable?
    Wating for reply...
    Thanks & Regards,
    Praveen.K

    Dear,
    I have got answer..
    Method 1 :Right click on variable in Query Designer and find the where used list.
    Method 2 : SE16--> RSZGLOBV -->Enter the variable VNAM as 'Variable Name' ->Get the VARUNIID> Go to table RSZELTXREF --> Enter the values of VARUNIID in TELTUID --> Get the list of SELTUID --> Go to table RSZCOMPDIR --> Enter the values of SELTUID in COMPUID --> Get the list of COMPID -->COMPID is the list of queries
    Thanks & Regards,
    Praveen.K

  • Is it possible to add text when using flashing button property node?

    I am trying to get a text button that displays TEST to show "running"
    when it flashes.  I am using a property node for flashing. 
    At present it cycles between TEST and default color which is set in
    flashing clolor options.

    hi there,
    use the "Strings[4]" property of the button. right click on the property node and see online doc for more information about the meanings of the 4 elements of strings[4].
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

  • How to add expression property using OMB+

    Hi,
    Is it possible to set the expression property for a attribute in the CONSTANT operator through OMB+ ?
    The following commend does not work
    OMBCREATE MAPPING map_name \
    SET PROPERTIES (BUSINESS_NAME, DESCRIPTION) \
    VALUES ('map name ', 'Mapping to test constant') \
    ADD CONSTANT OPERATOR 'CONST1'\
    ADD ATTRIBUTE 'NULL_DATE' OF GROUP 'OUTGRP1' OF OPERATOR 'CONST1' \
    SET PROPERTIES (EXPRESSION) VALUES ('NULL')
    Can anybody provide an example.
    Thanks,
    Sekar,K

    Thanks mark,
    I am not sure what i did wrong yesterday , today the statement is working ? I am using version 9.2.0.4.
    Yesterday initially i tried without operator name ,
    OMBCREATE MAPPING 'M' \
    ADD CONSTANT OPERATOR \
    ADD ATTRIBUTE 'A' OF GROUP 'OUTGRP1' OF OPERATOR 'CONST'\
    SET PROPERTIES ( EXPRESSION) VALUES ('NULL')
    This statement didn't work, after that i have tried with name i was getting different error.
    I will let you know if i am able to re-create the error..
    Does version 10g supports timestamp datatype ?
    Thanks for your help
    Sekar,K

  • Is it possible to add sticky note using Javascript?

    hi,
    I want to add some comments to acrobat file using Stcky note. I automated the text to be dynamic. And now, I wanted this text to be placed in sticky note.
    How it can be done? Would someone please suggest me?
    thanks in advance,
    shiva

    Use the doc.addAnnot method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.434.html
    with a type of "Text" and the "contents" set to the text you want to show: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.32.html

  • Using variable names for object names

    Is there any way you can use a String variable to name an object? I.e., something like:
    String name = "objectName";
    \\ create an Image object named objectName
    Image (name.valueOf()) = new Image();
    This code obviously does not work, but I'm working on a map applet which uses a map composed of thousands of tiles, and then shows only a portion of the map by drawing the appropriate tiles into the window using the x/y coordinates and a nested for loop to determine which tiles to draw. However, unless I want to manually declare and then call each of these Image objects, I need to have a way to have the actual name of each image object be a reference to a variable, which I will then initalize according to the name of the tile I'm using. Does that make sense at all? Anyway, I was just wondering if anyone knows of any way to do this. Thanks.
    -Ari

    Typically this is done using a Collection, for example:
    Image[] img = new Image[100];
    for (int i=0; i<img.length;i++)
      img[i] = new Image();... Sort of thing.

  • Using variable name for target dir in OdiExportMaster tool

    Hi
    I am using OdiExportMaster tool to export master repo on daily basis as backup. But for the target directory option in the tool, I am not able to use a variable (variable fetches the directory path from a pl/sql table).
    Please provide a solution for this.
    Thanks,
    Divya

    you can use in procedure using sunopisis technology
    OdiExportMaster "-TODIR=/temp/" "-ZIPFILE_NAME=export.zip" "-XML_CHARSET=ISO-8859-1" "-JAVA_CHARSET=ISO8859_1" "-EXPORT_VERSIONS=YES"
    or you can use (unix System)
    OdiExportMaster "-TODIR=/#v_FileName" "-ZIPFILE_NAME=export.zip" "-XML_CHARSET=ISO-8859-1" "-JAVA_CHARSET=ISO8859_1" "-EXPORT_VERSIONS=YES"
    Hope it will work
    Thanks

  • Using variable names in the jakarta img taglib

    I am using the jakarta image taglib for manipulating images, it is working fine with static names like this
    <img:image src="xyz.jpg"..etc
    but once I replaced the image name with this scriplet
    <img:image src="<%= book.img %>
    I got noting although I am sure that my scriplet has value but the image didn't show up, any idea
    thank you

    the problem was solved I've used the EL notation instead of scriplet and it worked
    <img:image src="${book.img}..etc
    thank you

  • [svn:fx-trunk] 11171: Add overlay property to GroupBase.

    Revision: 11171
    Author:   [email protected]
    Date:     2009-10-26 16:24:13 -0700 (Mon, 26 Oct 2009)
    Log Message:
    Add overlay property to GroupBase. Note, names of class and APIs will change, since it's still in review.
    QE notes: Ready testing, names will change after the APIs review.
    Doc notes: None
    Bugs: None
    Reviewer: Deepa
    Tests run: checkintests, mustella (all gumbo tests)
    Is noteworthy for integration: No
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Accordion.as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/ViewStack.as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/core/Container.as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/DataGroup.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/Group.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/GroupBase.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutBase.as
    Added Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/DisplayPlane .as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/OverlayDepth .as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/events/DisplayPlaneObjectExistenceEven t.as

    Thats good news.

  • Retrieve the message put in message header using variable substitution

    hi,
    i am using dynamic configuration to put some information in the message header.is it possible to retrieve the message using variable substitution and if it is possible then how it be done using variable substitution.
    regards,
    Meenakshi

    Variable Substitution does not allow you to read all the messaeg header elements only some of them can be read/ access....for more info on how to read the message header elements refer: /people/jin.shin/blog/2007/04/27/sap-netweaver-xi-variable-substitution-with-adapter-specific-message-attributes-via-dynamicconfigurationbean
    From the above blog:
    When using Variable Substitution, only certain standard message header attributes can be used/accessed (e.g. sender_party,
    sender_service, receiver_party, receiver_service, interface_name, interface_namespace, message_id)
    Better use Dynamic Configuration to read the parameters.
    I am wondering why you need to read the message header parameters when you are putting them using Dynamic Configuration.....cant you just get the details from the dynamic configuration UDF itself?
    Regards,
    Abhishek.
    Edited by: abhishek salvi on Dec 10, 2009 1:18 PM

  • Using variables in a jsp:useBean tag

    I was wondeing if it is possible in any way to use variables in a jsp:useBean tag. Here is an example of what I am trying to do.
    <%
    String beanType = request.getParameter( "bean" );
    if( beanType.equals( "Bean1" ) ) {
    beanClass = "com.myCompany.Bean1";
    } else {
    beanClass = "com.myCompany.Bean2";
    %>
    <jsp:useBean name="<%= beanType %>" class="<%= beanClass %>"/>
    I also tried using this approach
    <%
    if( beanType.equals( "Bean1" ) ) {
    %>
    <jsp:useBean id="bean" class="com.myCompany.Bean1"/>
    <%
    } else if( beanType.equals( "Bean2" ) ) {
    %>
    <jsp:useBean id="bean" class="com.myCompany.Bean2"/>
    <%
    %>
    Neither approach seems to work. Is there any way around this problem?
    Thanks,
    Marcus.

    Hi,
    check:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=398998&tstart=75&trange=15

Maybe you are looking for

  • Changing update mode in Error DTP

    Hi Gurus, I have some issues with data in PSA. I am trying to solve it using Error DTP. While Executing DTP one record failed to load giving bad request. Now i created an error DTP. By default the extraction mode is Delta. DTP extraction Mode->Full E

  • HELP!  Corrupt Library...Can It Be Restored?

    I have my iPhoto library on an external hard drive.  The other day when I was importing photos from my iPhone, the drive dropped.  I was able to access the photos no problem right after the drop...no loud noises or whining.  I began backing up all my

  • My time capsule has stopped working.

    My time capsule has stopped working. I get following error message The backup disk image "/Volumes/Michael Campbell's Time Cap/iMac.sparsebundle" could not be accessed (error -1). I tried everything including deleting all the data and starting again.

  • I have an iPad2 and am ready to purchase an iPad Air. Will I be able to transfer all my content to the new iPad?

    I have an iPad 2 and am ready to purchase an iPad Air. Will I be able to transfer all my photos, apps and content to the new iPad?

  • RSS feed: Invalid XML

    Hello everyone. I want to submit my podcast to iTunes, but I have a problem with the XML file. Feed Validator said to me: Sorry This feed does not validate. line 1, column 0: XML parsing error: <unknown>:1:0: not well-formed (invalid token) [help]{\r