Powershell and -contains

Hi, 
I have a little problem with powershell and "contains"
In this situation works well and return "true"
$test = "where is the word"
($test).Contains("word")
but in this other return always "false" 
$test = Get-Process
($test).Contains("winlogon")
Why? 
Thanks
Andrea Gallazzi
windowserver.it - blog:
andreagx.blogspot.com
This posting is provided AS IS with no warranties, and confers no rights.

Hi,
Try looking at the ProcessName property:
PS C:\Scripts\PowerShell Scripts\Misc Testing\1-10-2014> $test = Get-Process
PS C:\Scripts\PowerShell Scripts\Misc Testing\1-10-2014> $test.ProcessName.Contains('winlogon')
True
EDIT: If I remember correctly, I believe this requires PS3+ though.
EDIT2: This will work if you only have v2 (I'm sure there's a better way to do this, but this'll work in a pinch):
PS C:\> $found = $false
PS C:\> $test = Get-Process
PS C:\> $test | ForEach { If ($_.ProcessName.Contains('winlogon')) { $found = $true } }
PS C:\> $found
True
Don't retire TechNet! -
(Don't give up yet - 12,575+ strong and growing)

Similar Messages

  • HT204268; I have purchases on an aol login pre 2008 and all recent stuff under an apple id. I currently see and use everything when i login with the apple id. After March 31st will my apple id account still show and contain all?

    HT204268; I have purchases on an aol login pre 2008 and all recent stuff under an apple id. I currently see and use everything when i login with the apple id. After March 31st will my apple id account still show and contain all?
    I understand the instructions to create a new account id (apple id) from the old aol account. However, does this mean my purchases will be split into 2 accounts; or does the fact that I currently see everything under my apple id (regardless of the purchased by username) mean this will all still appear in my current account as it does now?

    You see them where when you login your non-AOL account ?
    If you currently have two accounts (the AOL username account and an email address account) then you will continue to have two accounts, and nothing should change when you update the AOL account to be an email address (apart from how you access that account).
    You will just be renaming the account to have an email address for accessing it, not creating a new account.

  • Powershell and Sharepoint workflow

    Oke I got this a really strange problem.
    I got a ps1 file with powershell code in it. The code create a list item in sharepoint with all information and on the information I want to trigger a workflow.
    But now if I activated the ps1 file powershell as administrator(automatic) and then run the code thats in the file. But no Workflow tiggered in sharepoint the workflow is automatic activated when a new item is created.
    And the strange thing is if I open my script with notepad copy the text insert it into powershell and press enter my workflow runs...
    So any1 have an idea to fix this?

    Below is code snippet in c#.net for fetching all the attachements for a specific list item.
    try
                    // Set the Site Url
                    SPSite objSite = new SPSite("http://Testsite/");
                    using (SPWeb objWeb = objSite.OpenWeb())
                        objWeb.AllowUnsafeUpdates = true;
                        // Get the List
                        SPList objList = objWeb.Lists["MyList"];
                        // Get the item by ID
                        SPListItem objItem = objList.GetItemById(1);
                        // Get the attachments of the item
                        SPAttachmentCollection objAttchments = objItem.Attachments;
                        // Iterate the attachments
                        foreach (string fileName in objItem.Attachments)
                            // Perform action on
    the extracted attachment
     Hope it
    answer the questions.Any suggestions are appreciated.
    Cheers, Eliza

  • ResultList and Container objects

    The Java ResultList and Container objects are used in SAP Mapping UDF's ...does anyone know which specific jar files contain these object definitions ?
    Thanks,
    Rod.

    For PI 7.0(3.0) you need the libraries: aii_mt_rt.jar, aii_map_api.jar, aii_utilxi_misc.jar
    For PI 7.1 you need the libraries: com.sap.xi.mapping.tool.lib_api.jar, com.sap.xpi.ib.mapping.lib.jar, com.sap.aii.utilxi.server.jar
    /people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio

  • Trying to understand context indexes and contains-help

    Hi
    i am using
    Achieving functionality of many preferences using one context index
    to understand context indexes and contains
    and i get the following
    Error starting at line 1 in command:
    begin
    ctx_ddl.create_preference ('nd_mcds', 'multi_column_datastore');
    ctx_ddl.set_attribute ('nd_mcds', 'columns', 'text nd, text text');
    ctx_ddl.create_section_group ('nd_sg', 'basic_section_group');
    ctx_ddl.add_ndata_section ('nd_sg', 'nd', 'nd');
    ctx_ddl.create_preference ('test_lex', 'basic_lexer');
    ctx_ddl.set_attribute ('test_lex', 'whitespace', '/\|-_+');
    end;
    Error report:
    ORA-06550: line 5, column 15:
    PLS-00302: component 'ADD_NDATA_SECTION' must be declared
    ORA-06550: line 5, column 7:
    PL/SQL: Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    so i am using the following to check for the error
    http://docs.oracle.com/cd/E18283_01/text.112/e16593/cddlpkg.htm#BABCBFCB
    plus
    oracle text application developer's guide
    plus
    oracle text reference
    but these have not listed that error (i have even googled this in vain)
    background::we were actually using catsearch but because of its downsides i want to implement this
    Is Achieving functionality of many preferences using one context index a good place to start when one does not know about
    context and contains??
    please post any other useful link for contains and context index that even explains
    1) fuzzy
    2) stem
    3) synonym
    4) near
    5) soundex
    6)ndata
    7)lexer
    thanks in advance

    Ndata is new to Oracle 11g. Your other posts indicate that you are using Oracle 10g, so you don't have ndata, so you get an error when you try to use it. If you want to use the 11g features that enable context indexes with contains to do all of the things that ctxcat indexes with catsearch do, then you need to upgrade to 11g.
    The online documentation is searchable. Most things regarding Oracle Text are contained in either the Oracle Text Reference or the Oracle Text Application Developer's guide.
    I suggest that you start with something very simple, then build from there.
    The following is similar to your other post that used catsearch:
    SCOTT@orcl_11gR2> CREATE TABLE mv_cat_seg_reg_prod
      2    (cat_ids       VARCHAR2 ( 7),
      3       act_status    VARCHAR2 (10),
      4       name           VARCHAR2 ( 1),
      5       email           VARCHAR2 ( 1),
      6       address1      VARCHAR2 ( 1),
      7       address2      VARCHAR2 ( 1),
      8       contact_name  VARCHAR2 ( 1),
      9       mobile           VARCHAR2 ( 1),
    10       telephone     VARCHAR2 ( 1))
    11  /
    Table created.
    SCOTT@orcl_11gR2> INSERT ALL
      2  INTO mv_cat_seg_reg_prod VALUES
      3    ('1', 'Y', 'A', 'B', 'C', 'D', 'E', 'F', 'G')
      4  INTO mv_cat_seg_reg_prod VALUES
      5    ('2', 'N', 'H', 'I', 'J', 'K', 'L', 'M', 'N')
      6  SELECT * FROM DUAL
      7  /
    2 rows created.
    SCOTT@orcl_11gR2> CREATE INDEX mv_cat_seg_reg_prod_idx
      2  ON mv_cat_seg_reg_prod (cat_ids)
      3  INDEXTYPE IS CTXSYS.CONTEXT
      4  /
    Index created.
    SCOTT@orcl_11gR2> SELECT token_text FROM dr$mv_cat_seg_reg_prod_idx$i
      2  /
    TOKEN_TEXT
    1
    2
    2 rows selected.
    SCOTT@orcl_11gR2> SELECT *
      2  FROM   (SELECT SCORE (1), name, email, address1, address2, contact_name, mobile, telephone
      3            FROM   mv_cat_seg_reg_prod
      4            WHERE  CONTAINS (cat_ids, '1', 1) > 0
      5            AND    act_status = 'Y'
      6            ORDER  BY DBMS_RANDOM.VALUE)
      7  WHERE  ROWNUM < 8
      8  /
      SCORE(1) N E A A C M T
             4 A B C D E F G
    1 row selected.

  • HashSet get() and contains() methods, by value or reference?

    All the tutorials I've seen on HashSets use Strings as the object type. With Strings, it seems the get() and contains() methods work by value, not by reference.
    <CODE>
    String s1 = "dog";
    String s2 = "cat";
    String s3 = "dog";
    HashSet<String> set = new HashSet<String>();
    set.add(s1);
    System.out.println(set.contains(s1)); //true;
    System.out.println(set.contains(s2)); //false
    System.out.println(set.contains(s3)); //true
    </CODE>
    But when I use a custom object, it works by reference:
    <CODE>
    MyClass c1 = new MyClass("dog", 1);
    MyClass c2 = new MyClass("cat", 1);
    MyClass c3 = new MyClass("dog", 2);
    MyClass c4 = new MyClass("dog", 1);
    HashSet<MyClass> myClassSet = new HashSet<MyClass>();
    myClassSet.add(c1);
    System.out.println(myClassSet.contains(c1)); //true
    System.out.println(myClassSet.contains(c2)); //false
    System.out.println(myClassSet.contains(c3)); //false
    System.out.println(myClassSet.contains(c4)); //false
    </CODE>
    ("MyClass" is a simple class that holds a String and an int).
    Is there any way I can get the set to select by value rather than reference for objects that aren't String?
    If so, is it possible that the value test could be customised, so that, for example, the above will return true if the String in MyClass is the same, regardless of the int value?

    803559 wrote:
    With Strings, it seems the get() and contains() methods work by value, not by reference.
    String s1 = "dog";
    String s2 = "cat";
    String s3 = "dog";
    System.out.println(set.contains(s1)); //true;
    System.out.println(set.contains(s2)); //false
    System.out.println(set.contains(s3)); //true
    Is there any way I can get the set to select by value rather than reference for objects that aren't String?Warning: Never use the term "by reference" around Java geeks. It makes 'em go all green at the gills and they start muttering about 'bloody C++ crossovers'.
    However, as DrClap pointed out, you've mis-diagnosed the problem:
    System.out.println(s1 == s1);
    System.out.println(s1 == s2);
    System.out.println(s1 == s3));would print out the exact same results.
    For an explanation why, Google "Java String pool" or try [url http://stackoverflow.com/questions/3297867/difference-between-string-object-and-string-literal]here.
    If so, is it possible that the value test could be customised, so that, for example, the above will return true if the String in MyClass is the same, regardless of the int value?Absolutely. But, as others have said, you'd need to override equals() and hashCode().
    Winston

  • Using databases and container events?

    I'm having trouble finding documents show how one should use databases and listen for container events? I'm using Berkley Java DB. I'll need all my remote object to have access to the database. How do I pass that in? Custom adapters? Also, when Tomcat shuts down I need to close the database, how would this be down? Custom adapters? So I may be answering my own question, but I'm asking cause I really don't see anything in the documentation that points this out. It really looks like I'd be using singletons and factories for this. I could register a Servlet or Servlet Context to listen for Tomcat events, but I figured it couldn't hurt to ask others using Blaze, as I'm very new to it. Thanks.

    So how would you tell Blaze to use this? Is there something you put into the config file? My thoughts on all this is to use PicoContainer to manage all services then create an adapter to inject all resources when creating remote objects. But this seems a little heavy if Blaze can do all this for me. The adapter seems like the injection point to me. Is that not what it's used for? Or is using it like that bad practice under Blaze? I've read all I can find on Blaze, so either it's missing docs, or I'm not finding them all. If I'm missing them, by all means let me know where to go. I don't want to ask questions that are already answered in documents else where.
    On Tue, May 20, 2008 at 10:51 AM, Mete Atamel <
    [email protected]> wrote:
    A new message was posted by Mete Atamel in
    General Discussion --
      Using databases and container events?
    I think it's mainly in JavaDocs but here's a sample I have where I check to make sure the HSQLDB is running as the BlazeDS starts up:
    import java.sql.Connection;
    import java.sql.SQLException;
    import flex.messaging.config.ConfigMap;
    import flex.messaging.services.AbstractBootstrapService;
    public class DatabaseCheckService extends AbstractBootstrapService
        // This is called right before server starts up.
        public void initialize(String id, ConfigMap properties)
            Connection c = null;
            try
                // Check that the database is running...
                c = ConnectionHelper.getConnection();
                // ... if yes return
                return;
            catch (SQLException e)
                System.out.println("DB is not running!");
            finally
                ConnectionHelper.close(c);
    // This is called as server is starting.
        public void start()
            // No-op
    // This is called as server is stopping.
        public void stop()
            // No-op
    View/reply at
    Using databases and container events?
    Replies by email are OK.
    Use the
    unsubscribe form to cancel your email subscription.
    "All that is necessary for the triumph of evil is that good men do nothing." - Edmund Burke

  • Import and contain?

    Hi,
    My wife wants me to import a group of contacts she's compiled of invitees to a party we're throwing. The problem is twofold:
    1) When I import her list, which contains some contacts I already have in my list, her duplicate contacts overwrite my existing ones, which is not good in cases where I have more detailed contact information for the person than she does. Is there a way to import her group without overwriting the duplicates using her info?
    2) There are many contacts in this group that I'll want to delete from my contact list afterward, as my car takes all of my contacts via bluetooth, and I'd rather purge most of this group after the invites are sent. Is there a way to import these individuals and contain them for later deletion without having them added to my main contact list?
    Whew! Thanks for reading all of that, and thanks so much in advance for any help you might be able to give!
    Cheers,
    Rob

    Oops... figured this out, with the update options, and then I can just save my address book and restore it to that saved version whenever I want.

  • Tuning SQL query with SDO and Contains?

    I'trying to optimize a query
    with a sdo_filter and an intermedia_contains
    on a 3.000.000 records table,
    the query look like this
    SELECT COUNT(*) FROM professionnel WHERE mdsys.sdo_filter(professionnel.coor_cart,mdsys.sdo_geometry(2003, null, null,mdsys.sdo_elem_info_array(1,1003,4),mdsys.sdo_ordinate_array(809990,2087279,778784,2087279,794387,2102882)),'querytype=window') = 'TRUE' AND professionnel.code_rubr ='12 3 30' AND CONTAINS(professionnel.Ctx,'PLOMBERIE within Nom and ( RUE within Adresse1 )',1)>0
    and it takes 15s on a bi 750 pentium III with
    1.5Go of memory running under 8.1.6 linux.
    What can i do to improve this query time?
    null

    Hi Vincent,
    We have patches for Oracle 8.1.6 Spatial
    on NT and Solaris.
    These patches include bug fixes and
    performance enhancements.
    We are in the process of making these patches
    avaialble in a permanent place, but until then, I will temporarily put the patches on:
    ftp://oracle-ftp.oracle.com/
    Log in as anonymous and use your email for
    password.
    The patches are in /tmp/outgoing in:
    NT816-000706.zip - NT patch
    libordsdo.tar - Solaris patch
    I recommend doing some analysis on
    individual pieces of the query.
    i.e. time the following:
    1)
    SELECT COUNT(*)
    FROM professionnel
    WHERE mdsys.sdo_filter(
    professionnel.coor_cart,
    mdsys.sdo_geometry(
    2003, null, null,
    mdsys.sdo_elem_info_array(1,1003,4),
    mdsys.sdo_ordinate_array(
    809990,2087279,
    778784,2087279,
    794387,2102882)),
    'querytype=window') = 'TRUE';
    2)
    SELECT COUNT(*)
    FROM professionnel
    WHERE CONTAINS(professionnel.Ctx,
    'PLOMBERIE within Nom and ( RUE within Adresse1)',1) >0;
    You might want to try reorganizing the entire
    query as follows (no promises).
    If you contact me directly, I can try to
    help to further tune the SQL.
    Hope this helps. Thanks.
    Dan
    select count(*)
    FROM
    (SELECT /*+ no_merge */ rowid
    FROM professionnel
    WHERE mdsys.sdo_filter(
    professionnel.coor_cart,
    mdsys.sdo_geometry(
    2003, null, null,
    mdsys.sdo_elem_info_array(1,1003,4),
    mdsys.sdo_ordinate_array(809990,2087279,
    778784,2087279,
    794387,2102882)),
    'querytype=window') = 'TRUE'
    ) a,
    (SELECT /*+ no_merge */ rowid
    FROM professionnel
    WHERE CONTAINS(professionnel.Ctx,
    'PLOMBERIE within Nom and
    ( RUE within Adresse1)',1) >0
    ) b
    where a.rowid = b.rowid
    and professionnel.code_rubr ='12 3 30';
    **NOTE** Try this with no index on code_rubr
    null

  • Powershell and robocopy pausing

    I am using powershell and Robycopy to move files from volume to another.  Server 2008R2 iSCSI volumes on
    It seems that powershell window occasionally pauses.  When I hit enter the process just starts up again.  It is taking more that a day to move 2TB of data.  Command is: robocopy h:\ j:\ /e /mov /R:5 /W:10 /log:c:\movedidson.log /TEE /NP /ETA
    Also an empty folder remains on the first drive.  Why is it not deleting the folders after it copies.
    Thanks,
    Mark

    Hi Mark,
    Total shot in the dark, perhaps this will help:
    http://social.technet.microsoft.com/Forums/en-US/ab36656d-bfbd-4ff1-ac7a-84e2ac975c1d/powershell-hangs?forum=winserverpowershell
    EDIT: Also, this isn't exactly a PowerShell question. You may be using PowerShell to launch robocopy, but that's pretty much the end of anything PowerShell related.
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • LIKE and CONTAINS

    I create index:
    SQL> CREATE INDEX UM2_ATTRS_STR_I_ctx ON UM2_ENTRIES_ATTRS
    (STRING_VALUE) INDEXTYPE IS CTXSYS.CONTEXT;
    2
    Index created.
    I've got 2 query:
    SQL> select count(e.id) from um2_entries e , um2_entries_attrs a where e.id = a.entry_id
    and a.name = 'user.name'
    and a.string_value like '%__%';
    2 3
    COUNT(E.ID)
    1734
    94 msec!!!!!!!!
    SQL> select count(e.id) from um2_entries e , um2_entries_attrs a where e.id = a.entry_id
    and a.name = 'user.name'
    and contains(a.string_value, '%__%', 1) > 0;
    2 3
    COUNT(E.ID)
    1734
    7 sec!!!!!!!!!!!!!!
    Why does one of them (with LIKE) goes much faster than the other?

    FYI - you might want to check the documentation on when wildcards are needed for CONTAINS vs. LIKE. From your example I can't tell whether you are looking for a part of a term (where a wildcard would be appropriate for CONTAINS), or if you are going to look for a term within a string (no wildcard needed for CONTAINS, but one is required for LIKE).
    Example - Assuming a string value of HELLO WORLD
    select count(e.id) from um2_entries e , um2_entries_attrs a where e.id = a.entry_id
    and a.name = 'user.name'
    and a.string_value like 'Hello';
    ** No record found - case-sensitive and partial string
    select count(e.id) from um2_entries e , um2_entries_attrs a where e.id = a.entry_id
    and a.name = 'user.name'
    and a.string_value like 'HELLO';
    ** No record found - Partial string
    select count(e.id) from um2_entries e , um2_entries_attrs a where e.id = a.entry_id
    and a.name = 'user.name'
    and a.string_value like 'HELLO%';
    ** Record found
    select count(e.id) from um2_entries e , um2_entries_attrs a where e.id = a.entry_id
    and a.name = 'user.name'
    and CONTAINS(a.string_value, 'Hello') > 0;
    ** Record found - Oracle Text is case-insensitive
    ** by default, so mixed-case here doesn't matter. Also,
    ** the search is against the DR$ tables where
    ** HELLO is a token. No need for a wildcard.
    I just wanted to make the differences between these two searches at least partially clear. Your earlier comparison seemed to indicate that you expected no difference regardless of search criteria and that just isn't the case. Some of the reasons for using wildcard or string functions are not valid when Oracle Text is used. That's one reason it is very usefull. Add stemming, fuzzy search, or a thesaurus and you go FAR beyond LIKE.
    Please do reference the CONTAINS sections in the online docs if you have more questions on these differences. They go far beyond where I just did.
    -Ron

  • Asking Again: Group Description Updated in Admin UI is not reflected in PowerShell and vice versa

    I've updated the Groups Description (About Me) using the GUI / Website.  Then running a script to output the Group's Description like:
    $siteUrl = "site url"
    $web = Get-SPWeb $siteUrl
    $web.SiteGroups
    $web.Dispose()
    The description doesn't change.  I can then update the Description of the group using PowerShell and close the window then and run the above code the changes are reflected.  However, the GUI / Website doesn't have the changes.  Very odd!
    raym

    Hi raym,
    Does this still work for you?
    I am rapidly losing my mind over this...
    Is there anything that you left out or perhaps assumed that Noobs (like myself) would already know or have considered? ;)
    I have tried about ten different solutions and Nothing works.
    All I get is plain text.
    Set
    Group Description to HTML via PS Script (This will explain what I have - from my original request of the same)
    Please!! If anyone can shed some light on this before I scrap SP altogether and revert back to DOS. It is the Only thing of Microsoft that actually worked. Oh! and AOE2!! ;)
    TIA,
    Neil

  • Differnce Between Webservice and Container

    I am geting confusion on the difference of Webservice and Container...
    Can you please give some function of each that can differentiate both separately?
    Is container reside in Webservice ...??

    Sorry the question is Diff Bet Webserver and Container...

  • I have hp compaq nw9440 mobile workstation the white screen appear and contain an error

    i have hp compaq nw9440 mobile workstation the white screen appear and contain an error:
    uoy computer has suffered from a non - recoverable system error please call our support line for assistance
    713-634-2494

    sneakypete1 a écrit:
    I use Photoshop Elements 12 for my photos.  I have a constant problem where my photos don't print like they appear on the screen.  They come out darker than the screen shows.  If brighten them in the program, I have to almost make the photo appear "white" in order to look good printed.   ??????  What can I do to fix this problem??
    I am ready to bet that your display is much, much too bright (like all displays at factory settings.
    Why Are My Prints Too Dark

  • Windows Powershell and HP Open Test Architect (TDApiOle80)

    I'm not sure that this is the correct forum to place this in. Please feel free to move it if needed...
    I have a task to create a new script using powershell and the OTA. When trying to log into quality center via the open test architecture in powershell I get this error. 
    At my computer char:22+ $td.InitConnectionEx $qualityCenterLink+ ~~~~~~~~~~~~~~~~Unexpected token '$qualityCenterLink' in expression or statement.
    At my computer char:11+ $td.Login $qualityCenterUsername, $qualityCenterPassword+
          ~~~~~~~~~~~~~~~~~~~~~~
    This is the code that I am using.
    $td = New-Object -ComObject "TDApiOle80.TDConnection"
    $td.InitConnectionEx $qualityCenterLink
    $td.Login $qualityCenterUsername, $qualityCenterPassword
    This code currently works in a script written with VBscript. I am just modifying the td variable to use powershell instead of vbscript. Do you all have any idea what it is that is causing this not to run? Also, Is powershell compatible with the OTA? I am assuming
    so only because the OTA is a COM package.

    it appears it doesn't like the formatting. It doesn't know how to handle the varibles
    Powershell thinks thinks these are 2 variable next to each other
    $td.InitConnectionEx $qualityCenterLinkmaybe put $td.InitConnectionEx($qualityCenterLink)$td.Login $qualityCenterUsername, $qualityCenterPasswordPowershell thinks thinks these are variable next to each other, with a comma separating two of themmaybe put $td.Login ($qualityCenterUsername, $qualityPasswrod)Maybe you can do $td | get-member, may that will show you how the arguments should look. I have neverused the OTA, just guessing here.

Maybe you are looking for

  • How can I center text in a JTextArea?

    I'm coding my own little font selection frame, and want to display the sample text in a JTextArea, and want to know how I can get the text centered in the field. Does anyone know how this can be done? Thanks.

  • How to create ios environment with adobe id?

    Hi , i am trying to create ios environment in windows platform. can any one please tell me, how to create IOS environment with adobe id. I a created adobe id and inserted code into it. But its running (Since one hour), and no response. Any one have i

  • "Error in the dac kernel system" Error

    I hope someone can help! I have Diadem 10.2 logging external signals through a can card, which was working perfectly last week, but now if I try and get some data, it throws a message: Error in the DAC kernel system Unable to lock a memory space. (Er

  • The status of ORASSO.WWSSO_LS_PRIVATE is invalid

    Hi all, the status of orasso.wwsso_ls_private is invalid. The user can't logout from portal. When I click on Logout-link the get the error: Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance do

  • Adobe flash player has stopped working how to rectify please help

    adobe flash player has stopped working how to rectify please help