Import-csv how to make powershell ignore a line in a csv file if a column contains a certain value

Basically I got a very basic script that uses a csv file to input values needed to remove people from a distro list. That part is working fine. I'd like to add to it's functionality so it can look at values in a certain column, and if any of those certain
values are present, I want powershell to skip that line and not process it. For instance I have a column in the csv called Group. If I have a listing under Group that says ABC I want the script to skip that line and not try to process it. What could I insert
into the script to acheive this?

You're welcome. You can add to the if test with -and:
Import-Csv .\groups.csv | ForEach {
If ($_.Group -ne 'ABC' -and $_.Group -ne 'DEF') {
Write-Output "Group is $($_.Group)"
Write-Output "Name is $($_.Name)"
Output:
Group is GHI
Name is Show Me
groups.csv:
Group,Name
ABC,Skip Me
DEF,Skip Me Too
GHI, Show Me
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing)

Similar Messages

  • How to make a appointment on line

    I have a problem on the screen on ipad, how to make a appointment on line for fixing it ? Could you show me the link ?

    Used the Pen tool, but click on the correct icon on the top left on the Options Bar. That way you can get a Path instead of a Shape Layer.
    Once you have your Path you can stroke it with a Brush or any drawing tool. Various options appear in the Brushes palette. For a dotted line you will need to increase the spacing. If you want dashes, use a square brush and set the Angle Jitter to Direction.

  • How to make reports on FI Line items

    Hi all,
    Let me know  how to make reports on FI Line items especially drill down reports. suggest me steps for developing reports through Bex query designer. Am new in reporting on FI. How to make the drilldown reports. Plz let me know step by step.
    Thanks,
    Jack

    Hi
    Follw the steps
    Step1
    Lets take an example of ODS Accounts Payable: Line Items  Technical Name: 0FIAP_O03
    install all this 0FIAP_O03  ODS from the Business content.
    For more details on FI Line item ODS
    http://help.sap.com/saphelp_nw04/helpdata/EN/af/16533bbb15b762e10000000a114084/frameset.htm
    Step2
    After installing make sure that all the infoobjects and transfer rules and update rules are in active state
    Step3
    Now type the transaction code RRMX , you will get into the query designer
    Step4
    Select the Infoprovider from the above example 0FIAP_O03 . now you will arrive to the screen where you can see Rows and colums
    Step5
    Drag and drop the  characteristic infoobject in to the row which is necesseayfor the report output
    Step6
    Drag and drop the  Keyfigure infoobject into the column which is necesseayfor the report output
    Step7
    Now under Free characteristics draga and drop the charactor infoobject which you need to navigate in the reporting.
    Note: Before dragging the objects in the freecharacteristic make sure that you need to check the navigation in the ODS level
    Step8
    Now save the report , when you save give the technical name of the report and save
    now execute the report
    Santosh
    Edited by: Santhosh Nagaraj on Nov 15, 2009 1:35 AM

  • How to make a curve dotted line

    Hi there,
    Since now 2 days I am trying to figure out how to make a curve dotted line with photoshop CS3 on WinXP. I know how to make a strait line using the line tool.
    Now, how to make a curve line ? I tried the pen tool, but it ended up with a filled shape rather than with a curve line
    How to set the thickness of this curve ?
    How to make a dotted curve ?
    Of course, I don't want to use hand-drawings with the brush.
    Thanks a lot for your help,
    Alex_pier

    Used the Pen tool, but click on the correct icon on the top left on the Options Bar. That way you can get a Path instead of a Shape Layer.
    Once you have your Path you can stroke it with a Brush or any drawing tool. Various options appear in the Brushes palette. For a dotted line you will need to increase the spacing. If you want dashes, use a square brush and set the Angle Jitter to Direction.

  • How to make CUCM as a TFTP server , then copy files to Voice Gateway ?

    how to make CUCM as a TFTP server , then copy files to Voice Gateway ? anyone knows?

    Hi,
    Please check the following link
    http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cucm/admin/6_1_1/ccmsys/cucm-accm-611/a02tftp.html#wp1023004
    Understanding How Devices Access the TFTP Server
    You can enable the IP phones and gateways to discover the TFTP server IP address in one or more of the following ways, depending on the device type:
    •Gateways and phones can use DHCP custom option 150.
    Cisco recommends this method. With this method, you configure the TFTP server IP address as the option value.
    •Gateways and phones can use DHCP option 066.
    You may configure either the host name or IP address of the TFTP server as the option value.
    •Gateways and phones can query CiscoCM1.
    Ensure the Domain Name System (DNS) can resolve this name to the IP address of the TFTP server. Cisco does not recommend this option because it does not scale.
    •You can configure phones with the IP address of the TFTP server. If DHCP is enabled on the phone, you can still configure an alternate TFTP server IP address locally on the phone that will override the TFTP address that was obtained through DHCP.
    •Gateways and phones also accept the DHCP Optional Server Name (sname) parameter.
    •The phone or gateway can use the value of Next-Server in the boot processes (siaddr).
    Devices save the TFTP server address in nonvolatile memory. If one of the preceding methods was available at least once, but is not currently available, the device uses the address that is saved in memory.
    You can configure the TFTP service on the first node or a subsequent node, but usually you should configure it on the first node. For small systems, the TFTP server can coexist with a Cisco Unified Communications Manager on the same server.
    HTH
    Manish

  • How to make powershell script.

    How to make script that copy content from notepad to other notepad and reverse the text?

    If you mean a .txt file then there's three aspects to your question.
    Open a file and read the text
    Reverse the text
    Save the text into a new file
    For point one, this technet article is good:
    http://technet.microsoft.com/en-us/library/ee692806.aspx
    For point two you could turn the text into one or more strings, then convert those into arrays, loop through them and then re-assemble them. This article shows you most of that:
    http://technet.microsoft.com/en-us/library/ee692804.aspx
    And finally you need to save that text as a file, there's lots of ways but the Out-File cmdlet is the simplest.
    This might also be of use:
    http://www.ehow.com/how_7174023_write-basic-powershell-script.html

  • How to make iTunes detect the new location of music files?

    Hi everyone. I moved all of my music to a different location on my hard drive, and I changed the location in iTunes preferences, but it doesn't seem to detect this, so my library is empty now. I saved an itl, xml, and temp file as well, but I don't know what to do from here.
    I also tried dragging the new music folder onto the "Library" entry in iTunes, and this added everything, but I no longer have my ratings, playlists or anything like that.
    Is there some other way to have iTunes detect the new location? And can I get back my ratings and playlists?
    Thanks.

    iTunes doesn't use file names to determine how music appears in your library,  Rather, it uses metadata that is split between:
    data elements that are embedded within the media files
    data elements that are included in the entries in the iTunes database
    No amount of reorganization, renaming or other manipulation at the file level will make any difference to how songs will appear in iTunes.  Using your example:
    the value of the track number element is 1
    the value of the artist element is "Elvis Presley"
    the value of the song name element is "Blue Suede Shoes"
    Depending on how you configure iTunes then the file name is either:
    completely independent of iTunes (i.,e., the file containing this song could be xyz.mp3)
    dependent on the metadata managed by iTunes, (i.e., when you have these two options set:
    then iTunes will set the file name to be 1-01 Blue Suede Shoes.mp3 where:
    the file is in a folder called "Elvis Presley" (the name of the album)
    that folder is in one called "Elvis Presley" (the name of the artist) which is in iTunes Media\Music
    Going back to your question "How to make iTunes read the song's name/singer from the file's name" the answer is simple - you can't, as this is not how iTunes works.  There are some third-party utilities that you can use to set some metadata element values based on parsing of file names which might be a useful first step.  However, to use iTunes effectively you should really forget about / ignore file names - manage your media using appropriate metadata and allow iTunes to look after file names behind the scenes.

  • How to make a stationery out of .doc or .docx file?

    Hi,
    I stumbled upon a website that has some nice stationery, in .doc format. and since there few free pre made stationery available for Mail.app, at least to my knowledge, because I think I almost downloaded every free stationery available out there that could be easily found via Google. I decided to download some of these .doc stationeries and try to put them in Mail.app, but first I had to convert them into .html format. so here is what I've already tried and did not work:
    first I tried opening them in TextEdit, which supports .doc out of the box, only to find out that the pictures in the documents are gone to thin air. I tried saving it and then opening it with something else like Open Office, but the pictures were permanently gone.
    then I tried opening the original documents directly in Open Office, you guessed right If you said they will look screwed, and they were, and tried to save them as html, they were screwed even more.
    so I did a bit of research and found out that I could use Google Docs in order to convert the documents, I uploaded them into my Google docs and then tried to open them with it, but found it that Google docs can't handle the pictures (specially background pictures) either. as a result I did more searching to find a document converter and here is what I found:
    I found a few online service to convert these documents:
    http://www.freefileconvert.com/ was pretty good to convert the files into an .odt format. at first I thought yes I got the solution, now I can simply convert it to html using Open Office, but unfortunately, when I saved the document in html format and checked it in Safari to see how does it look, as If I would have done the same in MS Office with the original format, it looked pretty much screwed .
    So I continued to look and I found a few other online services one of them asked me to pay a fee, I skipped to the other one which was http://docx-converter.com/. unfortunately the website wasn't functioning properly I think, at least for me (maybe someone out there has succeeded using it, I don't know.) and it didn't send me anything.
    Finally I found http://www.zamzar.com/ that could convert .doc or .docx documents into html, or at least that is what it claims to do so, I tried it, and after I received the file via email, I found out it only contains a bmp image of the document's background. So much for the online conversion services!
    But I decided I would give it a last shot using MS Office online, so I opened up my old Windows Live mail and went into my Skydrive, I uploaded the documents and tried saving it as html, but there were no save as html (after all an online copy of MS Office should have some limitations, otherwise few people will be willing to buy a Desktop version) but this didn't made me disappointed, since I already knew, that Neither Office Word can make a clear conversion, so I tried something different, while I was in Safari looking at the document in online MS office, I saved the page as Web Archives, then I opened the file with TextEdit, and after deleting useless links and pictures, I finally managed to get a clear document with everything that supposed to be in it. At this point I only need to know how to make use of this document to create a stationery with this raw file which is in Web Archive format. any ideas?
    null

    I'm a total idiot! How did I overlook http://www.zamzar.com/ functions? I think I might have mistakenly chosen convert to BMP instead of html. I tried it and the result was very good.
    OK I finally found a good solution for this problem, so everyone out there that has the same problem, here is what I did:
    1. OK if you have some .doc and .docx file formats and you want to convert them into something like .html or .odt, without having to reedit the code or getting a screwed document, use http://www.freefileconvert.com/ in order to convert them into .odt so they would look as they do in MS office just go to the website and upload your documents then choose .odt, then click convert, after a few moments you will get a link to download your .odt files. you can use and play around with your document in Open Office, I have tested it and it's really good.
    2. Or if you want to convert them into .html with a clean code, and all the elements in it, simply go to http://www.zamzar.com/ and then ulpoad your documents, choose .html and enter your email address, you will have your .html files zipped and sent right in your inbox, then you could use Kompozer like me, or any other html editor, to make a template out of it. I tried it and the result was nice, now I have a bunch of nice html files that I can use to make templates and email stationery.

  • How to make a slowly apearing line

    Hi there guys,
         Im having a problem with making 1 animation. I want to make a slowly appearing line. The scene is a pencil drawing a line.. so as the pen end moves a line is slowly appearing, i couldnt get the tecnique on doin this, can anyone give me an idea?
    thanks in advance

    I would take either the mask or the blocking approach for that.  Below is an image showing how I did it using the blocking approach.  You can maybe see the curved blocker piece that I gradually slide off the stage as the pencil moves along (it's white so you can't see it on the white stage).  The straight lines you see were done just extending their length with timeline tweens on layers above the curved lines.  You basically have to get a little creative with the way you reveal things gradually--often working piece by piece for more intricate line drawings.

  • How can i read all the lines from a text file in specific places and use the data ?

    string[] lines = File.ReadAllLines(@"c:\wmiclasses\wmiclasses1.txt");
    for (int i = 0; i < lines.Length; i++)
    if (lines[i].StartsWith("ComboBox"))
    And this is how the text file content look like:
    ComboBox Name cmbxOption
    Classes Win32_1394Controller
    Classes Win32_1394ControllerDevice
    ComboBox Name cmbxStorage
    Classes Win32_LogicalFileSecuritySetting
    Classes Win32_TapeDrive
    What i need to do is some things:
    1. Each time the line start with ComboBox then to get only the ComboBox name from the line for example cmbxOption.
       Since i have already this ComboBoxes in my form1 designer i need to identify where the cmbxOption start and end and when the next ComboBox start cmbxStorage.
    2. To get all the lines of the current ComboBox for example this lines belong to cmbxOption:
    Classes Win32_1394Controller
    Classes Win32_1394ControllerDevice
    3. To create from each line a Key and Value for example from the line:
    Classes Win32_1394Controller
    Then the key will be Win32_1394Controller and the value will be only 1394Controller
    Then the second line key Win32_1394ControllerDevice and value only 1394ControllerDevice
    4. To add to the correct belonging ComboBox only the value 1394Controller.
    5. To make that when i select in the ComboBox for example in cmbxOption the item 1394Controller it will act like i selected Win32_1394Controller.
    For example in this event:
    private void cmbxOption_SelectedIndexChanged(object sender, EventArgs e)
    InsertInfo(cmbxOption.SelectedItem.ToString(), ref lstDisplayHardware, chkHardware.Checked);
    In need that the SelectedItem will be Win32_1394Controller but the user will see in the cmbxOption only 1394Controller without the Win32_
    This is the start of the method InsertInfo
    private void InsertInfo(string Key, ref ListView lst, bool DontInsertNull)
    That's why i need that the Key will be Win32_1394Controller but i want that the user will see in the ComboBox only 1394Controller without the Win32_

    Hello,
    Here is a running start on getting specific lines in the case lines starting with ComboBox. I took your data and placed it into a text file named TextFile1.txt in the bin\debug folder. Code below was done in
    a console app.
    using System;
    using System.IO;
    using System.Linq;
    namespace ConsoleApplication1
    internal class Program
    private static void Main(string[] args)
    var result =
    from T in File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TextFile1.txt"))
    .Select((line, index) => new { Line = line, Index = index })
    .Where((s) => s.Line.StartsWith("ComboBox"))
    select T
    ).ToList();
    if (result.Count > 0)
    foreach (var item in result)
    Console.WriteLine("Line: {0} Data: {1}", item.Index, item.Line);
    Console.ReadLine();
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions.

  • How to write on a new line ("\n") to a file

    I dont know how to write on a new line ... this method writes everything in long line. I tried doing pS.println("\n") before the pS.println(buffer.toString());
    Some one please direct me :)
    public void WriteToFile() {
         try {
              byte[] record = new byte[100];
              ByteArrayInputStream iS = new ByteArrayInputStream(record);
             DataInputStream iDS = new DataInputStream(iS);
              StringBuffer buffer = new StringBuffer();
              OutputConnection connection = (OutputConnection)
                                          Connector.open("file:///CFCard/readme.txt");
              OutputStream oS = connection.openOutputStream();
              PrintStream pS = new PrintStream( oS );          
              try {
               for(int x=1; x<=rs.getNumRecords();x++) {
               rs.getRecord(x, record, 0);                                                                                               
                  buffer.append(iDS.readUTF());                          
                  buffer.append(iDS.readUTF());              
                  buffer.append(iDS.readInt());              
                  buffer.append(iDS.readInt());              
                  buffer.append("\n");
                  pS.println("\n");
                  pS.println(buffer.toString());                                          
                 iS.reset();                   
              oS.close();
              connection.close();
             iS.close();
             iDS.close();        
              catch(ConnectionNotFoundException err) {
                   Alert alert = new Alert("Error", "Cannot access file.", null, null);
                 alert.setTimeout(Alert.FOREVER);
                 alert.setType(AlertType.ERROR);
                 display.setCurrent(alert);     
              catch(IOException err) {
              Alert alert = new Alert("Error", err.toString(), null, null);
            alert.setTimeout(Alert.FOREVER);
            alert.setType(AlertType.ERROR);
            display.setCurrent(alert);     
              Alert alr = new Alert("Completed Sending to a File", "Data written successfully!",null,null);
              alr.setTimeout(Alert.FOREVER);
              alr.setType(AlertType.WARNING);
              display.setCurrent(alr);
              }catch(Exception err) {
    }

    Stinkin' crossposter
    http://forum.java.sun.com/thread.jspa?threadID=613784

  • How to only read the last line in the text file by using BufferedReader ?

    Dear all,
    Hello, I am new to Java. Do anybody know how to read the last line (this is the last record) in the text file.The method I am now using is reading from the first line until I reach the last line in the text file. Thank you!!
    BufferedReader br = new BufferedReader(new FileReader("c:\\sdk1.4.1\\bin\\dbExport.txt"));
    DataInputStream in = new DataInputStream(new FileInputStream("c:\\sdk1.4.1\\bin\\dbExport.txt"));
    String input;
    String firstinput;
    String secondinput;
    int count=90;
    int year=1955;
    while ((input = br.readLine()) != null) {
    firstinput = input.substring(0, 10);
    secondinput = input.substring(10);
    String insertStore1 = ("INSERT INTO AUTHORS " +
    "VALUES ('" + count + "', '" + firstinput + "', '" + secondinput + "', 1955)");
    System.out.println(insertStore1);
    int result = stmt.executeUpdate(insertStore1);

    I suppose you could use a java.io.RandomAccessFile.

  • How to get rows where a varchar column contain pure numeric value

    hi,
    i have to make a query from a table that return only the rows where the occurrences of a string column contain a pure numeric value
    for example my table MYTABLE have the column COL1 varchar2(100)
    with values
    row 1 : '100'
    row 2 : '101 dalmatiens'
    row 3 : '102'
    row 4 : 'anything'
    i want to get only the rows 1 and 3 which are pure integer so i can sort and compare them like number.
    thanks

    SQL> with rt as   
      2  (select '100' str from dual union all 
      3  select '101 dalmatiens' from dual union all 
      4  select '102' from dual union all
      5  select '103 #$&''() 456' from dual union all
      6  select 'anything' from dual)
      7  /* End of sample data (rt) */
      8  select str
      9         ,trim(translate(str,'1234567890'||str,'1234567890')) num
    10  from rt
    11  where trim(translate(str,'1234567890'||str,'1234567890')) is not null;
    STR            NUM
    100            100
    101 dalmatiens 101
    102            102
    103 #$&'() 456 103456
    -- Oooooops, I misread and now have corrected it
    SQL> with rt as   
      2  (select '100' str from dual union all 
      3  select '101 dalmatiens' from dual union all 
      4  select '102' from dual union all
      5  select '103 #$&''() 456' from dual union all
      6  select 'anything' from dual)
      7  /* End of sample data (rt) */
      8  select str
      9         ,trim(translate(str,'1234567890'||str,'1234567890')) num
    10  from rt
    11  where trim(translate(str,'1234567890'||str,'1234567890')) = str;
    STR            NUM
    100            100
    102            102Message was edited by:
    ushitaki

  • HT2370 How do I enable/activate/save line commands to host file?

    I'm a newbie to terminal and I am trying to add lines to block a few websites, I successfully used the sudo nano command for the host file but I have no idea how to "save" my modified (added) lines to the file so that it is activated. Help?? I currently running Yosemite.

    Go to Options>Applications tab > search MPEG Layer 3 audio(audio/mpeg) > use "Save File" option on drop down menu.

  • How to make OWB ignore a field that is not mapped.

    Hi,
    We're using OWB 10.1.
    I'm just doing a simple load from a flat file to a regular table.
    I discovered that the data file is missing an entire field or column of data.
    The field is not necessary so I'm continuing the load.
    I just remapped the OWB map so it doesn't not pull data from the last field in the data file.
    When it created the control file to do the load, the last field that was unmapped in the OWB map was re-designated as 'DECIMAL EXTERNAL'.
    Then when the map runs to load the data, I get an error message of
    Record 1: Rejected - Error on table "STAGING"."TCMBBX", column "PAID_AMOUNT".
    Column not found before end of logical record (use TRAILING NULLCOLS)So it looks like OWB is still trying to include the last field in the load for some reason when I had unmapped the field in OWB.
    My question is how can one un-map a field or not map a field in OWB and then have OWB ignore the field when running the load?
    This is regarding removing the map line drawn from a field in the data file to a field in the staging table.
    Thanks!

    Hi,
       Declare a range as :
    ranges : r_hkont for bseg-hkont.
    fill in the values
    r_hkont-sign = 'I'.
    r_hkont-option = 'BT'.
    r_hkont-low = '26000000'.
    r_hkont--high = '2999999'.
    append r_hkont.
    Select sgtxt from bseg into text
    where bseg-hkont in r_hkont.
    Regards,
    Srini.

Maybe you are looking for

  • Connection error in JDBC Adapter

    Hi All, I am using PI 7.1 and created a JDBC Receiver Comm. Channel. When I try to create an External Definition in ESR using the mentioned JDBC Channel, I get the following error: Serialized cause: com.sap.aii.mapping.lookup.LookupException: Connect

  • SWING, STUDIO CREATOR OR WHAT PLEASE

    I am new to development and started on VB where they had a GUI that was easy for me to learn. I was worried when I switched to JAVA, although I enjoy it I was worried about the GUI, until I found Studio Creator. Can you use Studio Creator for program

  • Smart View 'Free-Form' vs Excel Add-In

    The following Sample.Basic retrieve is valid in the Excel Add-In: Actual 100-10 Jan New York 1234 Connecticut 5678 It will retrieve in Smart View, but always converts immediately to this: Actual 100-10 Jan New York 1234 Connecticut 5678 Note that the

  • Looking to make a pdf cover

    I recently created a site about [spammy link removed]. Anyway, I wanted to create an ebook cover for adobe and i was wondering if anyone could help me with this. also is there any place on the website where i could place the cover that you think woul

  • CS6, CC, PE10, or PE12??

    I have several connected questions.  I had both CS6 monthly license and PE12 on my laptop.  My bank stopped  CS6 last June due to possible ID theft.  I restarted in Oct; but, the monthly license renewal did not work and I received errors every time I