Why can “find” not be used in PowerShellWhat are the PowerShell consoles for Windows?How start PowerShell...

Why do all the books in Game of Thrones library have their covers facing the back of the shelf?

Does diversity provide anything that meritocracy does not?

Why didn't the 2019 Oscars have a host?

How would an AI self awareness kill switch work?

Translation needed for 130 years old church document

Why is one not obligated to give up his life rather than violate Lashon Hara?

Memory usage: #define vs. static const for uint8_t

Small Stakes NLH 1-2 $300 Cap - What did villain have?

The No-Straight Maze

Critique vs nitpicking

How do I prevent a homebrew Grappling Hook feature from trivializing Tomb of Annihilation?

Why is it that Bernie Sanders is always called a "socialist"?

Does the ditching switch allow an A320 to float indefinitely?

When Are Enum Values Defined?

Is there a way to not have to poll the UART of an AVR?

How vim overwrites readonly mode?

What species should be used for storage of human minds?

A fantasy book with seven white haired women on the cover

Why is 'diphthong' pronounced the way it is?

Why is the "Domain users" group missing from this Powershell AD Query?

Does a paladin have to announce that they're using Divine Smite before attacking?

What is the wife of a henpecked husband called?

Non-Cancer terminal illness that can affect young (age 10-13) girls?

What language shall they sing in?



Why can “find” not be used in PowerShell


What are the PowerShell consoles for Windows?How start PowerShell from cmd by specific pathHow to repair powershell installation on windows 7Trying to make a symbolic link to a Powershell scriptApp Path incorrectly set as REG_SZChange Powershell Execution Policy silently from Batch scriptSensitive info in Powershell and/or cmd invocationsWhy does my PowerShell belief it's a Cygwin terminal?Powershell script won't launch in task scheduler when running as my admin userPowershell locks up for any command













4















What does find.exe find objectionable about the parameters when it is used in a PowerShell console shell? These commands work as expected in a cmd.exe shell.



PS C:WindowsSystem32WindowsPowerShellv1.0> find /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> find /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> C:WindowsSystem32find.exe /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> C:WindowsSystem32find.exe /i "System.Diagnostics.Process" .DotNetTypes.format.ps1xml
FIND: Parameter format not correct









share|improve this question























  • It isn't a Powershell command? Don't get confused between a executable ipconfig and a command shell command

    – Ramhound
    May 14 '17 at 2:29













  • What is it using other than C:WindowsSYSTEM32find.EXE?

    – lit
    May 14 '17 at 2:44











  • What exactly are you trying to do? Your third example uses invalid syntax

    – Ramhound
    May 14 '17 at 2:53













  • indeed I tried exactly the same command and it fails in PowerShell while gives proper output in cmd. Moreover where find works in cmd but doesn't in PowerShell

    – phuclv
    May 14 '17 at 2:54











  • I am in a PowerShell console. I want to search files for a string. find.exe does that. Yes, I know that PowerShell can also do that with Get-Content... etc. I am just trying to do something simple. Is that not possible in PowerShell? I have written a grep-like PowerShell script, but it is not on this system and I did not want to chase it down tonight.

    – lit
    May 14 '17 at 2:56
















4















What does find.exe find objectionable about the parameters when it is used in a PowerShell console shell? These commands work as expected in a cmd.exe shell.



PS C:WindowsSystem32WindowsPowerShellv1.0> find /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> find /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> C:WindowsSystem32find.exe /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> C:WindowsSystem32find.exe /i "System.Diagnostics.Process" .DotNetTypes.format.ps1xml
FIND: Parameter format not correct









