Problems to get the Variables of functions

If possible, could someone explain to me how function to produce variables.  Here's what I'm trying to do.  I have a CSV file that I'm importing.  I would then like to run function for each row in the CSV file and produce able to use in the script.

For example,.

I have a function that looks to see which version of windows operating system and will assign a key to license based on this variable.

Function Determine_Win_License_Key {}

#$erroractionpreference = "SilentlyContinue".

$CSV_Guest_OS = $_. Guest_OS

Switch ($CSV_Guest_OS)

{

2003 x 32 {$GuestOSLicense = "License key 1"; break}

2003 x 64 {$GuestOSLicense = "License key 2"; break}

2008 x 64 {$GuestOSLicense = "License key 3"; break}

2008r2x64 {$GuestOSLicense = "License key 4"; break}

}

}

Based on this function, I set the $GuestOSLicense variable to be used later.

The body of the script looks like this:

Import-Csv csv.csv | %{

Write-host "license key of determination."

Determine_Win_License_Key

Write-host "the used license key is: ' $GuestOSLicense

}

I expect to see what is the license key but all I get output is

"" The used license key is: ".

Someone know or understand why the function runs but does not save the variable generated by the function?

I have several other functions in this script, and each of them do not return the variable.

It's because you return anything in the service.

One way to achieve this is

Function Determine_Win_License_Key {
   param($OS)
   #$erroractionpreference = "SilentlyContinue"
   switch ($OS)
   {
      2003x32 {$GuestOSLicense = "License Key 1"; break}
      2003x64 {$GuestOSLicense = "License Key 2"; break}
      2008x64 {$GuestOSLicense = "License Key 3"; break}
      2008r2x64 {$GuestOSLicense = "License Key 4"; break}
   }
   $GuestOSLicense
}

Import-Csv csv.csv | %{
   Write-host "Determining License Key"
   Determine_Win_License_Key -OS $_.Guest_OS
   Write-host "The License Key being used is:" $GuestOSLicense
}

