Export function Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag?PowerShell if statement for retrieving Machine Type gives wrong response all the timeHow to output something in PowerShellRedirect write-host to a textbox in a form?In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?Powershell: moving items not working when filenames that have chars [ ]Why does this function break in Powershell?Powershell - Exporting Select-String when using regexPowershell Get-ChildItem appears to lock files for writtingPowershell export-csv return numbersRename multiple files with string from .txt file using PowerShellCombining two commands into one and exporting to csv file in Powershell

Is a manifold-with-boundary with given interior and non-empty boundary essentially unique?

What is the musical term for a note that continously plays through a melody?

Why are there no cargo aircraft with "flying wing" design?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

Why is "Consequences inflicted." not a sentence?

Can a non-EU citizen traveling with me come with me through the EU passport line?

Disable hyphenation for an entire paragraph

How do I keep my slimes from escaping their pens?

What are the pros and cons of Aerospike nosecones?

When to stop saving and start investing?

Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?

How discoverable are IPv6 addresses and AAAA names by potential attackers?

What do you call a plan that's an alternative plan in case your initial plan fails?

G-Code for resetting to 100% speed

Why did the IBM 650 use bi-quinary?

Do you forfeit tax refunds/credits if you aren't required to and don't file by April 15?

How to draw this diagram using TikZ package?

Why was the term "discrete" used in discrete logarithm?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

Is high blood pressure ever a symptom attributable solely to dehydration?

What is the longest distance a 13th-level monk can jump while attacking on the same turn?

How much radiation do nuclear physics experiments expose researchers to nowadays?

Gastric acid as a weapon

How to deal with a team lead who never gives me credit?



Export function



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?PowerShell if statement for retrieving Machine Type gives wrong response all the timeHow to output something in PowerShellRedirect write-host to a textbox in a form?In PowerShell, how do I define a function in a file and call it from the PowerShell commandline?Powershell: moving items not working when filenames that have chars [ ]Why does this function break in Powershell?Powershell - Exporting Select-String when using regexPowershell Get-ChildItem appears to lock files for writtingPowershell export-csv return numbersRename multiple files with string from .txt file using PowerShellCombining two commands into one and exporting to csv file in Powershell



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am trying to create a function in which a user has to give a filename that can not containt an empty string. Besides that, the string can not contain a dot. When I run this function, I keep looping when I enter "test" for example. Any idea as to why?



 function Export-Output 
do
$exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
until ($exportInvoke -eq "Y" -or "N")

if ($exportInvoke -eq "Y") Out-Null




EDIT:



On a related note:



do 
$exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
until ($exportInvoke -eq "Y" -or "N")


When I use these lines of code I can simply hit enter to circumvent the Read-Host. When I replace "Y" -or "N" with simply "Y" it does not. Any idea as to why this is happening?










share|improve this question






























    0















    I am trying to create a function in which a user has to give a filename that can not containt an empty string. Besides that, the string can not contain a dot. When I run this function, I keep looping when I enter "test" for example. Any idea as to why?



     function Export-Output 
    do
    $exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
    until ($exportInvoke -eq "Y" -or "N")

    if ($exportInvoke -eq "Y") Out-Null




    EDIT:



    On a related note:



    do 
    $exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
    until ($exportInvoke -eq "Y" -or "N")


    When I use these lines of code I can simply hit enter to circumvent the Read-Host. When I replace "Y" -or "N" with simply "Y" it does not. Any idea as to why this is happening?










    share|improve this question


























      0












      0








      0








      I am trying to create a function in which a user has to give a filename that can not containt an empty string. Besides that, the string can not contain a dot. When I run this function, I keep looping when I enter "test" for example. Any idea as to why?



       function Export-Output 
      do
      $exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
      until ($exportInvoke -eq "Y" -or "N")

      if ($exportInvoke -eq "Y") Out-Null




      EDIT:



      On a related note:



      do 
      $exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
      until ($exportInvoke -eq "Y" -or "N")


      When I use these lines of code I can simply hit enter to circumvent the Read-Host. When I replace "Y" -or "N" with simply "Y" it does not. Any idea as to why this is happening?










      share|improve this question
















      I am trying to create a function in which a user has to give a filename that can not containt an empty string. Besides that, the string can not contain a dot. When I run this function, I keep looping when I enter "test" for example. Any idea as to why?



       function Export-Output 
      do
      $exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
      until ($exportInvoke -eq "Y" -or "N")

      if ($exportInvoke -eq "Y") Out-Null




      EDIT:



      On a related note:



      do 
      $exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
      until ($exportInvoke -eq "Y" -or "N")


      When I use these lines of code I can simply hit enter to circumvent the Read-Host. When I replace "Y" -or "N" with simply "Y" it does not. Any idea as to why this is happening?







      powershell powershell-v2.0 powershell-v3.0






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 22 at 9:55









      Ansgar Wiechers

      146k13135193




      146k13135193










      asked Sep 4 '13 at 17:04







      user1863886





























          2 Answers
          2






          active

          oldest

          votes


















          2














          The -match operator checks against a regular expression, so this:



          $script:newLog -match ".*"


          is testing if the filename contains any charachter except newline (.) 0 or more times (*). This condition will always be true, thus creating an infinite loop.



          If you want to test for a literal dot, you must escape it:



          $script:newLog -match '.'



          As for your other question, you're misunderstanding how logical and comparison operators work. $exportInvoke -eq "Y" -or "N" does not mean $exportInvoke -eq ("Y" -or "N"), i.e. variable equals either "Y" or "N". It means ($exportInvoke -eq "Y") -or ("N"). Since the expression "N" does not evaluate to zero, PowerShell interprets it as $true, so your condition becomes ($exportInvoke -eq "Y") -or $true, which is always true. You need to change the condition to this:



          $exportInvoke -eq "Y" -or $exportInvoke -eq "N"





          share|improve this answer

























          • Alright that helps alot. I edited the main post for another small related question. Would you mind taking a look at that ?

            – user1863886
            Sep 4 '13 at 17:44











          • @user2744349 See updated answer.

            – Ansgar Wiechers
            Sep 4 '13 at 18:03












          • Much appreciated. I bookmarked the link. In for a good read I guess... To be honest I am not completely sure yet why "N" becomes $true but I guess I'll find out.

            – user1863886
            Sep 4 '13 at 18:14


















          1














          Use this to test your input:



          !($script:newLog.contains('.')) -and !([String]::IsNullOrEmpty($script:newLog)) -and !([String]::IsNullOrWhiteSpace($script:newLog))



          Your regular expression (-match ".*" is essentially matching on everything.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            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%2fstackoverflow.com%2fquestions%2f18619821%2fexport-function%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









            2














            The -match operator checks against a regular expression, so this:



            $script:newLog -match ".*"


            is testing if the filename contains any charachter except newline (.) 0 or more times (*). This condition will always be true, thus creating an infinite loop.



            If you want to test for a literal dot, you must escape it:



            $script:newLog -match '.'



            As for your other question, you're misunderstanding how logical and comparison operators work. $exportInvoke -eq "Y" -or "N" does not mean $exportInvoke -eq ("Y" -or "N"), i.e. variable equals either "Y" or "N". It means ($exportInvoke -eq "Y") -or ("N"). Since the expression "N" does not evaluate to zero, PowerShell interprets it as $true, so your condition becomes ($exportInvoke -eq "Y") -or $true, which is always true. You need to change the condition to this:



            $exportInvoke -eq "Y" -or $exportInvoke -eq "N"





            share|improve this answer

























            • Alright that helps alot. I edited the main post for another small related question. Would you mind taking a look at that ?

              – user1863886
              Sep 4 '13 at 17:44











            • @user2744349 See updated answer.

              – Ansgar Wiechers
              Sep 4 '13 at 18:03












            • Much appreciated. I bookmarked the link. In for a good read I guess... To be honest I am not completely sure yet why "N" becomes $true but I guess I'll find out.

              – user1863886
              Sep 4 '13 at 18:14















            2














            The -match operator checks against a regular expression, so this:



            $script:newLog -match ".*"


            is testing if the filename contains any charachter except newline (.) 0 or more times (*). This condition will always be true, thus creating an infinite loop.



            If you want to test for a literal dot, you must escape it:



            $script:newLog -match '.'



            As for your other question, you're misunderstanding how logical and comparison operators work. $exportInvoke -eq "Y" -or "N" does not mean $exportInvoke -eq ("Y" -or "N"), i.e. variable equals either "Y" or "N". It means ($exportInvoke -eq "Y") -or ("N"). Since the expression "N" does not evaluate to zero, PowerShell interprets it as $true, so your condition becomes ($exportInvoke -eq "Y") -or $true, which is always true. You need to change the condition to this:



            $exportInvoke -eq "Y" -or $exportInvoke -eq "N"





            share|improve this answer

























            • Alright that helps alot. I edited the main post for another small related question. Would you mind taking a look at that ?

              – user1863886
              Sep 4 '13 at 17:44











            • @user2744349 See updated answer.

              – Ansgar Wiechers
              Sep 4 '13 at 18:03












            • Much appreciated. I bookmarked the link. In for a good read I guess... To be honest I am not completely sure yet why "N" becomes $true but I guess I'll find out.

              – user1863886
              Sep 4 '13 at 18:14













            2












            2








            2







            The -match operator checks against a regular expression, so this:



            $script:newLog -match ".*"


            is testing if the filename contains any charachter except newline (.) 0 or more times (*). This condition will always be true, thus creating an infinite loop.



            If you want to test for a literal dot, you must escape it:



            $script:newLog -match '.'



            As for your other question, you're misunderstanding how logical and comparison operators work. $exportInvoke -eq "Y" -or "N" does not mean $exportInvoke -eq ("Y" -or "N"), i.e. variable equals either "Y" or "N". It means ($exportInvoke -eq "Y") -or ("N"). Since the expression "N" does not evaluate to zero, PowerShell interprets it as $true, so your condition becomes ($exportInvoke -eq "Y") -or $true, which is always true. You need to change the condition to this:



            $exportInvoke -eq "Y" -or $exportInvoke -eq "N"





            share|improve this answer















            The -match operator checks against a regular expression, so this:



            $script:newLog -match ".*"


            is testing if the filename contains any charachter except newline (.) 0 or more times (*). This condition will always be true, thus creating an infinite loop.



            If you want to test for a literal dot, you must escape it:



            $script:newLog -match '.'



            As for your other question, you're misunderstanding how logical and comparison operators work. $exportInvoke -eq "Y" -or "N" does not mean $exportInvoke -eq ("Y" -or "N"), i.e. variable equals either "Y" or "N". It means ($exportInvoke -eq "Y") -or ("N"). Since the expression "N" does not evaluate to zero, PowerShell interprets it as $true, so your condition becomes ($exportInvoke -eq "Y") -or $true, which is always true. You need to change the condition to this:



            $exportInvoke -eq "Y" -or $exportInvoke -eq "N"






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Sep 4 '13 at 18:02

























            answered Sep 4 '13 at 17:27









            Ansgar WiechersAnsgar Wiechers

            146k13135193




            146k13135193












            • Alright that helps alot. I edited the main post for another small related question. Would you mind taking a look at that ?

              – user1863886
              Sep 4 '13 at 17:44











            • @user2744349 See updated answer.

              – Ansgar Wiechers
              Sep 4 '13 at 18:03












            • Much appreciated. I bookmarked the link. In for a good read I guess... To be honest I am not completely sure yet why "N" becomes $true but I guess I'll find out.

              – user1863886
              Sep 4 '13 at 18:14

















            • Alright that helps alot. I edited the main post for another small related question. Would you mind taking a look at that ?

              – user1863886
              Sep 4 '13 at 17:44











            • @user2744349 See updated answer.

              – Ansgar Wiechers
              Sep 4 '13 at 18:03












            • Much appreciated. I bookmarked the link. In for a good read I guess... To be honest I am not completely sure yet why "N" becomes $true but I guess I'll find out.

              – user1863886
              Sep 4 '13 at 18:14
















            Alright that helps alot. I edited the main post for another small related question. Would you mind taking a look at that ?

            – user1863886
            Sep 4 '13 at 17:44





            Alright that helps alot. I edited the main post for another small related question. Would you mind taking a look at that ?

            – user1863886
            Sep 4 '13 at 17:44













            @user2744349 See updated answer.

            – Ansgar Wiechers
            Sep 4 '13 at 18:03






            @user2744349 See updated answer.

            – Ansgar Wiechers
            Sep 4 '13 at 18:03














            Much appreciated. I bookmarked the link. In for a good read I guess... To be honest I am not completely sure yet why "N" becomes $true but I guess I'll find out.

            – user1863886
            Sep 4 '13 at 18:14





            Much appreciated. I bookmarked the link. In for a good read I guess... To be honest I am not completely sure yet why "N" becomes $true but I guess I'll find out.

            – user1863886
            Sep 4 '13 at 18:14













            1














            Use this to test your input:



            !($script:newLog.contains('.')) -and !([String]::IsNullOrEmpty($script:newLog)) -and !([String]::IsNullOrWhiteSpace($script:newLog))



            Your regular expression (-match ".*" is essentially matching on everything.






            share|improve this answer



























              1














              Use this to test your input:



              !($script:newLog.contains('.')) -and !([String]::IsNullOrEmpty($script:newLog)) -and !([String]::IsNullOrWhiteSpace($script:newLog))



              Your regular expression (-match ".*" is essentially matching on everything.






              share|improve this answer

























                1












                1








                1







                Use this to test your input:



                !($script:newLog.contains('.')) -and !([String]::IsNullOrEmpty($script:newLog)) -and !([String]::IsNullOrWhiteSpace($script:newLog))



                Your regular expression (-match ".*" is essentially matching on everything.






                share|improve this answer













                Use this to test your input:



                !($script:newLog.contains('.')) -and !([String]::IsNullOrEmpty($script:newLog)) -and !([String]::IsNullOrWhiteSpace($script:newLog))



                Your regular expression (-match ".*" is essentially matching on everything.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 4 '13 at 17:34









                alrocalroc

                23.3k33566




                23.3k33566



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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%2fstackoverflow.com%2fquestions%2f18619821%2fexport-function%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현