PowerShell - Variable Evaluation in Return

OK, so I'm working with the registry, specifically the user's %PATH%. I am creating user variables, and adding these variables to the PATH.  I would like to be able to query the registry, but see the variable name's, not what they evaluate to.
For example:
(Get-ItemProperty 'HKCU:\Environment').PATH
Actual Return:
C:\test1;C:\test2
I want to return:
%VALUE1%;%VALUE2%
I have added values to the path as %VALUE1%;%VALUE2%, and both values are set as user variables.  What I would like to do is construct a PowerShell registry query that will return %VALUE1%;%VALUE2% instead of the actual set values for these variables. 
Is this possible?

Get-Member -InputObject (Get-Item 'HKCU:\Environment') -Name GetValue | FL
TypeName : Microsoft.Win32.RegistryKey
Name : GetValue
MemberType : Method
Definition : System.Object GetValue(string name), System.Object GetValue(string name, System.Object defaultValue), System.Object
GetValue(string name, System.Object defaultValue, Microsoft.Win32.RegistryValueOptions options)
[System.Enum]::GetNames([Microsoft.Win32.RegistryValueOptions])
None
DoNotExpandEnvironmentNames
(get-Item 'hkcu:\Environment').GetValue("TMP")
C:\Users\User\AppData\Local\Temp
(get-Item 'hkcu:\Environment').GetValue("TMP","Default",[Microsoft.WIN32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
%USERPROFILE%\AppData\Local\Temp

Similar Messages

  • Powershell variable

    Hi
    Is it possible to define a new powershell variable by using the form:
    $test="Hello"
    $Name = ("$" + "$test" + "webapFeature")
    When i type $name afterwards in PowerShell i get:
    $Hellowebapfeature
    But this has not been defined as a variable properly. I cant type: "$Hell" then tab to the whole "$Hellowebapfeature"
    Any ideas how to do this?
    The reason behind this is that i want to create several different variables in a function.
    brgs
    Bjorn

    Solved it :)
    $Name = ("test" + "webapFeature")
    new-variable -name $Name
    -value "yo local"
    This creates a variable: $testwebapFeature
    with value "yo local"

  • How to return 4 variables by one return statement

    Hello Experts
    I’m trying to develop & run a function which will collect data from 2 difference tables. I accomplished it and stores all the information which I need in 4 variables. Now as we all know that function must has to return but I don’t know how to return all these 4 variable using 1 return. Can please somebody show me how I can return 4 variables.
    For reference here is my code
    create or replace function TOT_PURCH_SF (id_shopper in bb_basket.idshopper%type)
    return VARCHAR2
    as
    cursor cur_bb_basket is
    select idshopper, total
    from bb_basket;
    cursor cur_bb_shopper is
    select firstname, lastname
    from bb_shopper
    where idshopper = id_shopper;
    v_idshopper VARCHAR2(4);
    v_total bb_basket.total%type;
    v_gtotal bb_basket.total%type := 0;
    v_fname bb_shopper.firstname%type;
    v_lname bb_shopper.lastname%type;
    v_result VARCHAR2(200);
    begin
    if not (cur_bb_basket%isopen) then
    open cur_bb_basket;
    end if;
    loop
    fetch cur_bb_basket into v_idshopper, v_total;
    if (v_idshopper = id_shopper) then
    v_gtotal := v_gtotal + v_total;
    dbms_output.put_line('Shopper Info: '|| v_idshopper ||', '|| v_total);
    --exit;   
    end if;
    exit when cur_bb_basket%NOTFOUND;
    end loop;
    -- dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal);
    close cur_bb_basket;
    open cur_bb_shopper;
    fetch cur_bb_shopper into v_fname, v_lname;
    close cur_bb_shopper;
    dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal);
    dbms_output.put_line('FIRST NAME: '|| v_fname ||' LAST NAME: '|| v_lname);
    -- return (dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal));
    return 'test';
    end;
    Thanks a lot in advance

    Hi,
    If you want more than one variable returned by something, used a procedure with this variables declared as output variables. You only need to declare the procedure and keep the internal logic (with minimal changes).
    Your code modified (please remove dead code):
    CREATE OR REPLACE PROCEDURE TOT_PURCH_SF(id_shopper  IN bb_basket.idshopper%TYPE,
                                             p_idshopper OUT VARCHAR2,
                                             p_gtotal    OUT bb_basket.total%TYPE,
                                             p_fname     OUT bb_shopper.firstname%TYPE,
                                             p_lname     OUT bb_shopper.lastname%TYPE) AS
       CURSOR cur_bb_basket IS
          SELECT idshopper,
                 total
            FROM bb_basket;
       CURSOR cur_bb_shopper IS
          SELECT firstname,
                 lastname
            FROM bb_shopper
           WHERE idshopper = id_shopper;
       v_idshopper VARCHAR2(4);
       v_total     bb_basket.total%TYPE;
       v_gtotal    bb_basket.total%TYPE := 0;
       v_fname     bb_shopper.firstname%TYPE;
       v_lname     bb_shopper.lastname%TYPE;
       v_result    VARCHAR2(200);
    BEGIN
       IF NOT (cur_bb_basket%ISOPEN) THEN
          OPEN cur_bb_basket;
       END IF;
       LOOP
          FETCH cur_bb_basket
             INTO v_idshopper, v_total;
          IF (v_idshopper = id_shopper) THEN
             v_gtotal := v_gtotal + v_total;
             dbms_output.put_line('Shopper Info: ' || v_idshopper || ', ' || v_total);
             --exit;
          END IF;
          EXIT WHEN cur_bb_basket%NOTFOUND;
       END LOOP;
       -- dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal);
       CLOSE cur_bb_basket;
       OPEN cur_bb_shopper;
       FETCH cur_bb_shopper
          INTO v_fname, v_lname;
       CLOSE cur_bb_shopper;
       --dbms_output.put_line('Shopper ID:' || v_idshopper || ', TOTAL:' || v_gtotal);
       --dbms_output.put_line('FIRST NAME: ' || v_fname || ' LAST NAME: ' || v_lname);
       -- return (dbms_output.put_line('Shopper ID:'|| v_idshopper || ', TOTAL:' || v_gtotal));
       --RETURN 'test';
       p_idshopper := v_idshopper;
       p_gtotal    := v_gtotal;
       p_fname     := v_fname;
       p_lname     := v_lname;
    END;Regards,
    Tip: to post formatted code, please enclose it between {noformat}{noformat} tags (start and end tags are the same) :)
    Edited by: Walter Fernández on Mar 3, 2009 8:19 PM - Adding procedure (not tested)...
    Edited by: Walter Fernández on Mar 3, 2009 8:20 PM - Adding useful tip...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Powershell Variable from Excel.VBA Macro

    Hi Guys!
    I don't know if what i'm asking you is achievable.
    I've learned how to pass variables/arguments from powershell to Excel/VBA Macro but i need to do the opposite thing.
    This is an example of what  i want:
    Powershell                                                                      
                       Excel/VBA Macro
    $Input=1   ---------------------------------------------------------------->   Sub Macro(input)
    $excel.Run("Macro",$Input)                                                              
      Output=input +6
    $output (Expected 7)   <----------------------------------------------------  return Output
    I don't know how to do this can you help me please?
    A

    Ok guys those are the script.
    Macro:
    Sub CreatePWD()
    Dim PWD As String
    Dim i As Integer
    Dim Max As Integer
    Dim F1 As Worksheet
    Set F1 = ThisWorkbook.Worksheets("Foglio1")
    Max = F1.Range("A1").Value
    For i = 1 To Max
    If Int((2 * Rnd) + 1) = 1 Then
    PWD = PWD & Chr(Int((90 - 65 + 1) * Rnd + 65))
    Else
    PWD = PWD & Int((9 - 0 + 1) * Rnd + 0)
    End If
    Next i
    MsgBox PWD
    End Sub
    Powershell:
    $Excel = New-Object -ComObject excel.application
    $Excel.visible=$false
    $Version = "C:\Users\Alberto Corona\Desktop\Cartel1.xlsm"
    $WorkBook= $Excel.workbooks.open($Version)
    $WorkSheet= $WorkBook.worksheets.item(1)
    $WorkSheet.cells.item(1,1)=5
    $Excel.Run("CreatePWD")
    $WorkBook.save()
    $WorkBook.close()
    $Excel.quit()
    The result of macro is like "52UT7" i want a variable in powershell called $PWD that contain the value of the macro. 
    Hope the problem is clear now.
    Thanks
    A

  • CI - Powershell Boolean Rule Always Returns True

    I'm trying to create a configuration baseline / item for a particular piece of software using a powershell script of data type Boolean. However, I'm having the issue that the evaluation is always returning compliant whether the workstation is or not. The
    script is as follows:
    $ErrorActionPreference = "SilentlyContinue"
    $Condition1 = (Test-Path -LiteralPath 'HKLM:\SOFTWARE\Adobe\Premiere Pro')
    $Condition2 = (Test-Path -LiteralPath 'C:\Program Files\Adobe\Adobe Premiere Pro CS6\Presets\Textures\720_govt1_bar.png')
    if ($Condition1) {
    if ($Condition2) {echo $true}
    else {echo $false}
    else {echo $true}
    This script works perfectly fine when run locally and always returns $true or $false as expected. However it only ever returns Compliant when used in a CI. It doesn't matter what the state of the 2 conditions are, it always evaluates Compliant.
    Any ideas?

    I'm beginning to wonder if there is variation between how well this feature works on Windows 7 and Windows 8.1. I'm beginning to notice that it usually works well on 7 but I have constant hell with it on 8. The last thing I tried which seemed to work (assuming
    it was not just randomness) was accepting the default "Platform" settings of the CI/CB. Before I had chosen Windows 7 and 8.1 only and was never able to return any value except Compliant on 8. Accepting the all platforms default Finally
    allowed me to show a state of Non-Compliant on 8. This was using a powershell script of string data type as discussed previously.
    My latest torment is discovering how to force a true re-evaluation of an updated CI/CB. In my non-compliant Win8 example, I have added a remediation script to an existing Monitor-Only CI and configured it to remediate. In my Win 7 members of the collection,
    everything works successfully, the condition is remediated and the state reports Compliant but on the Win8, although the local Control Panel applet shows both the CB and CI to have new revisions and the evaluation shows it has run with a new date/time,
    the remediation script never runs and changes to Compliant.
    Any suggestions how I can force an updated CI/CB to really re-evaluate, not just report it has?

  • How do I refresh a table with a bind variable using a return listener?

    JDev 11.1.2.1.0.
    I am trying to refresh a table with a bind variable after a record is added.
    The main page has a button which, on click, calls a task flow as an inline document. This popup task flow allows the user to insert a record. It has its own transaction and does not share data controls.
    Upon task flow return, the calling button's return dialog listener is invoked which should allow the user to see the newly created item in the table. The returnListener code:
        // retrieve the bind variable and clear it of any values used to filter the table results
        BindingContainer bindings = ADFUtils.getBindings();
        AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("pBpKey");
        attr.setInputValue("");
        // execute the table so it returns all rows
        OperationBinding operationBinding = bindings.getOperationBinding("ExecuteWithParams");
        operationBinding.execute();
        // set the table's iterator to the newly created row
        DCIteratorBinding iter = (DCIteratorBinding) bindings.get("AllCustomersIterator");
        Object customerId = AdfFacesContext.getCurrentInstance().getPageFlowScope().get("newCustomerId");
        iter.setCurrentRowWithKeyValue((String)customerId);
        // refresh the page
        AdfFacesContext.getCurrentInstance().addPartialTarget(this.getFilterText());
        AdfFacesContext.getCurrentInstance().addPartialTarget(this.getCustomerTable());But the table does not refresh ... The bind variable's inputText component is empty. The table flickers as if it updates. But no new values are displayed, just the ones that were previously filtered or shown.
    I can do the EXACT SAME code in a button's actionListener that I click manually and the table will refresh fine. I'm really confused and have spent almost all day on this problem.
    Will

    Both options invoke the create new record task flow. The first method runs the "reset" code shown above through the calling button's returnListener once the task flow is complete. The second method is simply a button which, after the new record is added and the task flow returns, runs the "reset" code by my clicking it manually.
    I'm thinking that the returnListener code runs before some kind of automatic ppr happens on the table. I think this because the table contents flicker to show all customers (like I intend) but then goes back to displaying the restricted contents a split second later.
    Yes, the table is in the page that invokes the taskflow.
    Here are some pictures:
    http://williverstravels.com/JDev/Forums/Threads/2337410/Step1.jpg
    http://williverstravels.com/JDev/Forums/Threads/2337410/Step2.jpg
    http://williverstravels.com/JDev/Forums/Threads/2337410/Step3.jpg
    Step1 - invoke new record task flow
    Step2 - enter data and click Finish
    Step3 - bind parameter / table filter cleared. Table flickers with all values. Table reverts to previously filterd values.

  • I can't over give my variable to the return in the get Method!

    Hello Java Cracks
    At the moment I am working with JDOM. I am able to get access to the XML File with JDOM, but when I want to send, the value of a variable, which I get from the XML File it is not possible. When I try to send the variable to the get Method (getDtdVersion), the value I over give is always �null�. Please help me, and say what the problem is?
    I also post you the second class, where I want to use the variable I over give.
    Here is my code:
    Class 1, I take the String from this class. See the arrow
    package FahrplanXML;
    import java.io.File;
    import java.io.IOException;
    import javax.swing.JFileChooser;
    import javax.swing.filechooser.FileFilter;
    import org.jdom.Attribute;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.JDOMException;
    import org.jdom.input.SAXBuilder;
    import org.xml.sax.InputSource;
    public class FileAuswahl {
    private File filenames;
    private String scheduledtdversion;
    public void ablauf() throws JDOMException, IOException {
    FileAuswaehlen();
    saxwer();
    grundoberflaeche xmloberflaeche = new grundoberflaeche();
    xmloberflaeche.grundoberflaechen();
    public void FileAuswaehlen() {
    JFileChooser datei = new JFileChooser();
    datei.setFileFilter(new FileFilter()
    @Override public boolean accept (File f)
    return f.isDirectory() ||
    f.getName().toLowerCase().endsWith(".xml");
    @Override public String getDescription()
    return "XML-Files";
    int state = datei.showOpenDialog(null);
    if (state == JFileChooser.APPROVE_OPTION )
    filenames = datei.getSelectedFile();
    System.out.println (filenames);
    if (filenames != null)
    try {
    System.out.print(filenames);
    saxwer();
    } catch (JDOMException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    else
    System.out.println("Kein File ausgew�hlt");
    else
    System.out.println("Auswahl abgebrochen");
    System.exit(0);
    //Ausgew�hlter Dateiname an saxwer �bergeben
    public File getNames() {
    System.out.println (filenames);
    return this.filenames;
    public void saxwer() throws JDOMException, IOException {
    //FileAuswahl filename = new FileAuswahl();
    File files = getNames();
    System.out.println (files);
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(files);
    Element schedulemessage = doc.getRootElement();
    //Root Element auslesen
    String sch_msg_dtdversion = schedulemessage.getAttributeValue ("DtdVersion"); // <---
    scheduledtdversion = sch_msg_dtdversion;
    new grundoberflaeche().grundoberflaechen();
    public String getDtdVersion() {
    System.out.println (scheduledtdversion);
    return this.scheduledtdversion;
    Now, you will see the class in which I pass the String. See also arrow...
    package FahrplanXML;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.IOException;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.text.Caret;
    import org.jdom.Attribute;
    import org.jdom.JDOMException;
    public class grundoberflaeche {
    // Layout f�r Laender vorbereiten
    static void addComponent (Container cont,
    GridBagLayout diversemoegl,
    Component laenderdetails,
    int x, int y,
    int width, int height,
    double weightx, double weighty )
    GridBagConstraints grundoberflaechen = new GridBagConstraints();
    grundoberflaechen.fill = GridBagConstraints.BOTH;
    grundoberflaechen.gridx = x; grundoberflaechen.gridy = y;
    grundoberflaechen.gridwidth = width; grundoberflaechen.gridheight = height;
    grundoberflaechen.weightx = weightx; grundoberflaechen.weighty = weighty;
    diversemoegl.setConstraints(laenderdetails, grundoberflaechen);
    cont.add(laenderdetails);
    //Ausw�hlen des XML Files
    public void XMLAuswaehlen() {
    JFrame xmlauswahl = new JFrame("Fahrplan ausw�hlen");
    xmlauswahl.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container laenderdetails = xmlauswahl.getContentPane();
    GridBagLayout diversemoegl = new GridBagLayout();
    laenderdetails.setLayout(diversemoegl);
    JButton dateiauswahl = new JButton ("Datei ausw�hlen");
    addComponent(laenderdetails,diversemoegl,dateiauswahl,1,1,1,1,1,1);
    ActionListener ersterdateiauswaehler = new ActionListener()
    public void actionPerformed( ActionEvent e)
    try {
    new FileAuswahl().ablauf();
    } catch (JDOMException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    dateiauswahl.addActionListener(ersterdateiauswaehler);
    xmlauswahl.setSize(150,70);
    xmlauswahl.setVisible(true);
    //Layout machen
    public void grundoberflaechen() {
    JFrame fahrplan = new JFrame("Fahrplanauswahldetails");
    fahrplan.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container laenderdetails = fahrplan.getContentPane();
    GridBagLayout diversemoegl = new GridBagLayout();
    laenderdetails.setLayout(diversemoegl);
    //Klassenobjekt aufbauen
    FileAuswahl fileauswahl = new FileAuswahl();
    // Labelsbauen und einbauen in den Fahrpl�nen
    String dtdversion = fileauswahl.getDtdVersion(); // <---
    System.out.println(dtdversion);
    JTextField DtdVersion = new JTextField(1);
    DtdVersion.setText(dtdversion);
    JTextField fahrplanzeit = new JTextField(1);
    fahrplanzeit.setText("123");
    JTextField fahrplanzeita = new JTextField(1);
    fahrplanzeita.setText("piips");
    //JButton oesterreich = new JButton("�sterreich");
    //JButton italien = new JButton("Italien");
    //JButton frankreich = new JButton("Frankreich");
    //JButton spanien = new JButton("Spanien");
    addComponent(laenderdetails,diversemoegl,new JLabel("Fahrplandetails"),0,0,1,1,0,0);
    addComponent(laenderdetails,diversemoegl,DtdVersion,1,0,1,1,0,0);
    addComponent(laenderdetails,diversemoegl,fahrplanzeit,2,0,1,1,0,0);
    addComponent(laenderdetails,diversemoegl,fahrplanzeita,3,0,1,1,0,0);
    // Action Listener f�r Dateiauswahl
    // Action Listener f�r das Speichern der Datei
    //addComponent(laenderdetails,diversemoegl,frankreich,2,1,1,1,0,0);
    //addComponent(laenderdetails,diversemoegl,spanien,3,1,1,1,0,0);
    fahrplan.setSize(600,750);
    fahrplan.setVisible(true);
    Thank you very much for your help....
    Your Java Learner

    I suspect you are setting the scheduledtdversion member in one instance of your FileAuswahl class, but are creating yet another instance of that class and printing the member of that instance, which is null. I notice you are creating a new FileAuswahl instance each time something happens, rather than reusing the same instance.
    FileAuswahl fileauswahl = new FileAuswahl();Ok, new object here. Not the same one that you previously set the scheduledtdversion member in
    String dtdversion = fileauswahl.getDtdVersion();It's null of course, for the reason above.

  • 0ORGUNIT variable doesn't return a hierarchy node

    Hi Gurus,
    I'd like to use 0ORGUNIT variable based on 0ORGUNIT characteristic to let my managers see only those employees there're responsible for. I am using 0ORGEH hierarchy.
    The variable seems to work fine, but it returns only a single value for 0ORGUNIT, not a hierarchy node.
    Does anyone know why is that and what should I do to make it work?
    Regards,
    Dorota

    Ok, solved my problem.
    I've created Customer Exit variable and copied the SAP-Exit code to ZXRSRU01 include of EXIT_SAPLRRS0_001 FM.
    Then added one row:
    ls_range-high = '0ORGUNIT'.
    And everything works just fine

  • Help with ynamic variable evaluation

    Hi guys,
    If someone can point me out to how to evaluate variables as
    part of an expression.
    for ex:
    event.result.reporting.series[0].eval("y"+j+"Label");
    basically how do i write the equivalent of eval in
    flex/actionscript
    Thanks a ton,
    Pranay

    Thanks Greg, saved my day................
    1 more question
    Problem:
    My flex httpservice returns an xml file in the "object"
    resultFormat.
    How could I get the count of all childNodes of an object in
    that returned object tree.
    For example, in the xml file below:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <reporting>
    <series>
    <title>Edge Page Views, in Page Views per
    Second</title>
    <xLabel>startdatetime</xLabel>
    <y1Label>sum(pageviews)</y1Label>
    <data>
    <x>1216233600</x>
    <y1>79.605</y1>
    </data>
    <data>
    <x>1216233900</x>
    <y1>78.076</y1>
    </data>
    </series>
    <series>
    <title>Total Bandwidth, in Mbits per
    Second</title>
    <xLabel>startdatetime</xLabel>
    <y1Label>sum(egress_bytes_mbps)</y1Label>
    <y2Label>combined_midgress_bytes_mbps</y2Label>
    <y3Label>ovh_bytes_mbps</y3Label>
    <y4Label>sum(ingress_bytes_mbps)</y4Label>
    <data>
    <x>1216233600</x>
    <y1>36.160352</y1>
    <y2>66.48362700000001</y2>
    <y3>66.48362700000001</y3>
    <y4>96.01235200000002</y4>
    </data>
    <data>
    <x>1216233900</x>
    <y1>34.260794</y1>
    <y2>62.10649799999999</y2>
    <y3>62.10649799999999</y3>
    <y4>88.902323</y4>
    </data>
    <data>
    <x>1216234200</x>
    <y1>35.329617</y1>
    <y2>62.77339099999999</y2>
    <y3>62.77339099999999</y3>
    <y4>89.30751</y4>
    </data>
    </series>
    </reporting>
    The first series element has 4 children
    I am able to get the number of data elements as:
    "resultObj.reporting.series[0].data.length"
    How do I effectively retreive:
    "resultObj.reporting.series[0].childNodes().length"
    Apparently this does'nt work, I also tried Nodes, children().
    Any documentation or help with this would be awesome
    Thanks a ton
    Pranay

  • Stripping variables for carriage returns

    Hi all, would appreciate any thoughts on this problem......
    Using the Show Me ODBC piece as a guide, I've successfully
    imported a table
    from an access database. The table comprises three fields
    [ID], [Question],
    [Response] which are stored as a variable called DB_ODBCData.
    This variable
    looks something like this:
    "1\tQuestion bla bla bla\tResponser bla bla
    bla100\r2\tAnother question bla
    bla\tAnother response bla bla\r3\Question 3 bla bla........ "
    etc etc
    I was then able to split this into three separate variables
    (eg. varID,
    varQuestion, varResponse) by sorting DB_OBDCData as a list.
    Everything
    looks fine and I'm able to display the correct field in the
    correct
    variable.
    However, if there is a carriage return in the actual field in
    the database,
    for example.....
    Can you confirm the times the following evidence were found:
    1) the watch
    2) training shoe
    ....this messes up my variables. It treats the carriage
    returns in the
    questions as an end of field, consequently (in the example
    above) "Can you
    confirm...." would be assigned to varQuestion correctly, but
    "1) the watch"
    ends up in varResponse, and "2) training shoe" ends up in
    varID
    I have tried to use the Authorware STRIP command to remove
    unwanted carriage
    returns from the DB_OBDCData variable, but this is
    unworkable. It won't
    recognise the carriage returns as anything other than "\r",
    which
    consequently strips away all the field separation and leaves
    everything in
    one big variable!
    Any clues guys as to how I can overcome this problem? I know
    the easiest
    thing would be to ensure there were no carriage returns in
    the actual
    database fields, but for other reasons this is impossible to
    achieve.
    TIA
    Reg.

    You could have just replaced it with something short, like
    "~". But
    whatever.
    "RegTheDonk" <[email protected]> wrote in
    message
    news:[email protected]...
    > Thanks everybody for your help :-)))
    >
    > Amy, the actual data within the database is inserted "on
    the fly" by
    > students. Its part of a system that is used for
    communicating in critical
    > incident simulations - they type in a question which the
    "control room"
    > answers appropriately. As time and pressure is a factor,
    they won't
    > adhere
    > to any specific rules like not using the carriage
    return, or using special
    > characters like ~ etc. So Im stuck with what I've got,
    > unfortunately....(they won't be to fussed about the
    spelling or grammer
    > either lol!)
    >
    > Steve, I'm unable to modify or control the table
    structure as the
    > databases
    > in question are part of a larger, non-open source
    programme, specifically
    > written for the above purpose. The reason I've been
    asked to get involved
    > is to make a kind of "3rd party application" where
    observers can view the
    > communications between students and trainers, to assist
    their own
    > debriefing
    > sessions. The main programme was developed by a company
    which offers no
    > real support, so its up to the clients to try and make
    any improvements on
    > the system themselves.
    >
    > Fortunately, as the first field [ID] always starts with
    a number, I tried
    > a
    > variation of Mike's idea and did a series of REPLACE
    statements on the
    > variable; eg:
    >
    > tempString := Replace("\r1", "carriagereturn1",
    tempString)
    > tempString := Replace("\r2", "carriagereturn2",
    tempString)
    > tempString := Replace("\r2", "carriagereturn3",
    tempString) etc etc,
    >
    > .... I then STRIPed out all the returns "\r" that were
    left, which
    > eliminated any returns that the students had typed
    themselves....
    >
    > .... I then re-REPLACEed the "carriagereturn1" with
    "\r1" etc.
    >
    > Its a bit long winded, but blow me - as long as a
    student doesn't start an
    > input with a number (which should never happen) it
    works!
    >
    > Thanks again everyone for your suggestions....doubtless
    I'll be along with
    > other problems as this thing gets bigger! lol
    >
    > Cheers,
    >
    > Reg.
    >
    >

  • Remote Exchange Powershell invoke command - customize return result

    Hi
    I am trying to create a powershell which connects to an exchange management shell and executes a command.
    [scriptblock]$Command = {Get-MailboxDatabaseCopyStatus | select Name,ContentIndexState}
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$Computername/powershell -Credential $Cred
    Import-PSSession $Session
    $Returnvalue = $Command.Invoke()
    Remove-PSSession $Session
    This would return a result like this:
    Name : DB02 - Specielle\EXCHANGE01
    ContentIndexState : Healthy
    Name : DB01 - Standard\EXCHANGE01
    ContentIndexState : Healthy
    Now how do I create an if-sentence that would check if both are "Healthy" and then return "Echo "Healthy"", else if one is not healthy then return "Echo "Not Healthy""? (I dont need to specify which one that
    isn't healthy).
    Best Regards,
    Soren

    Hi Soren,
    Give this a try (untested, sorry):
    [scriptblock]$Command = {
    $healthy = $true
    $statusList = Get-MailboxDatabaseCopyStatus
    foreach ($status in $statusList) {
    If ($status.ContentIndexState -ne 'Healthy2') { $healthy = $false }
    If ($healthy) { Write-Output 'Healthy' }
    Else { Write-Output 'Not Healthy' }
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)

  • Powershell Variables

    Hello there,
    I have a code in a following way:
    $a = "1234"$b = "`$a"$a
    $b
    The Output of this code is:
    1234
    $a
    Is it possible to use variable $b to get the content of variable $a when variable b includes variable a itself?  Something like that
    *somestring* $b
    Output of this should be: 1234
    Thank you very much for help!
    Regards
    Christoph

    Hi,
    @Mike: you are right. This is working with that code. But I would like to read out the information out of a file. The file got the following content:
    Submitter | 550000010 | c | 30 | $AR_SUBMITTER
    I would like to use the $AR_SUBMITTER variable in my own code.
    For that I use the following code:
    FUNCTION getFile ($path)
    $input = Get-Content $path | select-string -notmatch "#"
    foreach ($line in $input)
    $separator = $line.line.split("|")
    $database_name = $separator[0].Trim()
    $database_id = $separator[1].Trim()
    $data_type = $separator[2].Trim()
    $maximum_length = $separator[3].Trim()
    $value = $separator[4].Trim()
    return $value
    $AR_SUBMITTER = "123"
    $path = "file.txt"
    $Output = getFile($path)
    $AR_SUBMITTER
    $test = """$Output"""
    $test$test2 = (get-item Variable:$Output).Value
    $test2
    The Output here is:
    123
    "$AR_SUBMITTER"
    @Bill: I can't use the get-item-option. For that I got the following error-Code:
    Get-Item can't find path "Variable:\$AR_Submitter
    Thanks for your help!
    Regards
    Christoph

  • Running Powershell command from PHP returns blank page

    Hi. :-)
    I have this script :
    <?php
    $q = shell_exec('powershell Get-Help');
    echo $q;
    ?>
    This works well and gives me output.
    But... When I change Get-Help with Get-VM it gives me blank page as ouput. I have simillar problems with other Hyper-V cmdlets.
    This is code 1:
    <?php
    $q = shell_exec('powershell Get-VM');
    echo $q;
    ?>
    This code gives me blank page.
    Code 2:
    <?php
    $q = shell_exec('powershell Start-VM 'Vm1'');
    echo $q;
    ?>
    This code gives me that it cannot find VM with that name.
    What's the problem, what to change in script or system settings.
    Note: All this commands WORK and gives me output when I run it from cmd
    Things that I did:
     1. Changed execution policy to Unrestricted
     2. Added 2<&1 at the end of shell_exec.
    Thanks in advance.

    Hi,
    I think we should run powershell as adminitrator to get VMs.
    Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-VM"'
    Regards,
    Yan Li
    Regards, Yan Li

  • Store DisplayName as a Powershell Variable

    Good day All,
    I am attempting to create a script that watches a user account for a change in name. The reason is long, and unimportant, but I have created an automated script to log into Office 365, and get the user properties using 
    $checkName = Get-User -Identity [email protected] | FL DisplayName
    But, when I do:
    Write-Host $checkName
    It gives me: 
    Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData
    That. No idea why. Does anyone have any ideas on how to accomplish this? What I'm looking for is to keep the output, which looks like this when I do it in the shell:
    PS C:\Windows\system32> Get-User -Identity [email protected] | FL DisplayName
    DisplayName : First Last
    PS C:\Windows\system32>
    to save as just "DisplayName : First Last" so that I can compare it using:
    if($checkName -like "DisplayName : First Last"){
    $Result = "Name is Good!"
    $NagiosStatus = "0"
    }else{
    $Result = "NAME HAS CHANGED!!"
    $NagiosStatus = "1"
    To eventually be able to configure Nagios to watch it? I know this is a weird request, but sometimes weird things must be done. Thank you in advance for any help you can provide!
    -Ricky

    This is so cool, and works perfectly! Thank you so much for the help!
    For anyone else who may be looking to do the same, I'll add my script with comments, so you can preform the whole of what I'm going to do as well. I've not completely finished tweaking it to work in Nagios, and I may update it after it does so others can
    use it as well, but here it is as it currently reports:
    # Nagios Username Detection Script
    # Author: Ricky and some other templates I've used online
    # Version 0.1
    # Will be updated once working to version 1.0
    # Compatibility:
    # Nagios Version: 3.x.4.x
    # Exchange Version: Office 365 2013
    # Powershell Version: 2.0
    # NSClient++ Version: 4.x
    #——– User ———–
    $user = “[email protected]
    #——– Password: SECURE - Use a secure string for authentication, required secure string to be made ———–
    $pass = Get-Content C:\Users\user\Documents\WindowsPowerShell\SecureStrings\365securestring.txt | convertto-securestring
    $credential = New-Object System.Management.Automation.PsCredential($user, $pass)
    # Link to description of creating secure string: http://community.office365.com/en-us/f/148/t/81993.aspx
    # Command to create a secure string: read-host -prompt "Enter password to be encrypted in mypassword.txt " -assecurestring | convertfrom-securestring | out-file C:\Users\...\365securestring.txt
    #——– Import office 365 Cmdlets ———–
    Import-Module MSOnline
    #———— Establish an Remote PowerShell Session to office 365 ———————
    Connect-MsolService -Credential $credential
    #———— Establish an Remote PowerShell Session to Exchange Online ———————
    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
    #———— Set the warning prefrence to prevent output from connecting
    $WarningPreference = "SilentlyContinue"
    #———— This command that we use for implicit remoting feature of PowerShell 2.0 ———————
    Import-PSSession $session | Out-Null
    $checkName = Get-User -Identity [email protected] | select DisplayName
    if($checkName.displayname -eq "First Last"){
    $Result = "Name is Good!"
    $NagiosStatus = "0"
    }else{
    $Result = "NAME HAS CHANGED!!"
    $NagiosStatus = "1"
    Write-Host $Result
    Write-Host $NagiosStatus
    Thank you again Amit for your help! SO EXCITED TO HAVE THIS DONE!!
    -Ricky

  • Customize powershell prompt to display return code of last command

    Displaying $? in the prompt function of $profile always returns "True". How do I make my customized prompt display the status of the command I just ran?
    Thanks!
    Jon

    Thanks, Bill! For some reason, the first time I tried to park the value of $?, it didn't work. I must have done something wrong. Anyway, it does what I want now. Thanks much!
    function Prompt {
    $var=$?
    write-host ("⌠ ") -nonewline -foregroundcolor green
    write-host ($(get-location)) -foregroundcolor white
    write-host ("| $var") -foregroundcolor green
    write-host ("⌡") -nonewline -foregroundcolor green
    return " " 
    Jon

Maybe you are looking for

  • BT Yahoo e-mail Account and MacBook Pro

    Hi All This is my very first post, so please be patient if this topic has:  1) Already been covered.  The ones I have found seem a bit too technical for me (embarrassing!) 2) Shows I'm a bit of a novice For a number of months now I have been happily 

  • Passing a FILENAME from a LINUX SHELL Script to an SQLPLUS Script

    I written a LINUX Shell Script to receive a FILENAME. This FILENAME is the name of the file that I want to SPOOL into. So, below are two items. The first item is the LINUX Shell Script that has the FILENAME The last item is the SQLPLUS Script that is

  • Trying to understand the SubBass plugin...

    Hi, I'm experimenting with applying the SubBass plugin to kick drum tracks. Basically what I'm trying to achieve is the addition of some lower end thump (30-40hz) to kick drums that I've recorded that have a fundamental around 60-70hz. There are a fe

  • Can u add a background image to a 3D annotation?

    I like many others here are interested in 3D in web pages and to do so I would need to at times add background images to 3D annotations within the acrobat 3D embed to match the html page. Is this possible? -Thanks!

  • How to calculate the length of a string

    Hi everyone, A simple question. How to calculate the length of a string? Thanks!