share|improve this question























  • It isn't a Powershell command? Don't get confused between a executable ipconfig and a command shell command

    – Ramhound
    May 14 '17 at 2:29













  • What is it using other than C:WindowsSYSTEM32find.EXE?

    – lit
    May 14 '17 at 2:44











  • What exactly are you trying to do? Your third example uses invalid syntax

    – Ramhound
    May 14 '17 at 2:53













  • indeed I tried exactly the same command and it fails in PowerShell while gives proper output in cmd. Moreover where find works in cmd but doesn't in PowerShell

    – phuclv
    May 14 '17 at 2:54











  • I am in a PowerShell console. I want to search files for a string. find.exe does that. Yes, I know that PowerShell can also do that with Get-Content... etc. I am just trying to do something simple. Is that not possible in PowerShell? I have written a grep-like PowerShell script, but it is not on this system and I did not want to chase it down tonight.

    – lit
    May 14 '17 at 2:56














4












4








4


1






What does find.exe find objectionable about the parameters when it is used in a PowerShell console shell? These commands work as expected in a cmd.exe shell.



PS C:WindowsSystem32WindowsPowerShellv1.0> find /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> find /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> C:WindowsSystem32find.exe /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> C:WindowsSystem32find.exe /i "System.Diagnostics.Process" .DotNetTypes.format.ps1xml
FIND: Parameter format not correct









share|improve this question














What does find.exe find objectionable about the parameters when it is used in a PowerShell console shell? These commands work as expected in a cmd.exe shell.



PS C:WindowsSystem32WindowsPowerShellv1.0> find /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> find /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> C:WindowsSystem32find.exe /i "System.Diagnostics.Process" *.ps1xml
FIND: Parameter format not correct
PS C:WindowsSystem32WindowsPowerShellv1.0> C:WindowsSystem32find.exe /i "System.Diagnostics.Process" .DotNetTypes.format.ps1xml
FIND: Parameter format not correct






powershell cmd.exe find






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 14 '17 at 2:10









litlit

3011313




3011313













  • It isn't a Powershell command? Don't get confused between a executable ipconfig and a command shell command

    – Ramhound
    May 14 '17 at 2:29













  • What is it using other than C:WindowsSYSTEM32find.EXE?

    – lit
    May 14 '17 at 2:44











  • What exactly are you trying to do? Your third example uses invalid syntax

    – Ramhound
    May 14 '17 at 2:53













  • indeed I tried exactly the same command and it fails in PowerShell while gives proper output in cmd. Moreover where find works in cmd but doesn't in PowerShell

    – phuclv
    May 14 '17 at 2:54











  • I am in a PowerShell console. I want to search files for a string. find.exe does that. Yes, I know that PowerShell can also do that with Get-Content... etc. I am just trying to do something simple. Is that not possible in PowerShell? I have written a grep-like PowerShell script, but it is not on this system and I did not want to chase it down tonight.

    – lit
    May 14 '17 at 2:56



















  • It isn't a Powershell command? Don't get confused between a executable ipconfig and a command shell command

    – Ramhound
    May 14 '17 at 2:29













  • What is it using other than C:WindowsSYSTEM32find.EXE?

    – lit
    May 14 '17 at 2:44











  • What exactly are you trying to do? Your third example uses invalid syntax

    – Ramhound
    May 14 '17 at 2:53













  • indeed I tried exactly the same command and it fails in PowerShell while gives proper output in cmd. Moreover where find works in cmd but doesn't in PowerShell

    – phuclv
    May 14 '17 at 2:54











  • I am in a PowerShell console. I want to search files for a string. find.exe does that. Yes, I know that PowerShell can also do that with Get-Content... etc. I am just trying to do something simple. Is that not possible in PowerShell? I have written a grep-like PowerShell script, but it is not on this system and I did not want to chase it down tonight.

    – lit
    May 14 '17 at 2:56

















It isn't a Powershell command? Don't get confused between a executable ipconfig and a command shell command

– Ramhound
May 14 '17 at 2:29







It isn't a Powershell command? Don't get confused between a executable ipconfig and a command shell command

– Ramhound
May 14 '17 at 2:29















What is it using other than C:WindowsSYSTEM32find.EXE?

– lit
May 14 '17 at 2:44





What is it using other than C:WindowsSYSTEM32find.EXE?

