How to use substring on a property within a "select -expand properties" statement

Apologies if this is a dumb question - I'm just familiarizing myself with Powershell.
I have an existing script which queries groups in AD. It outputs some attributes of the groups to a CSV file.
I'm trying to modify it a little bit - one of the attributes it returns is the distinguishedname of each group. I'm trying to get it to chop off the first part ("CN=groupname,"), leaving the OU path of each group.
Here is the original line that I think needs to be modified:
$AllGroups = $GroupAccounts | select -Expand Properties | select @{n='GroupName';e={$_.name}}, @{n='Description';e={$_.description}}, @{n='DN';e={$_.distinguishedname}}
Based on what I've gleaned so far about Powershell, I figured I would use the substring function, along with the length of the group's name (plus 4 to account for the "CN=" and the first comma). But every variation that I've tried returns nothing
at all for the last property ("DN").  
Any suggestions?

Hi,
Here's an example:
Get-ADUser testac1 |
Select @{N='DN';E={$_.DistinguishedName.Substring($_.DistinguishedName.IndexOf(',')+1)}}
Output:
DN
OU=Test 1,DC=domain,DC=local
Don't retire TechNet! -
(Don't give up yet - 12,950+ strong and growing)

Similar Messages

  • How to use substring in  ITS(HTML file)

    Hai,
    I am modifying d_searchhelp.html file in agate. I want a use a substring function this file. So I used the below code.
      newclassname=~searchhelpcontrolname;
      oldclassname=newclassname.substring(0,8);
                                                                ^ ^ ^
    This is the error i got when i use this HTML file in searchhelp.
    @ ...\templates\system\dm\msiexplorer\d_searchhelp.html (263,42): error : syntax error   : '('
    @ ...\templates\system\dm\msiexplorer\d_searchhelp.html (263,44): error : syntax error   : ','
    @ ...\templates\system\dm\msiexplorer\d_searchhelp.html (263,46): error : syntax error   : ')'
    Please let me know how to use substring.
    Thanks & Regards,
    H.K.Hayath Basha

    Hello H.K.Hayath Basha,
    please see the HTML Business documentation on <http://help.sap.com/saphelp_nw04/helpdata/en/5f/1fb5174aee11d189740000e8322d00/frameset.htm>:
      string strSub (in string string, in int position, in int length)
    With regards,
      TJ

  • How to use warn about changes property with page menus

    how to use warn about changes property with page menus

    Hi,
    If u will enable this property, then u will get warning message as a popup in case of change of state of VO.
    Regards,,
    Gyan

  • How to access the Document Options dialog box to select display properties?

    How to access the Document Options dialog box to select display properties (e.g. smartcut ) for a selected document to
    be viewed in the Workspace.
    regards

    Preferences --> General --> Reset all warnings.
    Mylenium

  • How to use substr in external table defnition.

    Hi All,
    Im using oracle 11g. I have an external table which is reading data from a file. For one of the column, i need to get only the first 250 characters. My external table defnition looks like this
    create table tbl_substr
    ( col1 varchar2(20),
    col2 varchar2(250)
    organization external
    ( type oracle_loader
    default directory XXXX
    access parameters (
    records delimited by newline
    FIELDS TERMINATED BY '|'
    missing field values are null
    ( col1 ,
    col2 "substr(:col2,1,250)"
    ) ) location ('file.txt') )
    reject limit unlimited
    But this defnition gives an error when i do select * from tbl_substr
    I want to use substr in external table defnition its self and not in SELECT. Also i dont want to crete a view to solve this. If anyone has done this please help.

    You need to play with COLUMN_TRANSFORMS
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/et_params.htm#sthref1792
    BTW, i too got it from Google. I was not aware about this :)
    Amardeep Sidhu

  • How to use Substring function with Case statement.

    Hello Everyone,
    I have one requirement where I have to use substring function on the field for report criteria.
    E.G.
    I have Branch Name Field where I have all branch names information, Now some of the branch names are too big with some extension after the name .
    now i want to substing it but the character length varies for each branch.
    so is there any way where we can use case statement where we can define that if branch name character are exceeding some value then substing it with this length.

    Try something like this:
    CASE WHEN LENGTH(tablename.Branch_Name) > n THEN SUBSTRING(...) ELSE tablename.Branch_Name END
    where n is the number of characters you want to start the break.

  • How to use substring ?

    guys,
    i have to get last 3 char. of the char. string.
    now the problem is, the char. string is all different length. if it was the same i could use SUBSTRING formula. but in my case its all diff. and i have to get last 3 char. from the string .
    what shoud i use ?

    Hi Honar,
    Try this
    //<varname>- value whose last 3 character you want to read
    Data : v_length type n length 3,
              v_value_last3 like <varname> .
    *****read the length of value
    v_length = STRLEN(  <varname> ) .
    *****subtract string length index by 3 character
    v_length  = v_length - 3 .
    *****read last 3 character of value
    v_value_last3  =  <varname>+v_length(3) .
    v_value_last3 will have last 3 character
    Please follow spaces as in code .
    This will work .
    Regards,
    Jaya Tiwari

  • HOW TO USE SUBSTR IN PARTITIONING

    HEY ALL,
    CAN I USE SUBSTR IN PARTITIONING
    LIKE DIS
    create table test
    process_id number(19),
    name varchar2(15))
    partition by range(process_id)
    partition p1 values less than (substr(process_oid,-1))
    tablespace test,
    partition p2 values less than (substr(process_oid,-1))
    tablespace test,
    partition p3 values less than (maxvalue)
    tablespace test
    )

    No. You cannot use like that.
    Why don't you run your CREATE statement and check it for yourself. You will get the below error
    ORA-14019: partition bound element must be one of: string, datetime or interval
    literal, number, or MAXVALUE

  • Use 3 button or property to change selection of radio buttons?

    Hi all,
    I have LV 7.1 and am trying to write a process that allows the user to select the next action following the execution of several Case Structure steps.  The VI is basically thus: (sorry I can't cut-n-paste a graphic, it's on another pc.)
    While loop:--->radio button (Manual, Cycle, Auto Test)----> Case Structure (Manual, Cycle, Auto Test)--->Nested Case Structure within the "Auto Test" Case above with 13 cases ("0" to "12")
    On case "12" of the nested case structure, I want to provide a 3-button dialog box (or something that works) which allows the user to select the next test mode (i.e. the 1st case structure: "Manual", "Cycle", "Auto Test").  I can't figure out how to send anything that the property node "Value" of the radio button can use for this selection.  When I create an indicator to see what is sent from the 3-button, it shows ("Left", "Center", or "Right") "Button" strings.  The radio button "Value" property node needs an enum.  The labels on the 3-button don't seem have any consequence. 
    Any Suggestions? 
    Best Regards,
    Ed

    Dev,
    Thanks for the reply.  I experimented with the Property Node and Radio Button control extensively and figured out my problem.  It had to do with the difference between Labels, Captions, and Boolean Text.  I believe I had a caption on one of my buttons rather than the label, so the property node didn't see it as an option.  Through all the help screens that had the option of explaining this to me, it wasn't until I had fixed the problem before I found one that addressed the differences between those terms.  I'll attach my experiment vi (created with LV 7.1) for anyone like myself (non-programmer, inexperienced LabVIEW'er) that would like to see the basic function.
    Attachments:
    Property node experiment.vi ‏56 KB

  • How to use a collection type of bind variable for execute dynamic statement

    Hi,
    We have a case where we copy selective data from Schema A To Schema B in one oracle database. The copy is achieved by using
    execute immediate 'insert into '||target_schema||'.tablea select * from '||from_schema||'.table a where a.id in (select test_id from '||from_schema||'.table c);';
    This works fine it takes an average of 10 seconds to copy around 14 tables. We have a requirement to bring this time to 2 seconds. One observation has been the clause
    "select test_id from '||from_schema||'.table c" in the above sql statement repeats for many inserts . Thus we were thinking to bulk fetch this set of tests ids and use a bind vatiable of collection type for the execute immediate clause. Any suggestions on how to achieve it?
    Thanks,
    Chandana

    >
    One observation has been the clause
    "select test_id from '||from_schema||'.table c" in the above sql statement repeats for many inserts
    >
    So what? Constructing a string for a table level insert and parsing it can't possibly be a performance problem. If you were creating a string in a loop to insert rows into a table by getting the data FROM a collection - that's a problem that keeps showing up in the forums.
    I'm with bravid and Nikolay on this one. First find out which side, select/insert, the problem is on.
    As they said you need to provide more information about the process.
    And using collections for your use case is definitely not the thing to do.
    1. How many rows are we talking about?
    2. Are the rows being inserted into an empty table?
    3. Are you running these queries during peak production hours or in a batch windows?
    Tune the SELECT if the problem is on that side.
    Post an execution plan for the SELECT part of a query you think should run faster.
    SET SERVEROUTPUT ON
    SET AUTOTRACE TRACEONLY
    SQL> select * from emp;
    Execution Plan
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |    14 |   546 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| EMP  |    14 |   546 |     3   (0)| 00:00:01 |
    SQL>On the INSERT side you might be able to use bulk inserts
    ALTER TABLE myTable NOLOGGING;
    INSERT /*+ append */ INTO myTable . . .
    ALTER TABLE myTable LOGGINGIf the insert tables are always reused you could just leave them as NOLOGGING. Since you can't recover bulk data you need to make sure to get a good backup after the loads if you need to recover the data from the logs rather than just reload it yourself.

  • How to use OracleParameter whith the IN Operator of select statement

    Hi,
    I am having problems using the OracleParameter when used in a query with a IN operator.
    Following Example:
    oraCommand.Parameters.Add(":List", strMylist ); //or Array???
    The SQL command:
    SELECT * FROM XXX WHERE XXX.YYY IN (:List);
    What datatype must the value of :List be?
    regards
    Stefan

    Let's use a collection of User Defined Types (UDT's).
    First create a table with 1 million rows:
    create table employees (id number(10) not null primary key, name varchar2(100) );
    insert into employees
    select level l, 'MyName'||to_char(level)
    from dual connect by level <= 1e6;
    1000000 rows created
    commit;
    exec dbms_stats.gather_schema_stats(USER, cascade=>TRUE);No we turn to the C# code:
    Let's select employees with id's 3 and 4.
    Collection type MDSYS.SDO_ELEM_INFO_ARRAY is used because if we use this already predefined Oracle type we don't have to define our own Oracle type. You can fill collection MDSYS.SDO_ELEM_INFO_ARRAY with max 1048576 numbers.
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
        [OracleCustomTypeMappingAttribute("MDSYS.SDO_ELEM_INFO_ARRAY")]
        public class NumberArrayFactory : IOracleArrayTypeFactory
          public Array CreateArray(int numElems)
            return new Decimal[numElems];
          public Array CreateStatusArray(int numElems)
            return null;
        private void Test()
          OracleConnectionStringBuilder b = new OracleConnectionStringBuilder();
          b.UserID = "sna";
          b.Password = "sna";
          b.DataSource = "ora11";
          using (OracleConnection conn = new OracleConnection(b.ToString()))
            conn.Open();
            using (OracleCommand comm = conn.CreateCommand())
              comm.CommandText =
                  @" select  /*+ cardinality(tab 10) */ *  " +
                  @" from employees, table(:1) tab " +
                  @" where employees.id = tab.column_value";
              OracleParameter p = new OracleParameter();
              p.OracleDbType = OracleDbType.Array;
              p.Direction = ParameterDirection.Input;
              p.UdtTypeName = "MDSYS.SDO_ELEM_INFO_ARRAY";
              p.Value = new Decimal[] { 3, 4 };
              comm.Parameters.Add(p);
              int numPersons = 0;
              using (OracleDataReader reader = comm.ExecuteReader())
                while (reader.Read())
                  MessageBox.Show("Name " + reader[1].ToString());
                  numPersons++;
              conn.Close();
        }The index on employees.id isn't used when one omits hint /*+ cardinality(tab 10) */. This index is created by Oracle because id is the primary key column.
    Edited by: wateenmooiedag on Dec 30, 2009 2:45 AM

  • SBO - How to use two different Stock Account within the same Item Group

    Hi,
    I'm currently stuck within one of my implementation.
    I'm deploying the same solution worldwide which worked pretty well until now. All the items are connected to an item group, with a unique GL account, supposed to book at the same time the good receipt and the good issue (Balance-Sheet Account = 14xxxxx).
    My new unit is willing to use two different GL accounts when performing its stock entry (let say 14xxx10) and another GL account for the good issue, let say 14xxx20.
    Do you have any clue so i can please them and keep using at the same time the item group ?
    Thanking you in advance
    Stephane

    Hi,
    In fact, we use the GL account as the HQ Account (Reporting Account) while the "Export Code" will be used to store the local GL Account (greek account).
    As such, we can, somehow handle two different chart of accounts.
    In my reporting, i'm only using a single GL account for stock movements, while my greek counterparts want to handle two different accounts.
    Threfore, i have only two solution since there is normally a one to one relationship between a HQ account and a local account that are :
    1 - Duplicate the HQ accounts
    In that case, i do respect anytime the one to one relationship. I've got one HQ account for one local account. But how can i put this since i can only handle one single stock account.
    2 - I keep my single stock account like this but i won't be managing the possibility to get two different Export Codes.
    Regards
    Stephane

  • How To Use a Hidden Page Item within an SQL Report Query without Submitting

    Hi,
    Using: Oracle ApEx 3.0.1
    I have an sql report region that contains a hidden page item as part of the "where clause". My problem is, based on a value entered by the user, I need to assign this value enetered to my hidden item, so that it can be used within the where condition of my sql but this would need to be done without actually submitting the form.
    At the moment, I can set the value via an on-demand process but my SQL is still not returing any values as the hidden page item within the query is not set (as page has not been submitted).
    Can anybody please assist as I am not sure how to do this and whether in actual fact, this is possible to do, without having submitted the page.
    Thanks.
    Tony.
    Edited by: Tony F. on Nov 12, 2011 1:39 AM

    You can set a session value using a dummy ajax call e.g:
    Add the following to the 'Function and Global Variable Declaration' region
    function f_set_item(pThis){
      var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=dummy',1);
      get.add('P1_ID',pThis.value)
      gReturn = get.get();
      get = null;
    }Where P1_ID is the session value to be set. Then call the function in the usual way e.g.
    javascript:f_set_item(this);
    I hope that helps
    Shunt

  • How to use offset and multiplier property in waveform graph?

    hello,
    i m using a waveform graph and wanted to update its x-axis scale depending on the multiplier value. Also how this
    formula of offset n multiplier works (deltaX)*X+X0? What is delta X and X?
    Regards,
    vijtin
    Solved!
    Go to Solution.

    hi,
    X0 is the offset and X is the multiplier.  So the graph will start at a cetain offset and will aa to that the delta value times the multiplier.
    e.g.
    If you would have these normal X-values : 0 ; 1 ; 2 ; 3 ; 4 ; 5 and a multiplier of 2 and ofset of 5 you would get the result on the X-as = 5 ; 7 ; 9 ; 11 ; 13
    Hope this helps
    Kind regards,
    - Bjorn -
    Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's
    LabVIEW 5.1 - LabVIEW 2012

  • How to use adobe Flash Player offline within a webpage?

    I am connected to a network that has no internet access.  I am trying to demonstrate a product that is uses adobe flash player within the webpage. The webpage first goes to "http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf" file and then goes to the stream.  Is there anyway to download that file and store it locally to get the stream to work properly? Is there a standalone flash player that does not require GET to the swf file to start streaming the media?  What would be the best way to go about this issue?

    There IS a standalone Flash Player but is's part of Flash Professional. You'd need to purchase it (or download a 30 day trial, but I don't know if the Flash Player would keep working after the trial expires).

Maybe you are looking for

  • How can i add more than one portlet description in my provider.xml

    I already tested MyFirstPortlet developed using JPDK and is working fine.I add one more portlet description in the same provider.xml. But the new portlet is not getting displayed under the provider when i try to add it in my page. null

  • Firefox,Chrome, or Safari on Mountain Lion

    I have upgraded to Mpountain Lion for Lion. I have seached for software updates to find none. After a few days Safari seems slow and sluggish. Downloads are real slow. I used to use Firefox before I switch for Windows 7 to the Apple World. I am wonde

  • SAPStructure.GetSAPFieldsSchema

    Hi, I use the SAP.Connector 2.0 in a Windows 2003 SP1 environment and SAP R/3 6.20. In this case I want executing the same RFC in two different SAP environments from WebService ASP.Net. The client is a ASP application and communicate with the WebServ

  • Connecting a Canon GL2 to Prem v5.5 on a current Macbook Pro?

    I have the following: Canon GL2 camera, Adobe Premiere 5.5 and a 15-inch Macbook Pro w/Retina Display. I need to capture recordings from the camera into Premiere. Which cable or combination of cables (if any) will allow me to do so? The GL2 has a DV

  • Two SID installation a single machine???

    Hello, it's possible to install a single 2 system with the same SID on a machine??? (ECC 6.0, oracle 10,win 2003)     Thank you!