Trim title off of string using the replace command

Below is a simple task to read in data from a text file to use in account creation.
Get-Content employee.txt |
ForEach{
    $ID = ($_ -split ';')[0]
    $fname = ($_ -split ';')[1]
    $lname = ($_ -split ';')[2]
A problem that has came up which I did not anticipate was titles.  Titles such as MBA etc. throw off the creation of the account. I have a title like this myself an understand why someone is proud to append it to the last of their name because
they worked very hard to get it.  In this case I need to trim it off to create the account. Below is an example of a data file
1234;test;user, MBA;
4567;test;user2 MBA;
8901;test;user3;
Thought this would be an easy fix and here is how I attempted to correct it below
$lname = $string
$string -replace ",*" -replace " "
$string
My thought was a comma or a space could be used to divide the last name the same as I divided the individual fields in the text file with a semicolon. Is there an easy method to do this? The replace seems easy enough but the problem is I'm not familiar with
the syntax in powershell.

RegEx is an excellent tool but itt tkes a programmers mind to understand its subtleties.  It is a good excercize in declaritive thinking and in recursive parsing systems.  Once understood the lesson is transferrrable.
I do not recomment it to new scripters.  After you gains some mastery of a scripting system then RegEx becomes nmuch easier to understand.  I am not a RegEx wizard although I have used it since before it had a name.  It was part of all editors
before we had PCs.  VI and HPs EDIT,  MsEDIT and others.  EDLIN uses a primitive form of RegEx from the minicomputer era.  Of course EDLIN is no more.
¯\_(ツ)_/¯
I wouldn't necessarily call myself a new scripter, been doing it a few months now and whilst there is definitely a lot more i could learn, i find that when i need to accomplish something i figure it out eventually, it's how i learn best! It does leave me short
of tips and tricks you'd find in the early chapters of a book though!

Similar Messages

  • TS4062 On my Iphone I have 1-Camera roll, two Photo Libraries, and 1 delete.  I cannot get rid of the Photo albums off the phone.  I cannot take things off my Iphone using the itunes because it doesn't pull the Iphone up.

    On my Iphone I have 1-Camera roll, two Photo Libraries, and 1 delete.  I cannot get rid of the Photo albums off the phone.  I cannot take things off my Iphone using the itunes because it doesn't pull the Iphone up.

    Pat2006 wrote:
    I cannot take things off my Iphone using the itunes because it doesn't pull the Iphone up.
    Correct. You don't use iTunes to get photos off the iPhone.
    See this -> http://support.apple.com/kb/HT4083

  • How do I turn off suggested videos using the YouTube widget?

    How do I turn off suggested videos using the YouTube widget?

    That's not currently an option in the Muse youtube widget.
    We'll add support for that option in a future release of Muse.

  • How do I turn off the alt scroll zoom?  When I'm in Adobe photoshop and illustrator using the pen tool, alt is utilized for another short cut.  I would like to use the alt command for the pen tool instead of zooming into the screen.

    How do I turn off the alt scroll zoom? 
    When I'm in Adobe photoshop and illustrator using the pen tool, alt is utilized for another short cut.  I would like to use the alt command for the pen tool instead of zooming into the screen.

    I tend to select things from left to right and every time I am moving in a downward right diagonal motion during lasso selection I am missing a clear view and I am tending to have a more sloppy selection.  All this does is slow me down since I need to go back and hit those areas again.  The big arrowhead just get's in the way.  The original lasso tool with the thin line and small active point at it's lower left was far better for me.
    I don't like turning the cursors to precise because I like to see the active tool icon where my cursor is and as the icon changes as I hold modifier keys down.  If I am forced to get comfortable with using pricise cursors I guess I will, but man, I've never had to do this in my 15 years of photoshop use...
    I would absolutely LOVE to find a way to get the old lasso icon -- without the arrowhead above it.
    Is there any chance this option could be inlcuded in cursor preferences?  I'd give much thanks, Adobe.

  • My iPod shuts off repeatedly when using the Nike running app. Have already tried the headphones solution that Apple has recommended. Can anyone help?

    My iPod shuts off repeatedly when using the Nike running app. Have already tried the headphones solution that Apple has recommended. Can anyone help?

    Using the 5th generation iPod. Purchased it a few months ago before the new one was launched. Yes the workout randomly ends when I am no where near the time or distance I have programmed in. I keep tried to restart the workout and the same thing keeps happening over and over again. I figured it may have been the headphones but I have even tried holding the headphone connection in place, and different headphones as well and it continues to happen.

  • Use the same command

    Hello,
    My VI look like it :
    I would like to re-use the same command in my "while".
    I have several case and I don't want to creat several text command.
    If someone kown a trip please tell me how to do.
    See you,
    Solved!
    Go to Solution.

    That code as written will not work.  You are not making any updates to the string in the loop, therefore you either have a loop that runs once or an endless loop.
    But if you want to reuse code, then make a subVI and call that VI multiple times.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • The problem I have since I upgraded to Mavericks version 10.9.1 The problem appears only with Mail not with other programs, not even with my browser. When I try to zoom the text of an e-mail I received or sent , I can no longer use the keys Command   to e

    the problem I have since I upgraded to Mavericks version 10.9.1
    The problem appears only with Mail not with other programs, not even with my browser.
    When I try to zoom the text of an e-mail I received or sent , I can no longer use the keys Command + to enlarge the text, although I can reduce it with Command -.
    As I have a problem with my eyes, This is a serious matter for me.
    When I write an e-mail, if I select text and press Command +, it just displaces the text to the right.
    Now, my husband has a USB keyboard. If he connects it to my computer, his regular Command + does not work either, but  he uses the extended keyboard, then it works. Unfortunately, he needs it for a musical application which does not work with a wireless keyboard.

    Firefox 3.6.4 and 3.6.6 use a process called, "plugin-container.exe" which was using up most of my CPU when I opened up multiple tabs that contained Adobe Flash files, and caused Firefox to lock up.
    My solution was to use Firefox 3.5.10 which you can get from the Mozilla website at [http://www.mozilla.com/en-US/firefox/all-older.html]
    I am using Adobe Flash 10.1.53.64 without any problem in this version of Firefox. Check the release notes, I believe it contains all the latest security fixes in "Firefox 3.6.4".
    Hopefully, they will fix Firefox 3.6 in the next version (e.g. Firefox 3.6.7), until then you should probably use "Firefox 3.5.10".

  • Saving a pdf file using the print command

    I'm having a problem saving a document to pdf using the print command. I'm using an old version of Adobe. it's Adobe Acrobat 6. it is giving me the following error The instruction at "0x775355b2" referenced memory at "0x775355b2". The memory could not be "read". Could someone please help me resolve this issue. Thank you.

    The OS and release version of the source file's authoring application have a significant impact on use of Acrobat 6.
    For example, Acrobat 8.1 is where Vista support begins.
    With MS Office, Acrobat 6 PDFMaker compatiblility is only for Office 97, 2000, XP, and 2003.
    Be well...

  • Export to PDF - Can a single report (rpt file) create multiple PDF files using the export command?

    Post Author: markeyjd2
    CA Forum: Exporting
    Greetings forum members,
    My question is, in its entirety: Can a single report (rpt file) create multiple PDF files using the export command, ideally one PDF file per DB record?
    In my case; I have a Crystal Report that reads data from a DB table containing ~ 500 records.  When I export the report to a PDF file, I get one PDF file, with ~ 500 pages.
    What I would like to do is export the report to ~ 500 individual PDF files; One file per DB record.  The file names would be based on the table's primary key.
    Is this possible?

    Post Author: Micha
    CA Forum: Exporting
    Hi,
    you need some lines of code, but its easy. Dependend on how to start the generation of your 500 PDFs, you can write an ASP page and start it via Web Browser, or a Windows Script and start it via scheduled job...
    Here's an abstract of the ASP code I use:
    First, you create a recordset (here: "rsc") which gives you the list of ID fields you want to export, then you create CrystalRuntime.Application object, then you loop through the recordset, open your report (here: "oRpt") and set login info. Then set the selectionformula, so that the report displays only the data of the current ID, e.g.:
      oRpt.RecordSelectionFormula = "(" & oRpt.RecordSelectionFormula & ") AND {myTab.myVal}=" & rsc("myVal")
    Then you export the report, move to the next record in recordset, and repeat the loop until recordset.EOF. Then you close recordset and connection.
    Micha

  • Do we need a ODI agent to be running for using the startscen command

    Do we need a ODI full installation(both server and client) for using the Startscen command or just the client install should be enough. And also do we need a ODI agent to be configured and running for using this StartScen command
    Thanks

    ODI client is an agent.
    So you don't need to declare one more if not needed on your infrastructure.
    But to run odistartscen you need to configure the odiparams.bat with your repository connexion.
    If not it will try to connect by default to the demo repostory on HSQL.
    best regards,
    Brice

  • I am fairly new to MacBook. I want to copy a picture from a web site to Word and i can't select it using the usual command. What am I doing wrong? With windows it was very simple

    Why can't a copy a picture from the web in MS word using the available commands?

    Ask Microsoft by posting in their forums.  Not an Apple product.
    Microsoft for Mac Support

  • LR V1.2 Having problems using the find Command

    Have just recently started using lightroom and so far managing most applications imported a series of photos and after import added keywords to them using the find function I cannot get images to appear. What seems to happen is that in the keyword tag and the folders any of the headings that contain the keyword become active the remainder show a zero no in number of images held in that folder but no images on screen
    can anyone assist me
    Peter

    thanks for the reply
    have switched of global filters, made sure that using the Find command have set keywords in "text box" and in the "rule box "contains". When I then enter a key word as soon as a type the first two or three letters
    a message appears on the screen no "No photos in the selected keyword Tag" Also when you look at the folders which have a series of numbers indicating the photos in the directory the first number in each set turns to 0 with the exception of the folder and sub folder were the images are
    So have not managed to make any progress
    Peter

  • What are the advantages/disadvantages of using the Form Command over Creating a User Form in VBA?

    I’m in the early stages of creating a spreadsheet that will require data entry into the worksheet. The worksheet could get to 1000s of rows, depending on the particular user.
    When I refer to the ‘Form Command’ I’m referring to the option of adding a Quick Access Tool bar button by selecting ‘more commands’, ‘all commands’, ‘Form…’
    My questions/concerns would be relating to ‘should I develop this spreadsheet with the Form Command or a User Form in VBA?
    Concerns/Questions:
    Deployment to other users
    Protecting worksheet cells so the user can only add records using the form command or the user form in vba. In other words, don’t allow users to edit cells that are not within the table structure of the sheet or add rows if they’re not using the form
    Data validation when entering data…
    Keith
    Keith Aul

    Hi,
    Both variants have pro's and cons. If you plan to use VBA you have to consider the deployment settings on other p.c.'s where you have to allow macro's where as a regular form doesn't have the need for that.
    That said the userform gives you much more control because the form command is not saved. it is simply a temporary form which you have to setup every time. It's perfect for data entry. If you are looking for data validation the userform is the one to go
    for. You also have the possibility to work on placements of the data entry.
    So if you are looking for speed and simplicity then go for the form command. If it is handling control you are after I'd go for a userform.
    Just my 2 cts
    Maurice
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer. Thank You

  • Suddenly with version 9 and 10 i cant use the shortcut command of ctrl+shift+t to open the most recently closed tab.

    Suddenly with version 9 and 10 i cant use the shortcut command of ctrl+shift+t to open the most recently closed tab. a feature used several times a day, previously. This is very Frustrating to me, i have tried looking up a tool keyconfig 20110522 and looked that it says that ctrl+shift+t is the right command, but i still cant use it WHY oh WHY?? if i could get some help figuring this out it would be so awesome, cause i love Firefox, been using it almost daily for the last 10 or so years and i don't intend to switch soon.

    Hi,
    Please check if this happens in [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode.] This is a temporary diagnostic session and you can exit anytime and start Firefox normally again. This session disables all the '''Extensions''', themes ('''Appearance''') and '''Plugins''' in '''Tools''' ('''Alt''' + '''T''') > '''Add-ons'''.
    [http://kb.mozillazine.org/Problematic_extensions Problematic Extensions]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes Troubleshooting Extensions and Themes]
    [http://support.mozilla.com/en-US/kb/Uninstalling+add-ons Uninstalling Add-ons]
    [http://kb.mozillazine.org/Uninstalling_toolbars Uninstalling Toolbars]

  • Terminal does something strange when I use the 'say' command

    Hello,
    I use terminal frequently and have just nocticed something odd. When ever I use the 'say' command it said this:
               -                 -iMac:~                  $ say hello
    objc[1281]: Object 0x7ffcc2b1ee60 of class NSRunningApplication autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
    It doesn't really bother me, but I just want to make sure it is nothing serious
    - Thanks

    Could you describe this in more detail: did Firefox prevoiusly split the image over two pages and now it no longer does that?
    Or is the problem that there are two images, and if they do not both fit on the first page, Firefox is not printing the second page?
    Some page layouts may not print well when split across pages; there are some longstanding Firefox bugs. If this just started recently, those might not be relevant...
    Could you give an example URL of a page that has this problem, and indicate where the cutover is between scale percentages that work and those that no longer work?

Maybe you are looking for

  • Application lost existing session due to new jsession id.

    Hi Team, We have three linux box in production and each box contains apache and weblogic managed server. IP and apache port is configured in our ACE load balancer. -----A1---M1 | ACE- --|-----A2---M2 | -----A3---M3 A1,A2,A3-Apache servers, M1,M2,M3 -

  • Adobe Reader XI install problem

    I have tried to install Adobe Reader XI on a computer, however, on shortly after the install starts I receive the error: "Setup was interrupted before Adobe Reader XI could be completely installed. Error code 150208" Anyone know more details on the e

  • Appleworks "textedit" won't load

    When I click on the Appleworks 6 to activate the textedit feature- word processing- it will no longer open. "Application has unexpectedly quit" message appears. Two or three weeks ago I did a software upgrade. It didn't say it would effect appleworks

  • How to set value for table lines in web dynpro ?

    Hi experts, I'm new in webdynpro. My requirement is to set value to the second line when user press expand on first line. In method ONACTIONLOAD_CHILDREN , I use  get_static_attributes_table to get the current table records and change return table va

  • HT4759 cannot load email in iCloud

    Hello I hope you can help. I am having difficulty loading my email - both on the iMac and directly by Safari - Using Safari I am able to log into my iCloud account and view addresses, location etc, but when I try to acces my email it "does not load".