– lit
May 14 '17 at 2:44













What exactly are you trying to do? Your third example uses invalid syntax

– Ramhound
May 14 '17 at 2:53







What exactly are you trying to do? Your third example uses invalid syntax

– Ramhound
May 14 '17 at 2:53















indeed I tried exactly the same command and it fails in PowerShell while gives proper output in cmd. Moreover where find works in cmd but doesn't in PowerShell

– phuclv
May 14 '17 at 2:54





indeed I tried exactly the same command and it fails in PowerShell while gives proper output in cmd. Moreover where find works in cmd but doesn't in PowerShell

– phuclv
May 14 '17 at 2:54













I am in a PowerShell console. I want to search files for a string. find.exe does that. Yes, I know that PowerShell can also do that with Get-Content... etc. I am just trying to do something simple. Is that not possible in PowerShell? I have written a grep-like PowerShell script, but it is not on this system and I did not want to chase it down tonight.

– lit
May 14 '17 at 2:56





I am in a PowerShell console. I want to search files for a string. find.exe does that. Yes, I know that PowerShell can also do that with Get-Content... etc. I am just trying to do something simple. Is that not possible in PowerShell? I have written a grep-like PowerShell script, but it is not on this system and I did not want to chase it down tonight.

– lit
May 14 '17 at 2:56










2 Answers
2






active

oldest

votes


















3














Try:



find /i "`"System.Diagnostics.Process`"" *.ps1xml


I used Sysmon.exe to compare the executions in PowerShell.exe and cmd.exe:



For cmd.exe:



 Image: C:WindowsSystem32find.exe
CommandLine: find /i "System.Diagnostics.Process" *.ps1xml
ParentImage: C:WindowsSystem32cmd.exe


For PowerShell:



 Image: C:WindowsSystem32find.exe
CommandLine: "C:Windowssystem32find.exe" /i System.Diagnostics.Process *.ps1xml
ParentImage: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


we can see that in PowerShell, the quotes around the search-term are missing, so by adding another set of double-quotes it should work.






share|improve this answer
























  • That's because You must enclose string in quotation marks in find

    – phuclv
    May 14 '17 at 3:28






  • 1





    So, PowerShell strips the quotes from the command line parameter. Sneaky. Thanks.

    – lit
    May 14 '17 at 23:56



















2














As Peter Hahndorf said, PowerShell is stripping the outer quotes. See PowerShell stripping double quotes from command line arguments. You can check it by echoing or writing the string directly in command line



PS C:> echo C:WindowsSystem32find.exe /i "System.Diagnostics.Process" *.ps1xml
C:WindowsSystem32find.exe
/i
System.Diagnostics.Process
*.ps1xml
PS C:> "System.Diagnostics.Process"
System.Diagnostics.Process


IMHO it's a good thing because now you can use single quotes to wrap strings. You also have a standardized way to pass special characters parameters similar to bash, unlike in cmd where embedded double quotes are a pain



According to PowerShell quoting rule you must escape the quote by either `backticks` or the double quote itself, or simply put it in single quotes



find.exe /i "`"System.Diagnostics.Process`"" *.ps1xml
find.exe /i """System.Diagnostics.Process""" *.ps1xml
find.exe /i '"System.Diagnostics.Process"' *.ps1xml


In simple cases like this when there's no space in the parameter you can also escape the double quotes directly without putting it inside another pair of quotes



find.exe /i `"System.Diagnostics.Process`" *.ps1xml


However there's an easier way with Verbatim arguments --%




In PowerShell 3.0 the special marker --% is a signal to PowerShell to stop interpreting any remaining characters on the line. This can be used to call a non-PowerShell utility and pass along some quoted parameters exactly as is.




As a result you can use it like this



find.exe --% "System.Diagnostics.Process" *.ps1xml


Or if you don't need Unicode support then you can simply find with findstr which doesn't need the quotes



PS C:Users> help | findstr command
topics at the command line.
The Get-Help cmdlet displays help at the command line from content in





