Having trouble with using variables in functions and after functions..

Morning,
I have simplified this, as it represents the core of what’s I obviously don't know how to do. 
Problem:
Say I populate that variable by reading in a list if IP addresses from file, finding the line that matches the hostname and place that string into the $IPAddress variable for use later throughout the script.   I did not run into a significant problem
until I decided to convert the routine of looking up the IP address and populating the variable into a function.   As soon as I made it a function, and called that function, the $IPAddress variable only had the data in it until the function completed. 
Once the function had done its work, and had placed the data into the variable, I expected that “new” data to be available after the function had completed..in that variable.  But it’s like the $IPAddress variable in the main script is a totally
different data then the variable with the same name that’s used within the function. 
So I think this demonstrates some of what’s kicking my butt.. 
$IPAddress = "This is the wrong data”
Function TestFunction () 
$IPAddress  #call to display the contents of the variable at the start of the function. 
$IPAddress = Read-Host -Prompt "Please enter the text ‘Goober’" 
$IPAddress   #call to display the contents of the variable at the end of the function. 
TestFunction
$IPAddress ​
The output I get is: 
This is the wrong data
"Please enter ‘Goober’"  : where I enter Goober
Goober
This is the wrong data
Huh? 
I had expected:
This is the wrong data
"Please enter ‘Goober’"  : where I enter Goober
Goober
Goober
What good is the repeatability of a function if it’s output is lost? 

