header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Powershell ISE interactive commands
Last Post 15 Mar 2010 08:31 PM by deweeeese. 3 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
meissnersdUser is Offline
New Member
New Member
Posts:1
Avatar

--
20 Nov 2009 12:45 PM
    I just download Powershell 2.0 and using the ISE. In general I really like it but I am looking for a workaround on a gotcha. There are a lot of legacy commands which are interactive. For example xcopy will prompt the user by default if it is told to overwrite a file.

    In the Powershell ISE this appears to hang


    mkdir c:\tmp

    cd c:\tmp

    dir > tmp.txt

    mkdir sub

    xcopy .\tmp.txt sub # fine

    xcopy .\tmp.txt sub # "hang" here while it waits for a user response...




    The second xcopy is prompting the user for permission to overwrite C:\tmp\sub\tmp.txt, but the prompt is not displayed in the ISE output window. I can run this fine from cmd.exe but then what use is ISE?
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    21 Nov 2009 12:40 PM
    In a nutshell, Interactive console applications are not supported in ISE (see link below). As a workaround, you can "prevent" copy-item from overwriting a file by checking first if the file exists using test-path.

    http://blogs.msdn.com/powershell/ar...e-ise.aspx

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    halr9000User is Offline
    PowerShell MVP, Site Admin
    Advanced Member
    Advanced Member
    Posts:565
    Avatar

    --
    21 Nov 2009 12:42 PM
    Well the real answer here is--don't use Xcopy. Copy-Item (aliases cp, copy) should do the trick just fine, especially in combination with other powershell cmdlets and so forth. If there's something you can't do with xcopy that you need to, let's hear it.

    That said, the ISE just isn't a Win32 console app, so commands which were made to work one may not behave as you expect. But you get a ton of other functionality and ease-of-use when creating scripts and interactive powershell commands, so the trade-off should be worth it. Again, if you feel it's not, raise those concerns and we can address them.

    Also, consider PowerShell Plus (commercial app). I don't know if it's a true win32 console app, but it does much better emulate one, and has its other features besides.
    Community Director, PowerShellCommunity.org
    Co-host, PowerScripting Podcast
    Author, TechProsaic
    deweeeeseUser is Offline
    New Member
    New Member
    Posts:1
    Avatar

    --
    15 Mar 2010 08:31 PM
    Just started to take a look at PowerShell 2.0 included Windows 7, looking for a replacement (finally) to batch scripting to hook into my visual studio post-build step.

    I came across this PowerShell ISE input blocking problem too. It's worse than that, though; any command (e.g. xcopy) that blocks on input will block the ISE so that even the "Stop" command no longer functions. The only remedy was to restart the ISE!

    First-impression ISE wishlist:
    - bug: 'stop' command should kill commands that block on input, instead of forcing restart of ISE
    - feature: right-click on current script tab, "copy directory path"

    where can i report these issues?
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer