locked
Powershell interacting with command line tools RRS feed

  • Question

  • I have a command line tool to take a screenshot and save it to a file (  C:\asl\nircmdc.exe savescreenshot  c:\test\file.png )

    With powershell I'm trying to save a screen shot as the current date and time without success 

    $Date = Get-Date -format %d/%M/%h/%m/ss
     C:\test\nircmdc.exe savescreenshot    "C:\ASL\" + $date + ".png"

    This doesn't give any error message but doesn't save anything

    Thursday, December 7, 2017 2:29 PM

All replies


  • In powershell, expressions aren't normally evaluated as parameters.  Try it out with notepad.  See #3:  http://www.rlmueller.net/PSGotchas.htm

    C:\test\nircmdc.exe savescreenshot ("C:\ASL\" + $date + ".png")




    • Edited by JS2010 Thursday, December 7, 2017 2:58 PM
    Thursday, December 7, 2017 2:49 PM
  • You cannot use that date format as a file name.

    $Date = Get-Date -format %d-%M-%h-%m-ss
    C:\test\nircmdc.exe savescreenshot "C:\ASL\ $date.png"


    \_(ツ)_/

    Thursday, December 7, 2017 4:42 PM