THis seems to work.. IS there any reason NOT to do this?
$Global:IPAddress= "This is the wrong data” #"
Function TestFunction{
    Write-Host $IPAddress-fore green
      $host.ui.RawUI.FlushInputBuffer()
     $Global:IPAddress =
Read-Host -Prompt
"Please enter the text ‘Goober’"
    return$Global:IPAddress
TestFunction
return$Global:IPAddress

Similar Messages

  • I'm having trouble with using Calculated-User Can Override, it will not honor my overide

    I'm having trouble with using Calculated-User Can Override, it will not honor my overide.  I'm using LiveCycle Designer ES v.8.2

    Reset the device:
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears.
    If that doesn't help, tap Settings > General > Reset > Reset All Settings
    No data is lost due to a reset.

  • Having trouble with momentary delays while scrolling and typing, new problem that seems to be getting worse every day. Mouse?

    Having trouble with momentary delays while scrolling and typing.  It's a new problem that seems to be getting worse every day. Mouse? Internet connection? It's driving me nuts!

    Hi
    Did you find a solution ?
    I have the same problem on my iPhone 4

  • Having trouble with mail..Wheel spins and mail hangs up when mainly when sending

    Having trouble with mail..Wheel spins and mail hangs up when mainly when sending

    Have you many items in outbox? Seen this where a message has a large attachment and I stuck

  • HT1550 I'm having trouble with importing them into iTunes and converting them at the same time. when i hold down option over the files i can't find where its supposed to say create new version. is this if you're in iTunes?

    I'm having trouble with importing them into iTunes and converting them at the same time. when i hold down option over the files i can't find where its supposed to say create new version. is this if you're in iTunes?

    You can't do it in one step. Add to iTunes first, Once the tracks are in iTunes you may convert to a different format.
    tt2

  • Having trouble with music apps shutting down, even after I swipe them off the screen. They go off then come back on in a few minutes. This happens in my car either ubs plugged in, or bluetooth. ANy one else have that issue?

    Having trouble with music apps shutting down, even after I swipe them off the screen. They go off then come back on in a few minutes. This happens in my car either ubs plugged in, or bluetooth. ANy one else have that issue?

    Hi, beth.lau.gr.
    Thank you for visiting Apple Support Communities.  
    I understand you have been experiencing issues with your iPhone restarting and showing you a blue screen.  I wont be able to give you an exact answer as to why this is happening.  However, this is the most relevant troubleshooting article for this issue.  This article also provides options to reach out to us via phone for additional assistance.  
    If your iOS device restarts, displays the Apple logo, or powers off while you're using it
    http://support.apple.com/en-us/HT203899
    Cheers, 
    Jason H.  

  • I'm having trouble with a multi channel acquisition and download with PXI-5922

    I am having trouble with getting data out from both channels of a PXI-5922.  My software seems to be working, but when I do the fetch there is no data for the second channel.  I am using the same format for all of the channelList inputs (0,1).  I've checked the instrument handles and anything else I can think of, but this is my first time trying to collect data on 2 channels of a digitizer.  Any help would be appreciated.

    Hi schliepe,
    Try checking your code against an existing example. The
    Developer Zone Example: Independent
    Channel Configuration with NI-SCOPE is a good VI to reference. Also note
    that there are several examples that come with the NI-SCOPE driver. They can be
    found in Windows by going to Start »
    Programs » National Instruments » NI SCOPE » Examples. Additionally, if you find that the examples are not working either, verify that both channels are functioning by running the
    NI-SCOPE Soft Front Panel.
    Please post back if you have any questions. Have a great
    day!
    Ryan D.
    District Sales Manager for Boston & Northern New England
    National Instruments

  • Is anyone having trouble with the "home" button not responding after upgrading to 5.1.1 OS?

    Is anyone having problems with the "home" button not responding after upgrading to 5.1.1?

    You will not belive how I accidently solved this - !!!
    Yes I had the problem immediately after the 5.1.1 'cloud' upgrade, the problems started (on my iphone 4) ... I followed the 'get power down button, then hold HOME for 30 secs' solution, but no result, nothing seemed to work and I was starting to get a bit agressive with the keep it pushed, multiple double click frustrations, icopybot multigesture solutions etc. and paid money ... but this comedy solution now works ...
    I discovered it because I ordered a waterproof case for my iphone for my motorcycle ... I've just fitted it to my iphone and all the problems have gone ??? what! ... so wondering why I looked at what the home button on the casing was doing - it was pressing ACROSS the home button i.e. it converted my finger point into a wider 'PRESS
    so taking the new case off, instead of using the point of my thumb to press HOME, I used the flat of my thumb to emulate it ....and initially nothing, so I wondered if it wa making better 'cross button' contacts, so I licked my thumb, wiped it and then tried again! - it worked!
    I can't explain it but it seems to work - try it! if the double click on HOME doesn't work lick your thumb dry it and try again! I've just done it again
    what a mad techno world we live in! :-)
    Dave

  • Need a recommendation on using the book module ...having trouble with choosing the best template and adjusting text etc.

    Having trouble working with photo text box and normal page text boxes.  Cannot seem to consistently grab the handles of either and re-size.  Is there a good tutorial out there? 

    Adobe TV is a good place to start. See if these video tutorials help:
    Book Creation
    http://tv.adobe.com/watch/getting-started-with-adobe-photoshop-lightroom-5/lightroom-5-cre ating-and-publishing-a-book/
    Modify Layouts of Images & Text
    http://tv.adobe.com/watch/whats-new-in-lightroom-4/modifying-book-layouts-/
    Backgrounds & Favorites
    http://tv.adobe.com/watch/whats-new-in-lightroom-4/advanced-book-module/

  • I'm having trouble with the sync all feature and i'm not sure what to do about it

    i'm using Lr 5.3 on a windows 8.1 and a really fast laptop "can render movies in after effect in minutes"
    the problem i'm having is when i click the sync all button and the top loading bar moves like everybody, only the pictures viewed in my bottom slider will change even if i leave it for hours and this happen with big and small number of pictures so i tried reinstalling it and that didn't work
    i do a lot of timelapses and i thought maybe if i export the video they will show with the edited settings and that didn't happen and it showed the pictures that i havent moved to view blured, like the same blue when you move fast between raw pictures
    so i t tried exporting them and that worked fine but takes ages, the pictures still didn't change in the viewer but all the exported pictures did and thats not helping me in my job !
    FIND ME A SOLUTION please cause i'm dealing with 500-1000 picture here and i need to move the slider every 20 sec or so every picture is changed and this takes time and effort  guys !

    It could be overheating..........thing is ....i never realy though ibooks got that hot....the ibook does not even have a cooling fan...at least my blueberry 300mhz doesn't.
    I would have to say sounds more like your hard drive may be starting to fail you.

  • Having trouble with Itunes recognizing my Ipad and Iphone.

    Hvaing trouble with Itunes recognizing my Ipad & Iphone.  When it finally does the siftware will crash when syncing the devise...usually when syncing the Apps. I have removed and reloaded software ,mutiple times.
    Any suggestions for correcting this?

    I have removed and reloaded software ,mutiple times.
    Doublechecking. Have you also tried a complete uninstall of both iTunes and all the other related software components and then a reinstall? If not, try the instructions from the following document:
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8

  • Having trouble with making new internet tabs and windows

    When I open a new tab or new window, some small blank black windows appear and disappear right away. I have tried running virus scans, uninstalling unnecessary programs and deleting memory but they still pop up. Also after the blank windows disappear, there is a "not responding" after the blank windows disappear, for about 10 seconds and then resumes normal

    Well first, the version of Firefox you are running is EXTREMELY old and insecure. Please update to Firefox 11 right away. [[Updating Firefox]] can help you with that.
    After doing that, if you are still having issues, Try to start Firefox in [[Safe mode|Safe mode]]. This mode disables all extensions, user customizations, hardware acceleration, etc. temporarily for diagnostic and troubleshooting. If Firefox works fine in Safe Mode, then this is likely an add-on issue. Restart Firefox in normal mode, then type "About:addons" (without the quotes) in the address bar. Disable your extensions one by one, restarting Firefox between each one, until you find the trouble maker. Once you do, you can disable that add-on and report the issue to that add-on's developer.
    A few other basic trouble shooting things you can try is this:
    Run all Windows Updates, install all needed service packs, etc.
    Update your graphics driver (Firefox uses your graphics card for some rendering, and an out of date graphics card driver can cause problems. [https://support.mozilla.org/en-US/kb/how-do-i-upgrade-my-graphics-drivers https://support.mozilla.org/en-US/kb/how-do-i-upgrade-my-graphics-drivers].
    Update all your plugins (Flash, Java, etc.): [http://www.mozilla.org/plugincheck/ http://www.mozilla.org/plugincheck/].
    Download and Install MalwareBytes Anti-Malware, run a full Scan. [http://www.malwarebytes.org/ http://www.malwarebytes.org/]. This helps check that there are no viruses on your computer causing issues. You can uninstall this program after you clean off any infections.

  • Having trouble with using crypto in JC 2.2.2

    Hi,
    I am using the sourceforge Eclipse plugin for my project. Eclipse version is 3.5.
    My JC version is 2.2.2. When i debug my code (Using the debug mode) the program terminates at
    keypair = new KeyPair(KeyPair.ALG_RSA_CRT, (short)1024);
    In the debug window (Variables) I get the cause and theSW as (0, 3) which i think implies CryptoException - NoSuchAlgorithm.
    I don't understand why this shows.
    It does not generate any stacktrace and shows stacktrace as null.
    My code:
    package test;
    import javacard.framework.APDU;
    import javacard.framework.Applet;
    import javacard.framework.ISO7816;
    import javacard.framework.ISOException;
    import javacard.security.*;
    //import javacardx.crypto.*;
    public class Test extends Applet {
    // Private Objects
    private static Key privateKey;
    public static Key publicKey;
    private static KeyPair keyPair;
    // Private Debug objects
    private byte flag = 0;
    //standard APDU input offset values
    public final static byte THIS_CLA = (byte)0x90;
    // This is the INS for starting to generate 1024 bit RSA keys
    public final static byte  GENERATE_RSA_KEYS = (byte)0x20;
    // INS to sign provided hash
    public final static byte  COMPLETE_TRANSACTION= (byte)0x22;
    // INS to return Status of Applet.
    public final static byte  INITIALIZE_UPDATE= (byte)0x24;
    // INS to reset keys
    public final static byte  COMPLETE_UPDATE= (byte)0x26;
    // dummy byte sequences returned by this applet
    private final static byte[] INIT_SEQUENCE = { (byte)0xff, (byte)0x2 };
    private final static byte[] COMPLETE_SEQUENCE = { (byte)0x1, (byte)0x3 };
    private final static byte[] INIT_UPDATE_SEQUENCE = { (byte)0x1, (byte)0x2, (byte)0x3 };
    private final static byte[] COMPLETE_UPDATE_SEQUENCE = { (byte)0x1, (byte)0x1 };
    * Constructor.
    * Only this class's install method can create the applet object.
    private Test() {
    //perform some initialization here
    register();//register this instance
    * Installs this applet.
    * @param byteArray the array containing installation parameters
    * @param offset the starting offset in byteArray
    * @param length the length in bytes of the parameter data in byteArray
    public static void install(byte[] byteArray, short offset, byte length) {
    new Test();
    * Implementation  of the standard method for processing an incoming APDU.
    * @param apdu the incoming APDU
    * @exception ISOException with ISO 7816-4 response bytes
    public void process(APDU apdu) {
    byte buffer[] = apdu.getBuffer();
    //@SuppressWarnings("unused")
    flag = 0;
    if (buffer[ISO7816.OFFSET_CLA] == THIS_CLA) {
    switch (buffer[ISO7816.OFFSET_INS])    {
    case GENERATE_RSA_KEYS:
    //writeBack(apdu, INIT_SEQUENCE);
    generateRSAKeys(apdu, INIT_SEQUENCE);
    flag = 1;
    break;
    case COMPLETE_TRANSACTION:
    writeBack(apdu, COMPLETE_SEQUENCE);
    break;
    case INITIALIZE_UPDATE:
    writeBack(apdu, INIT_UPDATE_SEQUENCE);
    break;
    case COMPLETE_UPDATE:
    writeBack(apdu, COMPLETE_UPDATE_SEQUENCE);
    break;
    default:
    ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
    * An example method that writes back a given byte array through the apdu.
    protected void generateRSAKeys(APDU apdu, byte[] bytes)  {
    //byte buffer[] = apdu.getBuffer();
    try {
    byte[] apduBuffer = apdu.getBuffer();
    // Debug flag
    flag = 9;
    //privateKey = KeyBuilder.buildKey(KeyBuilder.TYPE_RSA_PRIVATE,KeyBuilder.LENGTH_RSA_2048, false);
    //privateKey = KeyBuilder.buildKey(KeyBuilder.TYPE_DSA_PRIVATE,KeyBuilder.LENGTH_DES, false);
    //publicKey = KeyBuilder.buildKey(KeyBuilder.TYPE_RSA_PUBLIC,KeyBuilder.LENGTH_RSA_2048, false);
    // Debug flag
    flag = 10;   
    keyPair = new KeyPair(KeyPair.ALG_RSA_CRT, (short)1024);
    //keyPair = new KeyPair(KeyPair.ALG_RSA, (short)publicKey.getSize());
    keyPair.genKeyPair();
    publicKey = keyPair.getPublic();
    // Debug flag
    flag++;   
    ((RSAPublicKey)publicKey).getModulus(apduBuffer, (short)0);
    //    apdu.setOutgoing(); // set transmission to outgoing data
    //    apdu.setOutgoingLength((short) apduBuffer.length);
    apdu.setOutgoingAndSend((short) 0,  (short) (publicKey.getSize()/8));
    // Debug flag
    flag++;       
    } catch(Exception e) {
    flag = 0;
    * An example method that writes back a given byte array through the apdu.
    protected void writeBack(APDU apdu, byte[] bytes) {
    byte buffer[] = apdu.getBuffer();
    // copy bytes into buffer
    buffer[0] = bytes[0];
    buffer[1] = bytes[1];
    // set apdu for data output
    apdu.setOutgoing();
    apdu.setOutgoingLength( (short) (2) );
    // output header
    apdu.sendBytes( (short)0, (short) 2);
    // writes data
    //apdu.sendBytesLong( bytes, (short) 0, (short) 0 );
    } NOTE: Part of the code is from an online tutorial that i found.
    Thanks for your help.

    Hi,
    That exception generally means that the platform you are running on does not support that crypto operation. This can be an indecator that the cipher you would use this key with is not available or the key size you are using is not supported.
    I am not familiar with the Eclipse plugin you mentioned, but if you are using the Java implementation of the Java Card simulator (jcwde) provided with the JCDK, ti will not support crypto operations. There have been several posts on this topic recently that you may be able to search for that will give you more details about this.
    On a coding note, you should not be using the new keyword outside of the applet constructor. In fact you should not be allocating new memory outside of this constructor. This is because you should not rely on garbage collection in Java Card as it is not be implemented on all cards. If it is available on a card it may be rather slow.
    Cheers,
    Shane
    Edited by: safarmer on 27/10/2009 17:19

  • I see that, it seems, everyone is having trouble with Firefox 6.0.2 and Adobe Flash 10.3. It's nice not to be alone, but is there an answer? My problem is I am continually asked to download the flash player. So how do I solve this situation?

    Whenever I open PDF it informs me that Adobe Flash Player is not found. When I check the box to add it, I am taken to Firefox and given a choice to add it to Explorer or other systems. I have chosen both in the past and added it more than a few times. My system is XP service pack 3, already installed Flash Player 10.3.181.34 and Firefox 6.0.2. In checking your web site I see that others are having this problem too. I did not see how to solve it. Is there an answer?

    Thanks for the swift reply, I have been looking online and a loose plug seems to be somewhat of an issue with many, I hope mine is actually a problem and not what others are experiencing. It's taken me this long to even reach out for the simple fact I HATE being a complainer but this is just horrible.
    Do you have an iPad 3 as well? And is yours not experiencing any issues close to mine?
    Thanks again!

  • I am having trouble with Safari. It keeps crashing after about two seconds in and wont then let me send the report to apple

    I wonder if it is something to do with gmail. as gmail has been asking to store emails on my local drive and I have been saying no as I was worried it might be a virus or something - maybe I have too many emails on the system. I just dont know. I am using Firefox in the meantime but feel frustrated as I dont know my way around as well and I have work to get on with!

    IVE DONE IT - THANKS SO MUCH SIG. I googled empty cache safari and worked it out it was easy once you told me how thanks very much. By the way what do you think I should do about the gmail requests to store emails on my laptop?

Maybe you are looking for

  • How to install E-Business Suite 11.5.9 on Linux ES4 64bits

    Dear Sir, I am upgrading E-Business Suite to 11.5.10.2. Before upgrading i have to install E-Business Suite on the new servers with OS Linux ES4 64bits which gives better performance and stability on the environment. Could you please guide me on this

  • Bad performance updating purchase order (ME22N)

    Hello! Recently, we face bad performance updating purchase orders using transaction ME22N. The problem occurs since we implemented change documents for a custom table T. T is used to store additional data to purchase order positions using BAdIs ME_PR

  • Break point in enhancement

    hi all, How do we set a break point in a enhancement. When i try to create a break point I am getting a message 'THE POSITION OF THE BREAK POINT CANNOT BE DETERMINED' I know that the code in the enhancement point is in a include program. but how do i

  • Error with Global property

    Hi All, I need to create a Global property NumOfDecPlaces which is derived in DRM.I inserted a formula for that property to get the hierarchy name . Depending on the hierarchy name I want to assign the no.of decimals. But when i write PropValue(HierN

  • Stop SAP from mmc console invalid credentials

    Hi everybody I'm trying to stop the SAP System over the MMC console 5xx13 After right clicking the instance and selecting stop SAP system I type in the user credentials <sid>adm and password. the message invalid credentials appears. Has somebody ever