It is also best to pass a parameter to a function, rather than depend on variables in the function, which are initialized defined outside the function.

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

  • How to get the variable 'dn' in a script

    Hello

    I have a problem, get the variable "dn" of the script is not a "public" variable, but I'm able to see in the log file. I bet it's in an object java somewhere - I don't know how to access it. No one knows how to get it. I have attached some of the newspaper:)

    CN = 8485 [5-6] XX, dn = 8485601 = 9812 cgn, ani = null, dnis = null, clid = null, atype = FORWARD_ALL lrd = 9817, ocn = 9817,

    I have a similar problem but I did not find the repo. package... Where?

    Thank you

  • How to get the variable substitution essbase in ODI

    Hi all
    I have a problem that I need to get the variable substitution of Essbase /EAS to work on a SQL in ODI.
    How can I do in ODI?
    Thank you all for...

    Thomas

    Hello

    If you read my blog:-http://john-goodwin.blogspot.com/2009/11/odi-series-planning-11113-enhancements.html
    In the post, there is a section on the recovery of the essbase substitution variables and their use in ODI.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Printing problems - I get the sizes of evil when I print from LR 5.5. on my Epson 3880 printer. USB connection. Reinstalled printer driver - not. Want to obey my print settings. What can be wrong?

    Printing problems - I get the sizes of evil when I print from LR 5.5. on my Epson 3880 printer. USB connection. Reinstalled printer driver - not. Want to obey my print settings. What can be wrong?

    I am not familiar with these communities - not provide Adobe and LR all direct support?

    You bet it's your page layout. As I said, the Epson driver has many offers for the same size paper. In addition, do NOT use Auto expand in this selection.

  • Get the variables of a function

    Hello

    In order to reduce the use of the event of calculation in a repetitive subform, I've implemented a function (riskRating) in a script object (calculateRisk), who calls the output of a drop-down list (RA_severity) event.

    It is the Javascript in the exit event...

    var vLikelihood = RA_likelihood.rawValue; Combo 1
    var vSeverity = RA_severity.rawValue; combo 2
    var vRisk;

    calculateRisk.riskRating (vLikelihood, vSeverity);

    Console.println ("risk after function =" + vRisk);

    RA_risk_rating. RawValue = vRisk;  This line is intended to affect the value of the function vRisk in another discipline (but is not)

    It is the function within the script calculateRisk object...

    function riskRating (vLikelihood, vSeverity)
    {

    var vRisk;

    If (vLikelihood == null & & vSeverity == null)
    {
    vRisk = null;
    }

    on the other
    {
    vRisk = vLikelihood * vSeverity;
    }

    Console.println ("risk inside the function =" + vRisk);

    Return vRisk;

    }

    I tried different approaches to get the response from the service and to serve for the rest of the script in the script to output event.

    The console are the correct calculation of the function, but it is not updated the variable outside the function.

    Any ideas?

    Thank you

    Niall

    Niall,

    Take a look at the attachment. The form contains four numeric fields: 'a', 'b', 'total' and 'other '. This a calculation field 'a' and 'b '. On the output of 'b' event, it calls "addNumbers()' in 'MyScriptObject '. The function 'total' updates and returns the value of 'total' to be linked to 'other '.

    Form1.Page1.Subform1.b::exit - (JavaScript, client)

    other.rawValue = MyScriptObject.addNumbers (a, b, total);

    Form1. #variables [0]. MyScriptObject - (JavaScript, client)

    function addNumbers (a_, b_, total_) {}
    return (total_.rawValue = a_.rawValue + b_.rawValue);
    }

    -What are you looking for?

    Steve

  • Incredible problems to get the new workgroup C8180 All-in-one

    I bought a C8180 All-in-one printer to the end of September. When I plugged in and installed the software, everything seemed to function OK (I didn't test printing from the computer at the time), but after a short period of time to print Microsoft Word and Wordpad failed, started working and then failing again every time I reinstalled the software to try to solve the problem. Then began a long series of emails with HP technical support. In the next two weeks I have uninstalled and reinstalled the software 6 or 7 times in several different ways, under the instruction of HP. But he never could get Word and Wordpad works correctly. Finally, once again, under order of HP, he worked with a fake installation of HP Deskjet 990c printer. Then I noticed that it was more possible to digitize documents and slides to the computer, except by using a chip memory such as an intermediate storage. Then I went on vacation after spending about 30-40 hours two weeks previous emailing and calling the HP technical support.

    Back from vacation in the third week of October, I took the issue once again with HP support. Yet once, I spent hours and hours writing emails and reinstalling the software but to no avail. HP finally proclaimed this a problem difficult and said that it would increase the level of support. A gentleman named Sylvester who sent someone would phone a day pre-arranged to see more advanced techniques could be applied to the problem. Needless to say that the phone call came not despite my cancelling several meetings to wait in it (I should have better that they had promised to phone back me several times before and has never done).

    Finally, I called customer service to the local office of HP. (At least you can get to them without having to listen to the music for half an hour for the price of 5 p / minute.) They said that they would ensure someone would contact me and would monitor the call to ensure that happened. A week later I ' d has received no call, and I went to the local customer service. Has been raised to the top level of management, and finally, after a few reminders more than me, they managed to get a senior technician, called Natheem, in their technical service Cap to call me.

    He has been very helpful (and actually phoned me several times), and finally he forced me to go through the complicated process of getting Microsoft in India (via a conference telephone with Cape Town and myself - apparently it would have cost me a lot in telephone charges, but I have not had the Bill) to give advice on how to spend my Windows XP with service pack 2 and my internet explore to IE6. I reinstalled the C8180 software once again. No difference, still the same problems, except that now, Microsoft Word would work with the HP C8180 printer driver.

    At this point, Natheem said that it must be a hardware fault and arranged for the device must be replaced.

    The new unit arrived last Thursday. I again carefully uninstalled and reinstalled the software, connected to the machine and got the same problems, but once again with Microsoft Word cannot print with the C8180 printer drivers.

    I tried to contact Natheem again once in Cape Town this afternoon. After half an hour of expensive music additional I have with a person named Waleed who said that Natheem is on a call but he would get to call. No call came.

    So on the forum, I would like advice on what to do with a new HP C8180 All-in-One printer which:

    1. not print Word documents (except by using a printer deskjet 990c driver)
    2. used to scanning documents or transparent to the computer
    3. will not print photos from the computer using HP photosmart essential, or other photo editing software

    I'm also rather fed up of the assistance provided by HP. When you get through them they always try to help, but pass through, especially for someone who knows your case is more frustrating (and costs). In an attempt to get the thing, I also had to downgrade my computer Windows XP service pack 2 OS and my internet explore to IE6. I spent probably 50-60 + hours of the last two months, trying to get the thing work.

    Any advice on what to do next would be welcome.

    BobA

    Hi David,

    Well, my story has a happy ending. I stopped trying to untangle the printer after a whole month of working hours, including a lot of phone calls to the SA and responidng to dozens of emails. But then I bought my wife a laptop Toshiba for Christmas - and it worked perfectly first time. In any case, my computer was in a bit of a mess especially when the messing around I had done on this to HP support, so I decided to reload my operating system (after reformatting hard disk), I just finished. And guess what the C8180 works perfectly (at least until now anyway)! I just updated my OS to SP2 (according to HP support the C8180 has problems with SP3), and I kept my Internet Explorer version 6 (higher versions - 7 I think - again can cause problems according to HP support). I somehow use Firefox. But now its work, its quite an impressive machine.

    I want to say individual personnel in support of HP thin is always very friendly and helpful. It's just a phone, it costs and often listen to music for a long time, its very difficult to get hold of the same person again, if you spend hours to repeat the details of your problem, and despite vehement promises they call you rarely back - probably because they are too busy. His support system which is very poor, not the support staff.

    In any case you have a different problem. If your printer does not work on computers with different operating systems. I would say that you have good arguments to either get a new printer or your money under the guarantee.

    Good luck

    BobA

  • Get the custom IdocScript function contributor data file

    Hello

    I have a requirement to retrieve a number of elements of a given contributor data file. The problem is, I don't know how to retrieve the XML code inside a custom component of IdocScript.

    Given the content of the data contributor file ID, is there an easy way to get the XML file, or do I need to use with a service call?

    Thank you!

    If it's a Java component, why not just get the direct file system XML file? The demand function, you could have a file path in the binder... If not, use the IdcFileDescriptor object:

    https://groups.Yahoo.com/neo/groups/intradoc_users/conversations/topics/25937

  • Maybe stupid question from new user: that can be done to get the variables displayed in the information tab variables?

    I've been a user of LabVIEW (2011) for about 1.5 years now and just got ahold of TestStand 2014 to try future test as a structure for our needs.

    I am using on and off for about 3 days and there is something that has been driving me nuts.  When I launch a sequence, and that the report comes at the end, there are three tabs on it: report, steps and Variables.  Report and the steps are exactly what I expect to see.   However, the Variables tab is always empty.  Nothing that I found via my technique of checking everything in menus that looks vaguely related and right click things on many items and these menus for other vaguely related things as well.

    I tried looking for references to it, and all I get is the "Main" variable tab you see when you change the sequence, not the one that appears on the report.

    See arrow in the image below:

    I suspect there is something incredibly obvious that I'm missing, but it's driving me crazy here...

    You won't see that filled when a run is complete. The variables are useless at this time here.

    If you want to see this populous tab to suspend execution in the middle.  Or a breakpoint.  Then you can watch the variables at run time.

    Kind regards

  • Problem to get the background color

    Mr President, in my code, I wasn't able to use fully all the width of the screen,

    This is my code

    public class HorizontalField extends VerticalFieldManager
    {
       HorizontalFieldManager sd=new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
       HorizontalFieldManager r1=new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
       MySeparatorField ds=new MySeparatorField();
       Font fnt,fntv;
        HorizontalField()
        {
           fnt = this.getFont().derive(FontFamily.SCALABLE_FONT, 14);
           fntv = this.getFont().derive(FontFamily.SCALABLE_FONT, 11);
           r1.setFont(fntv);
           /*---------------------Heading-----------------------------------*/
           DateField dd=new DateField("Date");
    
           dd.setFont(fnt);
           sd.add(dd);
          /*------------------*/
           MyLine s=new MyLine();
           sd.add(s);
           Desp d1=new Desp("Description");
           d1.setFont(fnt);
           sd.add(d1);      
    
           /*_________________*/
           MyLine s1=new MyLine();
           sd.add(s1);
    
           Amt d2=new Amt("Amount");
           d2.setFont(fnt);
           sd.add(d2);
           add(new SeparatorField());
           add(sd);
           add(new SeparatorField());
    
               DateField dfr=new DateField("13.08.09")
               {
                   public void paint(Graphics g)
                   {
                        g.setBackgroundColor(Color.RED);
                        g.clear();
                        super.paint(g);
                   }
               };
               r1.add(dfr);
               MyLine sr=new MyLine();
               r1.add(sr);
               Desp dr=new Desp("Reent")
               {
                   public void paint(Graphics g)
                   {
                        g.setBackgroundColor(Color.RED);
                        g.clear();
                        super.paint(g);
                   }
               };
               r1.add(dr);
               MyLine sra=new MyLine();
               r1.add(sra);
               Amt amtr=new Amt("5000")
                 {
                   public void paint(Graphics g)
                   {
                        g.setBackgroundColor(Color.RED);
                        g.clear();
                        super.paint(g);
                   }
               };
               r1.add(amtr);
               add(r1);
               add(new SeparatorField());
    
           }
    
        }
    
     class DateField extends LabelField
    {
         DateField(String s)
        {
            super(s,LabelField.LEFT);
         }
        public  int getPreferredWidth()
        {
            return Display.getWidth()*2/10;
        }
    
    }
    
      class Desp extends LabelField
    {
         Desp(String s)
        {
            super(s,LabelField.RIGHT);
         }
        public  int getPreferredWidth()
        {
            return Display.getWidth()*5/10;
        }
    
    }
    
      class Amt extends LabelField
    {
        Amt(String s)
        {
            super(s,LabelField.RIGHT);
         }
        public  int getPreferredWidth()
        {
            return Display.getWidth()*4/10;
        }
    
    }
    

    MyLine code is

    public class MyLine extends LabelField
    {
        int width,height;
    
        ButtonField dd;
        MyLine()
        {
            width=1;
            //height=200;
        }
         MyLine(int w)
        {
            width=w;
            //height=200;
        }
    
         public int getPreferredWidth()
            {
                return width;
             }
    
         public void paint(Graphics g)
                {
                       // g.setBackgroundColor(Color.BLUE);
    
                     g.drawLine(0,0,0,70);
                }
    }
    

    When I call this HorizontalField I get the result, but in the amount column (i.e. red) background color I get half of this label, I don't know what problem I did

    Thank you

    The problem is in your calculation of width.

    Your should calculate your width in such a way that (approximate):

    Display.getWidth () = DateField width, width PED, Amt width + 2 * MyLine width;

    Furthermore, a solution may be simply change your constructor Amt class as below:

            Amt(String s)        {                   super(s,LabelField.RIGHT | Field.USE_ALL_WIDTH);        }
    

    Concerning

    Bika

  • problem to get the current date in qml

    Hello world

    I'm trying to get the current date in c ++ and qml and I used the class QDate, but it still has some problems:

    Code:

    =====================================================

    QDate * nowdate = new QDate;
    QDeclarativePropertyMap * nowdateMap = new QDeclarativePropertyMap;
    nowdateMap-> insert ("date", QVariant (nowdate-> currentDate()));
    QML-> setContextProperty ("nowdateMap", nowdateMap);

    ===========================================================

    After setting the nowdateMap, I'm able to get the date in the application, but the format is really weird, I did not use QDatetime, but the restult of shows like ' 2013-1 - 3 T 00: 00:00 ", how can I get rid of the final"T00:00:00 "? or is there a better way to get the current date?

    Thank you

    QDate nowdate is QDate::currentDate();.

    QString nowdatestring = nowdate.toString (); / / to get the date string format, you can define the shape of toString(), you can //search it
    QDeclarativePropertyMap * nowdateMap = new QDeclarativePropertyMap;
    nowdateMap-> insert ("date", QVariant (QString (nowdatestring)));
    QML-> setContextProperty ("nowdateMap", nowdateMap);

    then in the file qml, using nowdateMap.date will do.

  • Problem to get the startup-config under the privilege level

    Hi guys

    I use the level of privilege 15.2 and in this version, that I can not get the startup-config under some of IOS (in this case, IE 7)

    I have no problem to get it from the earlier version, also to 15.1

    Router #sh privileges

    Current privilege level is 7

    Router #sh startup-config

    With the help of 4414 262136 bytes

    % Error opening nvram: / startup-config (Permission denied)

    Config:

    privilege exec level 7 show startup-config

    privilege level exec 15 see the configuration

    show privileges exec level 1

    When I added cmd ' privilege exec level 7 show startup-config ', IOS generated automatically new line "privilege exec 15 level show configuration.

    seems that there must be an "improvement" under versions of 15.2

    Any ideas?

    Thank you

    Pet

    Hello

    I have faced the same problem and opened a folder. Please find the answer I get from the TAC:

    ==============================================

    This is designed by design as a security measure. Starting in the new versions of IOS, the privilege level of access to system files must be configured separately. There are two options to solve this problem:

    (1) run the command at the prompt to activate it.

    (2) set the privilege level of the file system via the config command "file privilege X" with X the number of privilege level

    ==============================================

    Hope that helps.

    Best regards.

    Karim

  • is it possible to pass the value of the variable validation function return Boolean message?

    Selection_012.pngSelection_013.png

    Assume that L_BATCH_NAME is the name of the variable which will receive the value as

    declare

    l_batch_name: = "NA";

    BEGIN

    L_BATCH_NAME: = FUNCTION (PARAMETERS);

    IF CONDITION > 0

    THEN

    RETURN FALSE;

    ON THE OTHER

    RETURN TRUE;

    END IF;

    END;

    Hi Reema,

    ReemaPuri wrote:

    Assume that L_BATCH_NAME is the name of the variable which will receive the value as

    declare

    l_batch_name: = "NA";

    BEGIN

    L_BATCH_NAME: = FUNCTION (PARAMETERS);

    IF CONDITION > 0

    THEN

    RETURN FALSE;

    ON THE OTHER

    RETURN TRUE;

    END IF;

    END;

    1. create a hidden item I say P1_HIDDEN_ITEM

    2 type the error message for this element in your process of

    declare
    l_batch_name:='NA';
    
    BEGIN
    :P1_HIDDEN_ITEM := FUNCTION(PARAMETERS);
    IF CONDITION > 0
    THEN
    RETURN FALSE;
    ELSE
    RETURN TRUE;
    END IF;
    END;
    

    3 and refer to this element hidden in the error message.

    Record for the batch '||&P1_HIDDEN_ITEM.||' already exists.
    

    Kind regards

    Jitendra

  • Problem to get the IP address of the Client on ADF

    Hi all

    I use jdev 11.1.1.7.0 version

    In my case, I created a stubborn taskflow and deploy it to Webcenter.

    In this application I wrote the code for the customer as follows - ip address

    ExternalContext ectx is FacesContext.getCurrentInstance () .getExternalContext ();.

    HttpServletRequest request = (HttpServletRequest) ectx.getRequest ();

    String ip = request.getRemoteAddr ();

    but he returned

    127.0.0.1

    or in my env production he return server ip address.

    so my question is what is the problem with this code, why is not the ip address of the customer return

    or any other way to do

    concerning

    Manish

    This is a configuration on the weblogic server. You do not get the address of the default client. You must make a few changes to the configuration of your wls (see getting the IP address of the application client). If you do this, you should be aware of the implications that you find in the blog http://www.ateam-oracle.com/wls-plugin-enabled/

    Timo

  • How do addEventListener and get the variable

    Hello

    I'm getting data from a json and filling on the edge of adobe file but I could not get the id when I click on the image? How can I do this?

    $.getJSON("theshort.json",function(data){
    
    
      var datam = data.urunler;
      for (var i = 0; i < data.urunler.length ; i++){
    
        var d = sym.createChildSymbol("mynames","Rectangle");
      d.$("first").html(data.urunler[i].baslik);
      d.$("last").html(data.urunler[i].icerik);
      d.$("resim").html("<img src="+data.urunler[i].resim+" />");
    
        d.$("resim").setVariable("durum",data.urunler[i].id);
    
      }
    
    
    
    
      AdobeEdge.Symbol.bindElementAction(compId, "stage", "Rectangle", "click", function(sym, e) {
    
      alert(e.target.sym.getVariable("durum"));@
      });
    
    
    });
    

    You can find my file below, json

    {
        "urunler": [
            {
                "id": "24",
                "baslik": "title 1",
                "icerik": "Content area 1",
                "resim": "https://placeholdit.imgix.net/~text?txtsize=20&txt=150×150&w=150&h=150",
                "sira": "1"
            },
            {
                "id": "25",
                "baslik": "title 2",
                "icerik": "Content Area 2",
                "resim": "https://placeholdit.imgix.net/~text?txtsize=20&txt=150×150&w=150&h=150",
                "sira": "2"
            }
        ]
    }
    

    Hello

    As data.urunler is an array, you can use forEach().

    Data.urunler.forEach ({function (key)

    var d = sym.createChildSymbol ("librarySym", "container");

    d. $("first") ( key, .baslik) .html.

    d. $("last") ( key, .icerik) .html.

    d. $("resim") .attr ('src', key.resim) .bind ("click", function() {alert (keyuser.user)});

    } );

    See also: position an element Via file external JSon and then on mouseover / click on load ID

  • PowerCLI Invoke-VMScript re - ip guest - how to get the variable hostname comments

    I run the following script as a task Post-Power-we a re - ip our VMs after that MRS. them rocking.  I was able to run this script successfully without the variable hostname of comments (in the test, he runs a script by test VM with the hostname assigned...), but I'm stumped on how to get comments variablized according to the machine's host name works on, it will take the host name and use it in the GuestUser variable and the command - VM.  I tried the bold part, but it does not work.

    $srv = Connect-VIServer 10.0.0.10 - administrator of the username-password password

    $Hostname = (get-wmiobject win32_computersystem). Name

    $script = "%windir%\system32\cmd.exe/c c:\dr\drIPsettings.bat".

    $HostUser = "root".

    $HostPassword = "password"

    $GuestUser = ' $Hostname\Administrator '.

    $GuestPassword = "password"

    $ScriptType = "bat".

    SE connect-VIServer 10.0.0.10 - Session $srv. SessionID

    Invoke-VMScript - ScriptText $script - VM $Hostname - HostUser $HostUser - HostPassword $HostPassword - GuestUser $GuestUser - GuestPassword $GuestPassword - ScriptType $ScriptType

    Thank you!

    How you code the - VM on the Invoke-VMScript cmdlet parameter, it seems that Displayname of the guest is the same as the host name.

    Can't you just use a loop on guests and then use the displayname property

    $script = "%windir%\system32\cmd.exe /c c:\dr\drIPsettings.bat"
    $HostUser = "root"
    $HostPassword = "password"
    $GuestPassword = "password"
    $ScriptType = "bat"
    
    Get-VM | %{
       $GuestUser = $_.Name + "\Administrator"
       Invoke-VMScript -ScriptText $script -VM $_ -HostUser $HostUser -HostPassword $HostPassword -GuestUser $GuestUser -GuestPassword $GuestPassword -ScriptType $ScriptType
    }
    

    You can encode the Get - VM with more specific selection criteria or use a Where-Object after the Get - VM.

    ____________

    Blog: LucD notes

    Twitter: lucd22

Maybe you are looking for