Reference the "Noteproperty" of an object from within a string

Hello...this is more of a learning question...I am just curious if there is a more effecient way to do something:
Lets say I have the following code (simplified version of what am I actually trying to do):
$ServerObject = New-Object System.Object
$ServerObject | Add-Member -Type NoteProperty -Name ServerName -Value "MYSERVER"
$ServerObject | Add-Member -Type NoteProperty -Name OS -Value "WIN2008R2"
$Server = $ServerObject | Select-Object ServerName,OS
And I want to do something like this:
Write-Host "$Server.ServerName is blah blah blah...."
But obviously this does not work.  Is there a way to code this without creating a second variable?  For example, I know this will work:
$MyServerName = $Server.ServerName
Write-Host "$MyServerName is blah blah blah"
But I am wondering if there is a better way to do this without a second variable.  I have tried:
$(Server).ServerName
$(Server.Server)
{$Server.ServerName}
And a few others - but none of these work (other than using a second variable).  Obviously my real script involves 100's of servers in an array of objects, but for purposes of my question, the above code similutes what I am trying to do.  I have
also looked into concatenating the strings, but in my real script I am using Out-File and it tells me I cannot use the "+" operator for the -Input parameter...so I would still have to use a second variable.
Thanks
NK

I was soooo close!  Thanks.  Oh and I think you missed a "(".  I think it should be:
Write-Host "$(($Server).ServerName) is blah blah blah"
thanks again,
NK