share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1208964%2fwhy-can-find-not-be-used-in-powershell%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Try:



    find /i "`"System.Diagnostics.Process`"" *.ps1xml


    I used Sysmon.exe to compare the executions in PowerShell.exe and cmd.exe:



    For cmd.exe:



     Image: C:WindowsSystem32find.exe
    CommandLine: find /i "System.Diagnostics.Process" *.ps1xml
    ParentImage: C:WindowsSystem32cmd.exe


    For PowerShell:



     Image: C:WindowsSystem32find.exe
    CommandLine: "C:Windowssystem32find.exe" /i System.Diagnostics.Process *.ps1xml
    ParentImage: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


    we can see that in PowerShell, the quotes around the search-term are missing, so by adding another set of double-quotes it should work.






    share|improve this answer
























    • That's because You must enclose string in quotation marks in find

      – phuclv
      May 14 '17 at 3:28






    • 1





      So, PowerShell strips the quotes from the command line parameter. Sneaky. Thanks.

      – lit
      May 14 '17 at 23:56
















    3














    Try:



    find /i "`"System.Diagnostics.Process`"" *.ps1xml


    I used Sysmon.exe to compare the executions in PowerShell.exe and cmd.exe:



    For cmd.exe:



     Image: C:WindowsSystem32find.exe
    CommandLine: find /i "System.Diagnostics.Process" *.ps1xml
    ParentImage: C:WindowsSystem32cmd.exe


    For PowerShell:



     Image: C:WindowsSystem32find.exe
    CommandLine: "C:Windowssystem32find.exe" /i System.Diagnostics.Process *.ps1xml
    ParentImage: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


    we can see that in PowerShell, the quotes around the search-term are missing, so by adding another set of double-quotes it should work.






    share|improve this answer
























    • That's because You must enclose string in quotation marks in find

      – phuclv
      May 14 '17 at 3:28






    • 1





      So, PowerShell strips the quotes from the command line parameter. Sneaky. Thanks.

      – lit
      May 14 '17 at 23:56














    3












    3








    3







    Try:



    find /i "`"System.Diagnostics.Process`"" *.ps1xml


    I used Sysmon.exe to compare the executions in PowerShell.exe and cmd.exe:



    For cmd.exe:



     Image: C:WindowsSystem32find.exe
    CommandLine: find /i "System.Diagnostics.Process" *.ps1xml
    ParentImage: C:WindowsSystem32cmd.exe


    For PowerShell:



     Image: C:WindowsSystem32find.exe
    CommandLine: "C:Windowssystem32find.exe" /i System.Diagnostics.Process *.ps1xml
    ParentImage: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


    we can see that in PowerShell, the quotes around the search-term are missing, so by adding another set of double-quotes it should work.






    share|improve this answer













    Try:



    find /i "`"System.Diagnostics.Process`"" *.ps1xml


    I used Sysmon.exe to compare the executions in PowerShell.exe and cmd.exe:



    For cmd.exe:



     Image: C:WindowsSystem32find.exe
    CommandLine: find /i "System.Diagnostics.Process" *.ps1xml
    ParentImage: C:WindowsSystem32cmd.exe


    For PowerShell:



     Image: C:WindowsSystem32find.exe
    CommandLine: "C:Windowssystem32find.exe" /i System.Diagnostics.Process *.ps1xml
    ParentImage: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


    we can see that in PowerShell, the quotes around the search-term are missing, so by adding another set of double-quotes it should work.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered May 14 '17 at 3:17









    Peter HahndorfPeter Hahndorf

    8,71953758




    8,71953758













    • That's because You must enclose string in quotation marks in find

      – phuclv
      May 14 '17 at 3:28






    • 1





      So, PowerShell strips the quotes from the command line parameter. Sneaky. Thanks.

      – lit
      May 14 '17 at 23:56



















    • That's because You must enclose string in quotation marks in find

      – phuclv
      May 14 '17 at 3:28






    • 1





      So, PowerShell strips the quotes from the command line parameter. Sneaky. Thanks.

      – lit
      May 14 '17 at 23:56

















    That's because You must enclose string in quotation marks in find

    – phuclv
    May 14 '17 at 3:28





    That's because You must enclose string in quotation marks in find

    – phuclv
    May 14 '17 at 3:28




    1




    1





    So, PowerShell strips the quotes from the command line parameter. Sneaky. Thanks.

    – lit
    May 14 '17 at 23:56





    So, PowerShell strips the quotes from the command line parameter. Sneaky. Thanks.

    – lit
    May 14 '17 at 23:56













    2














    As Peter Hahndorf said, PowerShell is stripping the outer quotes. See PowerShell stripping double quotes from command line arguments. You can check it by echoing or writing the string directly in command line



    PS C:> echo C:WindowsSystem32find.exe /i "System.Diagnostics.Process" *.ps1xml
    C:WindowsSystem32find.exe
    /i
    System.Diagnostics.Process
    *.ps1xml
    PS C:> "System.Diagnostics.Process"
    System.Diagnostics.Process


    IMHO it's a good thing because now you can use single quotes to wrap strings. You also have a standardized way to pass special characters parameters similar to bash, unlike in cmd where embedded double quotes are a pain



    According to PowerShell quoting rule you must escape the quote by either `backticks` or the double quote itself, or simply put it in single quotes



    find.exe /i "`"System.Diagnostics.Process`"" *.ps1xml
    find.exe /i """System.Diagnostics.Process""" *.ps1xml
    find.exe /i '"System.Diagnostics.Process"' *.ps1xml


    In simple cases like this when there's no space in the parameter you can also escape the double quotes directly without putting it inside another pair of quotes



    find.exe /i `"System.Diagnostics.Process`" *.ps1xml


    However there's an easier way with Verbatim arguments --%




    In PowerShell 3.0 the special marker --% is a signal to PowerShell to stop interpreting any remaining characters on the line. This can be used to call a non-PowerShell utility and pass along some quoted parameters exactly as is.




    As a result you can use it like this



    find.exe --% "System.Diagnostics.Process" *.ps1xml


    Or if you don't need Unicode support then you can simply find with findstr which doesn't need the quotes



    PS C:Users> help | findstr command
    topics at the command line.
    The Get-Help cmdlet displays help at the command line from content in





    share|improve this answer






























      2














      As Peter Hahndorf said, PowerShell is stripping the outer quotes. See PowerShell stripping double quotes from command line arguments. You can check it by echoing or writing the string directly in command line



      PS C:> echo C:WindowsSystem32find.exe /i "System.Diagnostics.Process" *.ps1xml
      C:WindowsSystem32find.exe
      /i
      System.Diagnostics.Process
      *.ps1xml
      PS C:> "System.Diagnostics.Process"
      System.Diagnostics.Process


      IMHO it's a good thing because now you can use single quotes to wrap strings. You also have a standardized way to pass special characters parameters similar to bash, unlike in cmd where embedded double quotes are a pain



      According to PowerShell quoting rule you must escape the quote by either `backticks` or the double quote itself, or simply put it in single quotes



      find.exe /i "`"System.Diagnostics.Process`"" *.ps1xml
      find.exe /i """System.Diagnostics.Process""" *.ps1xml
      find.exe /i '"System.Diagnostics.Process"' *.ps1xml


      In simple cases like this when there's no space in the parameter you can also escape the double quotes directly without putting it inside another pair of quotes



      find.exe /i `"System.Diagnostics.Process`" *.ps1xml


      However there's an easier way with Verbatim arguments --%




      In PowerShell 3.0 the special marker --% is a signal to PowerShell to stop interpreting any remaining characters on the line. This can be used to call a non-PowerShell utility and pass along some quoted parameters exactly as is.




      As a result you can use it like this



      find.exe --% "System.Diagnostics.Process" *.ps1xml


      Or if you don't need Unicode support then you can simply find with findstr which doesn't need the quotes



      PS C:Users> help | findstr command
      topics at the command line.
      The Get-Help cmdlet displays help at the command line from content in





      share|improve this answer




























        2












        2








        2







        As Peter Hahndorf said, PowerShell is stripping the outer quotes. See PowerShell stripping double quotes from command line arguments. You can check it by echoing or writing the string directly in command line



        PS C:> echo C:WindowsSystem32find.exe /i "System.Diagnostics.Process" *.ps1xml
        C:WindowsSystem32find.exe
        /i
        System.Diagnostics.Process
        *.ps1xml
        PS C:> "System.Diagnostics.Process"
        System.Diagnostics.Process


        IMHO it's a good thing because now you can use single quotes to wrap strings. You also have a standardized way to pass special characters parameters similar to bash, unlike in cmd where embedded double quotes are a pain



        According to PowerShell quoting rule you must escape the quote by either `backticks` or the double quote itself, or simply put it in single quotes



        find.exe /i "`"System.Diagnostics.Process`"" *.ps1xml
        find.exe /i """System.Diagnostics.Process""" *.ps1xml
        find.exe /i '"System.Diagnostics.Process"' *.ps1xml


        In simple cases like this when there's no space in the parameter you can also escape the double quotes directly without putting it inside another pair of quotes



        find.exe /i `"System.Diagnostics.Process`" *.ps1xml


        However there's an easier way with Verbatim arguments --%




        In PowerShell 3.0 the special marker --% is a signal to PowerShell to stop interpreting any remaining characters on the line. This can be used to call a non-PowerShell utility and pass along some quoted parameters exactly as is.




        As a result you can use it like this



        find.exe --% "System.Diagnostics.Process" *.ps1xml


        Or if you don't need Unicode support then you can simply find with findstr which doesn't need the quotes



        PS C:Users> help | findstr command
        topics at the command line.
        The Get-Help cmdlet displays help at the command line from content in





        share|improve this answer















        As Peter Hahndorf said, PowerShell is stripping the outer quotes. See PowerShell stripping double quotes from command line arguments. You can check it by echoing or writing the string directly in command line



        PS C:> echo C:WindowsSystem32find.exe /i "System.Diagnostics.Process" *.ps1xml
        C:WindowsSystem32find.exe
        /i
        System.Diagnostics.Process
        *.ps1xml
        PS C:> "System.Diagnostics.Process"
        System.Diagnostics.Process


        IMHO it's a good thing because now you can use single quotes to wrap strings. You also have a standardized way to pass special characters parameters similar to bash, unlike in cmd where embedded double quotes are a pain



        According to PowerShell quoting rule you must escape the quote by either `backticks` or the double quote itself, or simply put it in single quotes



        find.exe /i "`"System.Diagnostics.Process`"" *.ps1xml
        find.exe /i """System.Diagnostics.Process""" *.ps1xml
        find.exe /i '"System.Diagnostics.Process"' *.ps1xml


        In simple cases like this when there's no space in the parameter you can also escape the double quotes directly without putting it inside another pair of quotes



        find.exe /i `"System.Diagnostics.Process`" *.ps1xml


        However there's an easier way with Verbatim arguments --%




        In PowerShell 3.0 the special marker --% is a signal to PowerShell to stop interpreting any remaining characters on the line. This can be used to call a non-PowerShell utility and pass along some quoted parameters exactly as is.




        As a result you can use it like this



        find.exe --% "System.Diagnostics.Process" *.ps1xml


        Or if you don't need Unicode support then you can simply find with findstr which doesn't need the quotes



        PS C:Users> help | findstr command
        topics at the command line.
        The Get-Help cmdlet displays help at the command line from content in






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 5 hours ago

























        answered May 19 '17 at 6:44









        phuclvphuclv

        9,41363990




        9,41363990






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1208964%2fwhy-can-find-not-be-used-in-powershell%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

            Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...