Remove the prefix string in powershell

I am getting the users connected to Webservers count with this query
$wf = Get-Counter -ComputerName "WebServerName" -Counter "\web service(_total)\Current Connections"
I am getting the out put as..
webservername\\web service(_total)\current connections : 5
But i want to get out put only Webservername : 5
Please help us ..
Regards,
Phani

Hi,
It seems you have got the answer in the thread which you asked in the Windows PowerShell forum as the link below.
http://social.technet.microsoft.com/Forums/windowsserver/en-US/88a4d5e3-3591-43ac-b20f-ecc915ee004e/remove-the-prefix-string-in-powershell?forum=winserverpowershell#72b8da5c-ee85-483e-a6c4-fefcb44f78f4
Thanks.
Tracy Cai
TechNet Community Support

Similar Messages

  • XSLT mapping to remove namespace prefix

    Hi experts,
    I have one requrement where I need to remove the prefix ns0 from the xml (given below) getting generated in message mapping.
    <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns0:ExecuteRequest xmlns:ns0="http://test/">
    <ns0:_sRequestXML><inteflow>body</inteflow></ns0:_sRequestXML></ns0:ExecuteRequest></soap:Body></soap:Envelope>
    I am usimg the below xslt and it is now adding one ns0 prefix in the tag <inteflow>.
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <ExecuteRequest xmlns="http://test/">
    <_sRequestXML>
    <inteflow>
    <xsl:copy-of select="//inteflow"/>
    </inteflow>
    </_sRequestXML>
    </ExecuteRequest>
    </xsl:template>
    </xsl:stylesheet>
    Result after using xslt.
    <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ExecuteRequest xmlns="http://test/"><_sRequestXML>
    <inteflow xmlns:ns0="http://decisionintellect.com/inteport/"></inteflow></_sRequestXML></ExecuteRequest></soap:Body></soap:Envelope>
    Can you please help. What is wrong in the xslt and how I can get the desired result.
    Thanks & Regards,
    Pratyus Ganguly
    <?

    Hi Pratyus
    XMLAnonymizerBean works fine when I try it with your payload. Here is the config, basically I included the namespace for everything except the ns0.
    Parameter Name
    Parameter Value
    anonymizer.acceptNamespaces
    http://www.w3.org/2001/XMLSchema xsd http://www.w3.org/2001/XMLSchema-instance xsi http://schemas.xmlsoap.org/soap/envelope/ soap
    Before
    After
    Rgds
    Eng Swee

  • Remove "&" charachter from string

    Hi,
    Please inform me how can i remove the & from string.
    i try this but not working.
    SELECT REGEXP_REPLACE(’raise the level of &performance, creativity',’&','') COL1 FROM DUAL;
    Also i want to remove any special character from statement.
    many thanks

    Ayham wrote:
    i try this but not working.
    SELECT REGEXP_REPLACE(’raise the level of &performance, creativity',’&','') COL1 FROM DUAL;Are you getting any error?
    SQL> set define off
    SQL> SELECT REPLACE('raise the level of &performance, creativity','&') COL1
      2  FROM DUAL;
    COL1
    raise the level of performance, creativity>
    Also i want to remove any special character from statement.
    Search the forum..
    Sample:Re: How to find Special Characters in a single query
    Edited by: jeneesh on Sep 17, 2012 12:26 PM

  • Removing the data portion

    Hi ,
    I have a varchar2 field that stores time :
    16:29:00
    08:30:00...
    i want to query this column but after converting it to date and getting only the time portion so i can make some comparisons , but when i issue this query the date part still shows :
    select TO_DATE(ACTION_TIME,'HH24:MI:SS')
    FROM V$EVENTLOGS;i also tried this select TO_DATE(to_char(ACTION_TIME,'HH24:MI:SS'),'HH24:MI:SS')
    FROM V$EVENTLOGS;but it gives:
    ERROR at line 1:
    ORA-01722: invalid number
    Thanks

    Hi,
    oais wrote:
    select TO_DATE(ACTION_TIME,'HH24:MI:SS')
    FROM V$EVENTLOGS;i also tried this select TO_DATE(to_char(ACTION_TIME,'HH24:MI:SS'),'HH24:MI:SS')
    FROM V$EVENTLOGS;but it gives:
    ERROR at line 1:
    ORA-01722: invalid numberPerhaps it really means that.
    If even one of the strings contains something other than a number (e.g. '??:00:00', you will get that error, and no other results.
    To see what rows are not in the correct format, use TRANSLATE.
    SELECT  action_time
    FROM     v$event_logs     -- as others have said, a confusing name
    WHERE     TRANSLATE ( action_time
                , '123456789'
                , '000000000'
                ) != '00:00:00'
    ;you'll get a different error message if the string contains a valid number that does not happen to be a valid hour, minute or second. You might as well check for those errors at the same time:
    SELECT  action_time
    FROM     v$event_logs     -- as others have said, a confusing name
    WHERE     TRANSLATE ( action_time
                , '123456789'
                , '000000000'
                ) != '00:00:00'
    OR     SUBSTR (action_time, 1, 2)     NOT BETWEEN '00' AND '23'
    OR     SUBSTR (action_time, 4, 2)     NOT BETWEEN '00' AND '59'
    OR     SUBSTR (action_time, 7, 2)     NOT BETWEEN '00' AND '59'
    ;You should correct (or remove) the invalid strings from the table, then add a CHECK constraint to make sure the data stays clean.
    Why are you converting the strings to a DATE?
    If you just need to display them, or compare them (e.g., find times between '08:00:00' and '18:00:00') it's better to leave them as strings.
    If you do convert them using TO_DATE, note what Justin said:
    An Oracle date always has a day component and a time component. If you convert the string '16:29:00' to a date, that automatically becomes today (i.e. 18 April 2009) at 16:29:00.I think Justin made a typo, though. If you don't give a day of the month in TO_DATE, it defaults to the 1st of the month, not the current day.
    That is
    TO_DATE ( '16:29:00'
            , 'HH24:MI:SS'
            )returns 01-Apr-2009 16:29:40 when run today (April 18) or any time during April 2009.

  • How to user PowerShell -replace to remove the dreaded em dash from a file name?

    I have a bunch of .msg files in a directory and want to zip them up (to send them to our spam filtering company), but I keep getting errors on file names that contain the em dash (—).  I believe it's (char)0x2014.
    [edited]... the correct syntax is [char]0x2014.
    I wish to eliminate the em dash in the file name but I can't seem to find anything on the web about replacing em dashes.  When I paste '—', PowerShell replaces it with a '-'.
    I found this neat function that does a great job replacing multiple characters within a string.
    http://powershell.com/cs/blogs/tobias/archive/2011/04/28/multiple-text-replacement-challenge.aspx
    I am using the below code for my string replacement.
    Thank you for your help.
    function Replace-Text {
    param(
    [Parameter(Mandatory=$true)]
    $text,
    $replacementlist = "(-,,',,%,,$,,@,,#,,&,,’,"
    Invoke-Expression ('$text' + -join $(
    foreach($e in $replacementlist.Split(',')) {
    '.Replace("{0}","{1}")' -f $e, $(
    [void]$foreach.MoveNext()
    $foreach.Current)
    $path = '<path>'
    Get-ChildItem -Path $path | Rename-Item -NewName {(Replace-Text $_.Name).trim()}

    Here is a simple filter that will strip out all nonprintable chanracters.
    $newname=$file.Name -replace '[^a-zA-Z\.]'
    I just tested it on Win 7 which supports has a Unicode filesystem and it successfullstrips the bad characters.
    We also need to do this on files uploaded to SharePoint and OneDrive.
    The ~ and other similar characters are not allowed in may systems.  You should keep a translation log and tag all renamed files with some obvious tag.
    ¯\_(ツ)_/¯

  • Remove namespace prefix with the XMLAnonymizerBean is possible at SOAP Adap

    Hello,
    I am wondering is it possible Remove namespace prefix with the XMLAnonymizerBean at SOAP Receiver Adaptor?
    Thanks

    Hi Rajiv,
    Pl. go through this blog:
    /people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
    Also if you want to use this at sender side, SOAP adapter will not support. Please check stefans reply in this thread:
    XMLAnonymizerBean doesnt work
    Regards,
    ---Satish

  • How to remove the comma from string

    Hi,
    I Have string like below :
    String some1="123,44.22";
    I want to remove comma from string and final output should be 12244.22.
    public class getOut{
    public static void main(String args[]){
    String some1="123,44.22";
    getChars(int 0,some1.length(),char[] dst,0);
    can somebody in the forum give me idea how to remove comma from the String and
    have a string without comma.
    Thanks
    Jack

    int idx = oldString.indexOf(',');
    if(idx >= 0)   
          newString = oldString.substring(0, idx) + oldString.substring(idx + 1);or for jdk 1.4 and later
    str = str.replaceAll(",", "");

  • How to remove the "int len" of my return string on the DLLS header when building a DLL on LabVIEW 8.5

    Hi all.
    I'm building a DLL on LabVIEW and I choose a string as an output on the terminals connectors.
    But LabVIEW creates another output, the lenght of the return string.
    This is a problem because I have other DLLs and I need them to be compatible.
    How do I remove this length from the header? What is the difference between Pascal String and C string and String Handle Pointer?
    String Handle Pointer removes the length from the header but I don't know the difference between this data types.
    Thanks in advance for the help.
    Daniel Coelho
    Portugal
    Daniel Coelho
    VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
    Controlar - Electronica Industrial e Sistemas, Lda

    Daniel Coelho wrote:
    Hi all.
    I'm building a DLL on LabVIEW and I choose a string as an output on the terminals connectors.
    But LabVIEW creates another output, the lenght of the return string.
    This is a problem because I have other DLLs and I need them to be compatible.
    How do I remove this length from the header? What is the difference between Pascal String and C string and String Handle Pointer?
    String Handle Pointer removes the length from the header but I don't know the difference between this data types.
    Thanks in advance for the help.
    Daniel Coelho
    Portugal
    C string pointer is a pointer to a memory location whose string information is terminated by a 0 byte. Pascal String Pointer is a pointer to a memory location where the first byte specifies the number of bytes to follow. This obviously allows only for strings up to 255 character length.
    LabVIEW String Handle is a pointer to a pointer to a memory location where the first 4 bytes are an int32 value indicating the number of characters to follow. You can read such a String handle in a function without many problems, but you can only create, resize and delete such a handle by using LabVIEW memory manager functions. So this makes only sense if the caller of such a DLL is LabVIEW too as another caller would have to go through several hoops and tricks in order to gain access to the correct LabVIEW kernel that could provide the memory manager functions to deal with such handles.
    Last but not least output strings whose allocated length is not passed to the funciton as additional parameter are a huge secerity risk (talk about buffer overrun errors). LabVIEW DLL Builder does not support the creation of DLLs with output string (or array parameters)  without the explicit passing of an additional parameter telling the DLL function how large the allocated size is (so that the DLL function can make sure to never write over the end of the buffer).
    The additional length parameter only disappears for String Handles because LabVIEW will simply resize them to whatever length is necessary and that is also the reason why those handles need to be allocated by the same memory manager instance that is also going to execute the DLL function.
    Resizing of memory pointers is non-standardized and in normal circumstances not suited for passed function parameters at all.
    Rolf Kalbermatter
    Message Edited by rolfk on 06-13-2008 12:28 PM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to  Remove the  Spc Char from a String ?

    Hi
    I am trying to stream out the file name after useing Timestamp. It throws some exception
    So I used the trim method for remove the space and spacial charater. But does't trim even space also.
    Please any body help me how to remove the space and spceial characters from my string.
    The file name ( String of value)
    2c5e773bad5e153cf91d7adabc121e62007-03-30 21:54:43.219.ivwr
    the file name after removing will be like this
    d2c5e773bad5e153cf91d7adabc121e620070330215443.ivwr
    pls help me
    Thanks,
    Merlin Roshina

    filename = filename.replaceAll("(?!\\.ivwr$)[- :.]","");

  • CreateTempFile(String prefix, String sufix) is adding numbers to the prefix

    Hi folks,
    When I call createTempFile("filename", ".dat") it is adding numbers to the prefix. In my temporal directory I get a file called "filename34486.dat" instead a file called "filename.dat"! Do you know why ?
    Thanks in advance.

    bifiado wrote:
    Hi folks,
    When I call createTempFile("filename", ".dat") it is adding numbers to the prefix. In my temporal directory I get a file called "filename34486.dat" instead a file called "filename.dat"! Do you know why ?
    Thanks in advance.If you wanted a file named explicitly "filename.dat", then don't use createTempFile - that's for creating, well, temporary files with a (hopefully) unique name so as to not collide with other processes who might also be trying to create temporary files of the same name pattern.

  • Why does Firefox remove the URL from the query string?

    Hello there,
    I've writing a servlet to read data from a file stored on a server. I'm using an HTTP <INPUT TYPE=file > element to locate the file to be read. When I run the servlet using IE as the browser it works fine. When I try running it using Firefox, the path to the file is not included in the query string. The full URL to the file shows up in the file input text field but then mysteriously disappears from the query string. Without the path, the servlet can't locate the file and the servlet fails. How do I get Firefox to include the path in the query string or is there some other workaround for this problem. I want my servlet to work on all types of browsers.
    thanks,
    grant

    Well you may also ask it the other way. Why does Microsoft send the full path file with the input type="file" component?
    The purpose of this control is to upload a file from the client to the server. That file is sent with the request.
    It does not allow you to browse server files at all. Most probably you are working on your developer machine where the client IS the server, so it works right now.
    It won't once they're seperate.
    <input type="file"> is the wrong tool to use to browser the server. You need to write your own html pages to do that.
    Cheers,
    evnafets

  • Removing segment from the concatenated String...

    Hi,
    please any one tell me that what will be the query to separate segments from the concatenated string.
    For instance, if the segment value passed is
    ‘000-000-abcd-10001-post-000-21000’, then the following output should get displayed.
    000
    000
    abcd
    10001
    post
    000
    21000
    Thanks in advanced

    test it:
    with
      test_table as
          select '000-000-abcd-10001-post-000-21000' as str from dual union all
          select '111-222-cdef-20002-test' as str from dual
    select v.str,
           substr( my_str,
                   instr(my_str,'-',1, rn) + 1,
                   instr(my_str,'-',1, rn + 1) -  instr(my_str,'-',1, rn) - 1
                 ) as new_str
      from (
             select '-'||ltrim(rtrim(str,'-'),'-')||'-' as my_str,
                    str
                 from test_table
           ) v,
             select level as rn
                 from dual,
                        select max(length(str) - length(replace(str,'-'))) max_len from test_table
              connect by level <= max_len + 1
            ) pivot
    where (length(str) - length(replace(str,'-'))) + 1 >= rn
    order by str, rn
    Query finished, retrieving results...
                   STR                   NEW_STR
    000-000-abcd-10001-post-000-21000    000
    000-000-abcd-10001-post-000-21000    000
    000-000-abcd-10001-post-000-21000    abcd
    000-000-abcd-10001-post-000-21000    10001
    000-000-abcd-10001-post-000-21000    post
    000-000-abcd-10001-post-000-21000    000
    000-000-abcd-10001-post-000-21000    21000
    111-222-cdef-20002-test              111
    111-222-cdef-20002-test              222
    111-222-cdef-20002-test              cdef
    111-222-cdef-20002-test              20002
    111-222-cdef-20002-test              test
    12 row(s) retrieved

  • Set-acl and remove-ntfs both fail from PowerShell yet i can do it from the GUI

    I have put together a script that searches all of our folders then searches the folders for groups that should have access and do not and groups that should not have access and do.
    Finding only the folders that need NTFS permissions changed works great.  Adding the groups that need added works great but removing groups is not working.  Below is a section of my script with the section not working underlined.  You can
    see i have tried 2 approaches.  
    If i use the Remove-NTFSAccess command (which i really prefer) I get no errors and you would think all worked until you check.
    If i use set-acl about half give me a error  "Set-Acl : The process does not possess the 'SeSecurityPrivilege' privilege which is required for this operation" but it does not remove the Domain admins for any of the
    folders including the ones that give no error.
    I have privileges to do it.  I can go to a folder and remove the group from the NTFS permissions in the GUI with no issue. 
    Thanks!
    "Add Nseries Admins"
    $workingdir = (Get-Content "$env:TEMP\Add nseries admins.txt")
    $mynum=[int]$workingdir.Count
    foreach ($path in $workingdir) {
    $mynum
    $mynum = $mynum - 1
    $path
    Add-NTFSAccess -Path "$path" -Account "SCHOOLS\Nseries Admins" -AccessRights FullControl -AccessType Allow -AppliesTo ThisFolderSubfoldersAndFiles
    "Romeve Domain admins"
    $workingdir = (Get-Content "$env:TEMP\Remove domain admins.txt")
    $mynum=[int]$workingdir.Count
    foreach ($path in $workingdir) {
    $mynum
    $mynum = $mynum - 1
    $path
    # Add-NTFSAccess -Path "$path" -Account "SCHOOLS\Nseries Admins" -AccessRights FullControl -AccessType Allow -AppliesTo ThisFolderSubfoldersAndFiles
    # Remove-NTFSAccess -Path "$path" -Account "SCHOOLS\Domain Admins" -AccessRights Read -AccessType Allow -AppliesTo ThisFolderOnly
    $acl=get-acl "$path"
    $accessrule = New-Object system.security.AccessControl.FileSystemAccessRule("SCHOOLS\Domain Admins","Read",,,"Allow")
    $acl.RemoveAccessRuleAll($accessrule)
    Set-Acl -Path "$path" -AclObject $acl

    I just ran that a couple of times.  No errors as long as the subfolders are not protected in a way the blocks the admin.  I will try and find a folder that causes this exact scenario.
    Is it possible that this was fixed in V4?
    ¯\_(ツ)_/¯
    The SACL being overwritten isn't fixed. There's a Connect bug
    here. Set-Acl basically does this before trying to call SetAccessControl():
    $path = "$env:Temp\temp_item_name"
    $acl = Get-Acl $path
    # Get the binary form:
    $binaryForm = $acl.GetSecurityDescriptorBinaryForm()
    # Create a new SD object:
    $newacl = New-Object $acl.GetType()
    # Take the old binary form and use it for the new SD object,
    # but tell it it's for all sections, including the SACL:
    $newacl.SetSecurityDescriptorBinaryForm($binaryForm, "All")
    Next, it tries to call SetAccessControl() inside of a try{} block. If it detects a PrivilegeNotHeld exception, it will try to redo the section above without setting the Owner, Group, and SACL (if certain conditions are met). I can't get the second call to
    error the way Lishron did, but that doesn't mean there's no scenario where that can't happen.
    By the way, here's an example of trying to call SetAccessControl() with the modified SD object from above:
    $FileSystemItem = Get-Item $path
    $FileSystemItem.SetAccessControl($newacl) # <-- Fails if you're not an admin; overwrites SACL if you are
    $FileSystemItem.SetAccessControl($acl) # <-- Succeeds (unless you're trying to change the owner)

  • How to remove the last line input into a string indicator??

    I am currently working on a program where the user has the ability to create a profile for one of our lab machines to run.  When the user selects what parameters they would like, a string indicator shows the user the last input they set followed by a comma.  For example, if the user selects which profile they want, and the times they would like to set, the following string would be displayed:
    As you can see in the picture above, the profile is updated in the string indicator after every set button is hit.  In the event the user makes a mistake, I want them to have the ability to delete the last line that was added.
    This is the code I developed so far.  The string coming in and leaving is attached to a shift register so it continues to append to the indicator.  I tried in this case to count how many lines have been written in the string so far, and I built an array with the current string.  Using the delete from array.VI I indexed it to the number of lines that was created so that the last line is deleted.  I unfortunately had no luck.  Any suggestions?

    tbob wrote:
    Fonzie1104 wrote:
    Hey Tbob,
    That almost worked.  The only issue though is it leaves a null string in its place without moving everything after up one line.  Also, if i have a parameter repeating multiple times, it doenst seem to work.
    I'm confused.  If you are deleting the last line, how can there be anything after?  What do you mean by a parameter repeating multiple times?
    If you look at my example front panel, you will see that the last line is deleted.  Isn't this what you asked for?
    It's due to the fact that your constant doesn't have a comma in the last line. If you add that in, you should be able to reproduce his problem. This is just a guess though, I didn't actually test it to see.
    Message Edited by for(imstuck) on 06-08-2010 01:24 PM
    CLA, LabVIEW Versions 2010-2013

  • Removing the country code prefix from all contacts in the Address Book

    upgrading my iphone (to os 3.0) added country codes to all of my contacts,
    not noticing this i synced it with my mac, thus adding said preixes to the contacts on my mac as well.
    is there a way (only applescript from what i understand) to remove the country code from all my contacts?
    thanks!

    paste the following into Script Editor
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    tell application "Address Book"
    set mlist to selection
    repeat with per in mlist
    set NP to number of phones of per
    repeat with i from 1 to NP
    set curphone to value of (phone i of per) as text
    if text 1 thru 4 of curphone is "+972" then
    set value of phone i of per to "0" & text 5 thru -1 of curphone
    end if
    end repeat
    end repeat
    save
    end tell</pre>
    select all the contacts you want to be affected in Address Book (you can select them all) and press "run" in script editor.

Maybe you are looking for