Similar Messages

  • How do I check if the ctrl key is pressed from within a mouseReleased actio

    How do I check if the ctrl key is pressed from within a mouseReleased action?
          addMouseListener( new MouseAdapter() {
             public void mouseReleased( final MouseEvent e ) {
               // If ctrl button is held down and mouse is clicked, do something
             }};

    Found it, I think
        e.isControlDown()

  • I have CS 6 installed on a Win 7 OS machine. I can not connect to the internet to get updates from within the program. How do I fix this?

    I have CS 6 installed on a Win 7 OS machine. I can not connect to the internet to get updates from within the program. How do I fix this?

    IP routing doesn't work the way many folks might initially think it does; functional IP routing requires manual configuration and the establishment of static routes and default routes specific to the local network configurations, and it's very easy to get it wrong, or to get the default route swapped. Multiple NIC boxes don't magically work, either. (Been there, done that, wondered what happened to my network when the paths got reordered or my route settings were messed up, etc.)
    Routing configuration errors can be quite subtle, too. (Again, voice of experience. Ever had a thousand-seat office LAN accidentally routing through your desktop? As the, um, unnamed guilty party discovered, getting into that configuration was subtle. Seeing the performance crater on the fellow's box and on the LAN was obvious.)
    Knowing how IP routing works is a prerequisite to getting this configuration to work; there's manual configuration required. Clearly something has gone weird here.
    What to do? Read up on IP routing. I'll again suggest the threads and the manual mentioned earlier.
    And in general, I prefer to avoid using my comparatively expensive Mac boxes as sub-optimal IP routers or as firewall boxes. General-purpose operating systems and generic x86 boxes are going to be inherently poor IP routers. Dedicated routers (or embedded or surplus x86 boxes with routing software loaded) offload the Mac boxes here, and are also typically easier to configure manage. And "real" IP routers can have hardware specific to efficiently routing packets. Use of an outboard firewall or firewall-router box also greatly simplifies gateway routing, too; it's a configuration that many folks and many businesses tend to use.

  • Accessing java objects from within javascript

    Hello,
    Anyone with an idea of a useful toolkit for accessing java objects from within javascript will be much appreciated.
    Thanks in advance,
    Antana.

    What do you mean by accessing Java objects? Do you mean interacting with an applet via JavaScript? Something else?

  • OBIEE - Find position of the last occurrence of a charcter within a string.

    Hi,
    I have a requirement in 11.1.1.6.9 to be locate the position of the last occurrence of a character within a string.
    i.e. Given the following, I would want to locate the last "/":
    This/is/an/exampleI would like to return a value of 11. Now, there could be any number of "/" so I can't always locate the nth one - it must be the last one.
    Anyone any ideas?
    Thanks,
    John

    Your requirement is not complete. just in case you want to extract the last part 'example' just use substring and replace to trim up to required part.
    You may have to go for the same for multiple times.
    ETL is the best to handle this than BI.
    BTW: Check this How to use locate function if multiple occurences of same character
    Edited by: Srini VEERAVALLI on May 10, 2013 10:25 AM
    Good that given link is helped you to solve it ;)
    Edited by: Srini VEERAVALLI on May 13, 2013 7:47 AM

  • Instantiating COM objects from within the java code in WLS

    is there a way to use COM objects from servlets or ejb's,
    with JVM, not with JView.
    thanks,
    ali.

    Sun has released a beta product - its a COM bridge that you can use
    to connect a Java2 JVM to a COM object with. I havent tried it yet
    but I probably will soon.
    Brad
    "Michael Girdley" <[email protected]> wrote in message news:39b86deb$[email protected]..
    >
    >
    No, at the current time we only support COM integration when using the
    Microsoft JVM. The Jintegra product from Linar is good.
    Thanks,
    Michael
    Michael Girdley
    BEA Systems Inc
    "Ali Ozgun" <[email protected]> wrote in message
    news:[email protected]..
    is there a way to use COM objects from servlets or ejb's,
    with JVM, not with JView.
    thanks,
    ali.

  • How can I check the progress of a Loader from within a movie clip?

    Hi All,
    I have a Loader called profileContentLoader that I create in AS3 on the main timeline, I would like to check the bytesLoaded of profileContentLoader from within a movieclip thats in another movieclip....
    I tried:
    MovieClip(root).profileContentLoader.bytesLoaded
    but that doesn't work....
    Thanks for any help

    The Loader class uses a LoaderInfo class object to do its loading event informational bidding.  Look into the contentLoaderInfo property of the Loader class and then followup looking at the LoaderInfo class to see what you can make use of from it.

  • Client unable to get the javax.activation.DataHandler object from Server

    Hi All,
    I am trying to download the file from the server to the client using Javax.Activation.Data Handler object with IBM web services. But server always returning the Data Handler object is null. I am wondering why it is behaving like this.
    My requirement is add the file to the Data Handler object from the server and read the same from the client. But I am always getting Data Handler object is  null at the client place.
    Please see the client side code and server side code below.
    Server side Code:
    This is the simple web service method, its creating the Data Handler object and adding it to the Hash Map and returning the Hash Map object to the client.
    public Hashtable download()
              DataHandler dh = null;
              HashMap hashMap =new HashMap();
              try{
                   //Sample test files contains data
                   String downLoadFName="C:/ADP/downLoadData.txt";
                   //Creating the DataHandler Object with sample file
                   dh      =      new DataHandler(new FileDataSource(new File(downLoadFName)));
                   //Keeping the DataHandler object in the HashMap.
                   hashMap.put("DATAHANDLER",dh);
                   //keeping the sample test message object in the HashMap
                   hashMap.put("TEST","Keeping the DataHandler and test messages in the hashTable");                         
              }catch(Exception e){
                   logger.error("Error :while sending the data:"+e.getMessage(), e);
              //retrun the HashMap object to the client.
              return hashMap;
    Client Side Code:
    This is the simple client code, and connecting to the server and invoking the web service method
    //This is the client code,Just invoking the webservice method from the Webspehre server.
    public class WebserviceClient {
         static DocumentTransfer controller     =     null;
         public static void main(String args[]){     
                DocumentTransferService service          =     null;
              try{
                   //Creating the service Object
                   service               =     new DocumentTransferServiceLocator();
                   //Getting the Server connection
                    controller          =      (DocumentTransfer)service.getDocumentTransfer(new java.net.URL("http://localhost:9081/eNetsRuntimeEngine/services/DocumentTransfer"));
                    //Calling the download method from the server and it returns HashMap object.
                   HashMap hashMap     = controller.download();
                   //Getting the DataHandler Object from the HashMap
                    DataHandler dh=(DataHandler)hashMap.get("DATAHANDLER");
                   System.out.println("DATAHANDLER: :"+dh);
                   //Getting the String object from the HashMap.
                   String message=(String)hashMap.get("TEST");
                   System.out.println(": :"+message);
               }catch(Exception e){
                    System.out.println("Exception :Not able to get the file :"+e.getMessage());
    Could you please give me some inputs on this?
    Thanks in advance,
    Sreeni.

    Hi Stif,
    Thanks for your response.I did debug from server side,it has printing content of Data Handler properly.
    Also i have debug request and response messages using TCP/IP monitor(RAD environment has this feature).The response from the server is going proplery.
    But the client side Data Handler is coming null.
    Any advice or solution would be greatly appreciated.
    Thanks,
    Sreeni.

  • Triggering the creation of a quotation from within an Opportunity...

    We have implemented CRM Best Practice (CRM 7) and want to trigger the creation of an ERP quotation from within an Opportunity. Within the customising to assign the ERP order type to the CRM transaction type,
    when input help is pressed, no values are returned. CRM is not seeing the ERP order types.
    I have been informed that this is correct and that we need to create the order in CRM and then forward to ERP. However, this will never do, especially as CRM does not have all the information to successfully raise an order.
    I was wondering if anyone had encountered a similar problem and found a way around it. I'm aware that we can probably use the transaction launcher to create an order in ERP and return to CRM, but how this is triggered is another matter.
    Any advice and suggestions would be very much appreciated.
    Jason

    Thanks to all. We have had a reply back from SAP to say that what we trying to do is not possible. We have CRM 7 and ERP ECC5, however SAP are saying that we need at least 2005 on our ERP system for this functionality to work.
    Basically, when in config we attempting to set up the document types, but none are being displayed.
    SAP connected to our system and after analysis said that the cutsomers ERP system (ECC 5) needs to be upgraded to a minimum of ERP 2005, which I find to be an absolute crazy statement to make. Apparently, according to note 1236015 a minimum of ERP 2005 is required to maintain ERP sales transactions in CRM 7.0's CRM webclient UI.
    They debugged CL_CRM_INTLAY_LORD1_ERPIL
    IF_CRM_ERP_LORD_HELP_VALUES~GET_AUART
    Which seems to call FM SLS_LORD_GET_VALUES_AUART but does not exist in ECC 5.
    When tested in our CRM 7 system (not the clients) we do get a list of doc types appear, but then we are on the latest version of ERP.
    I was wondering whether there was a service patch to ECC 5 which might add the function group SLS_LORD_SHLP and assocaited function modules and includes, together with the class CL_FIELD_CONVERT.  That looks to be everything needed to run in ECC 5 from looking at our ECC 6 system. I'm never sure where ERP 2005 sits, is that a higher than version than ECC 6?.
    Jason

  • Getting the list of downloaded jars from within a ws app

    How do I query from within a webstart launched application about the list of jars downloaded and their version numbers?
    Is this even possible using the apis provided?
    Thanks a million!

    Hi,
    I recently got the same problem and after a day of searching and trying I gave up. So, if anybody has a solution... Let me know!

  • How to get the client's IP address from within Java Studio Creator JSP/Java

    Hi there.
    I just started using the Java Studio Creator 2 and now I need to get hold of the client IP address - this should be part of the request, but I cannot fint the right way to get hold of that information. I want to be able to access this information from within the Java-code in a JSP/JSPF-page.
    Is there a new way of doing:
    request.getRemoteAddr();
    This is the way I remember it from the JSP/Servlet-days...
    Sincerely,
    - Oystein Saebo -

    javax.servlet.http.HttpServletRequest req = (javax.servlet.http.HttpServletRequest) getExternalContext().getRequest();
    req.getRemoteAddr();

  • Cannot get Yahoo email with the built-in email app from within my company's network

    Hello,
    From within my company's network, I can get Yahoo email if I use the Yahoo email app but not if I use the iPhone built-in email app (iPhone 5 and iPad 4 both running iOS 7.1.2). Any idea what may be going on?
    Could it be that the two apps use different ports to get email (and one port happens to be blocked by the company's firewall/proxy)? If yes, anyone knows what these ports may be?
    Thank you in advance

    akoutalos wrote:
    Could it be that the two apps use different ports to get email (and one port happens to be blocked by the company's firewall/proxy)?
    That's entirely possible. Talk to your IT department about it. Attempting to bypass their security and potentially violating their security policy may not be good for your career.

  • Change the Blu-Ray burn speed from within PRE9

    I burned a 2 hour video to Blu-Ray last night from within PRE9, and it all turned out well. Except it took maybe 5 or 6 hours to burn (its 6x speed disc).
    Is this to be expected? I don't see any settings for burning speed from within PRE9.
    I burned a 2 hour test Blu-Ray the other day from within the software that the Blu-Ray burner came with (where you can adjust the burn speed), and I could swear it was much faster. But I don't want to waste another disc just to test this out.
    Thanks
    Greg

    Unfortunately, PrE does not allow one to alter the Burn Speed. The "big brother," Encore has that capability.
    In PrE, I suggest doing a Burn to Folder, and then the great, free burning utility, ImgBurn, which allows that adjustment. However, without extra software (virtual BD burner software), PrE does not allow BD Burn to Folder, at least not yet.
    Sorry for the bad news,
    Hunt

  • Loading the SCCM 2012 R2 Cmdlets from within a module

    Hi together,
    In the following article was described how to load the Powershell Module for SCCM 2012:
    http://blogs.technet.com/b/configmgrteam/archive/2013/03/27/powershell-connecting-to-configuration-manager.aspx
    I've taken the code to build a function to load the Powershell Module which works fine when i directly integrate it in my scripts.
    Currently i build a Module called SCCM-HelperFunctions.psm1 and the above mentioned function is one which i want to integrate, i named it "Import-Cmdlets". The Import of my Module works fine,  the function "Import-Cmdlets" is available
    trough IntelliSense and the command ends with no errors in the context of the given Site (ex. "PS CM1:\") but when i try to use SCCM Cmdlets the Command is not found.
    I've checked if the Module was loaded successfully but it isn't. Following is the function included in the Module:
    Function Import-SCCMCmdlets {
    <#
    .SYNOPSIS
    Lädt die SCCM Cmdlets und wechselt in den Kontext der angegebenen Site.
    .DESCRIPTION
    Die Funktion Import-SCCMCmdlets lädt die Powershell Cmdlets und wechselt in den PSDrive Kontext des angegebenen Sitecodes.
    In diesem Kontext können dann die in folgeendem Artikel aufgeführten Cmdlets ausgeführt werden:
    http://technet.microsoft.com/en-us/library/jj821831%28v=sc.20%29.aspx
    .PARAMETER Sitecode
    Eine Zeichenkette mit dem Sitecode der CAS oder Primary Site in dessen Kontext die Cmdlets laufen sollen.
    .EXAMPLE
    Import-SCCMCmdlets -SiteCode "P01"
    .EXAMPLE
    $SiteCode = "P01"
    Import-SCCMCmdlets -SiteCode $SiteCode
    #>
    Param (
    [Parameter(Mandatory=$true)]
    $SiteCode
    $null = Import-Module ($env:SMS_ADMIN_UI_PATH.Substring(0,$env:SMS_ADMIN_UI_PATH.Length – 5) + '\ConfigurationManager.psd1')
    Set-Location "$($SiteCode):" | Out-Null
    if (-not (Get-PSDrive -Name $SiteCode))
    Throw "Beim Versuch das Powershell Modul zu laden und auf das PSDrive $Sitecode zu wechseln trat ein Fehler auf."
    The exact same function works when i copy it to the ISE and run it.
    Does anyone have any ideas and can point me into the right direction? (eventually different workspaces when the function runs from within the module or something like that?)
    Best regards
    Rolf

    Hi together,
    In the following article was described how to load the Powershell Module for SCCM 2012:
    http://blogs.technet.com/b/configmgrteam/archive/2013/03/27/powershell-connecting-to-configuration-manager.aspx
    I've taken the code to build a function to load the Powershell Module which works fine when i directly integrate it in my scripts.
    Currently i build a Module called SCCM-HelperFunctions.psm1 and the above mentioned function is one which i want to integrate, i named it "Import-Cmdlets". The Import of my Module works fine,  the function "Import-Cmdlets" is available
    trough IntelliSense and the command ends with no errors in the context of the given Site (ex. "PS CM1:\") but when i try to use SCCM Cmdlets the Command is not found.
    I've checked if the Module was loaded successfully but it isn't. Following is the function included in the Module:
    Function Import-SCCMCmdlets {
    <#
    .SYNOPSIS
    Lädt die SCCM Cmdlets und wechselt in den Kontext der angegebenen Site.
    .DESCRIPTION
    Die Funktion Import-SCCMCmdlets lädt die Powershell Cmdlets und wechselt in den PSDrive Kontext des angegebenen Sitecodes.
    In diesem Kontext können dann die in folgeendem Artikel aufgeführten Cmdlets ausgeführt werden:
    http://technet.microsoft.com/en-us/library/jj821831%28v=sc.20%29.aspx
    .PARAMETER Sitecode
    Eine Zeichenkette mit dem Sitecode der CAS oder Primary Site in dessen Kontext die Cmdlets laufen sollen.
    .EXAMPLE
    Import-SCCMCmdlets -SiteCode "P01"
    .EXAMPLE
    $SiteCode = "P01"
    Import-SCCMCmdlets -SiteCode $SiteCode
    #>
    Param (
    [Parameter(Mandatory=$true)]
    $SiteCode
    $null = Import-Module ($env:SMS_ADMIN_UI_PATH.Substring(0,$env:SMS_ADMIN_UI_PATH.Length – 5) + '\ConfigurationManager.psd1')
    Set-Location "$($SiteCode):" | Out-Null
    if (-not (Get-PSDrive -Name $SiteCode))
    Throw "Beim Versuch das Powershell Modul zu laden und auf das PSDrive $Sitecode zu wechseln trat ein Fehler auf."
    The exact same function works when i copy it to the ISE and run it.
    Does anyone have any ideas and can point me into the right direction? (eventually different workspaces when the function runs from within the module or something like that?)
    Best regards
    Rolf

  • How to refer to an object from within a handler

    So I have a mouse listener that is attached to multiple objects as so:
      for (int i = 0; i < Grids.size(); i++) {
    Grids.get(i).addMouseListener(new GameMouseListener());
    }Now the problem I have is I need to know which of the Objects activated the handler
    obviously this wont work since the var "i" is not defined inside the class and was only used in the previous for loop.
    how to I know using the Handler Which Specific Object has been clicked on.
    public class GameMouseListener implements MouseListener {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (Grid.get(i).isSelected()) {
                    Grid.get(i).unselected();
                } else {
                    Grid.get(i).selected();
            @Override
            public void mousePressed(MouseEvent e) {
            @Override
            public void mouseReleased(MouseEvent e) {
            @Override
            public void mouseEntered(MouseEvent e) {
            @Override
            public void mouseExited(MouseEvent e) {
            }

    user10689232 wrote:
    So I have a mouse listener that is attached to multiple objects as so:No, you have grids.size() amount of listeners, each listening to one object. Just pass the i along to the listener:
    new GameMouseListener(i); // and create that constructor

Maybe you are looking for

  • Destructive Samples with Handling Units

    Dear Experts, I just wanted to check if there's anyone who has encountered destructive inspection for samples with Handling Units and how this was managed (via enhancements/operational workaround). Based on SAP KBA 1771624, destructive sampling will

  • MacBook, low on memory, won't boot up completely

    My old and proud macbook is maxed on memory space...which is why I assume it is not booting up completely. I turn it on and it goes into just the lovely outer space milky way image...and stays there. Is there any way I can get it to launch all the wa

  • Labels not printing right

    I have an HP Officejet 5610xi All-in-One printer. I have never had any trouble with it. I don't think I have ever printed labels with it, though. I purchased the Avery Clear easy peel labels 8662 and down loaded the template 5162 that it told me to u

  • What to do with recovery partition?

    hi...i have a hp pavilion g6 notebook and i want to know how many disks are needed for the recovery and how to create the a new partition.Also what is the need of the HP_tools partition. thanks<script type="text/javascript" src="https://in.admedia.co

  • What driver is making all clips be "white screen"?

    I'm using Premiere Pro CC on Windows 7.  I previously was able to import and edit clips via exactly the same workflow - but now, not matter what clips I import, they all appear as the 'white screen'.  The thumbnail is a frame of the video, but as soo