Poweshell Tool NonInteractive Mode

Comments

6 comments

  • Official comment
    Brigg Angus

    We've identified this as an issue within PDQ Inventory that should be resolved with the RTM version of PDQ Inventory 12.

    Comment actions Permalink
  • Stephen Valdinger

    This is expected. Read-Host provides you a way to do user input, which is then passed on as a variable to further commands in the script. In the case of PDQ Deploy, and invoke-command, you are say "Put a prompt for input on the remote machine for input". 99% of the time, you are not at that machine to provide the needed input for the script to continue. This is especially true in the case of Running Powershell in PDQ Deploy, as the Powershell console is launched in a hidden session so there is no window showing to the user on the target machine if there happens to be someone logged in at the time.

    In your CSV create a row for Hostname, and a row with the Description

    I would refactor your code to pull data in from a CSV file instead. Play with the following, It's not tested and off the cuff, but I think it should work.

    $new = Get-Content "\\path\to\file.csv"

    Set-ADComputer -Identity:$name -Replace:@{"Description"=$new.Description | Where {$new.Hostname -match $name}} -Server:"someserver.fqdn"

     

    0
    Comment actions Permalink
  • J.B. Cummings

    Thanks. Do you care to edit your response and anonymize the server.  I missed that and was editing my post when you responded.

    0
    Comment actions Permalink
  • Stephen Valdinger

    Done my friend!

    0
    Comment actions Permalink
  • J.B. Cummings

    Thank you very much.  I had originally mis-posted this in Deploy, I have now moved it to Inventory where it belongs.  My intention is to right click a computer, select the tool and enter the new AD description.  I have a kludge that launches a compiled Autoit script to capture the new description and writes it  to a text file. The text file is then read by PS and makes the changes.  I was hoping there was a way accomplishes this without launching an external program. I am guessing that is impossible.

     

    0
    Comment actions Permalink
  • Pepijn Deneut

    Hello, I'm having the same issue in PDQ Deploy when I try to install the PSWindowsUpdate Module.

    Exception calling "ShouldContinue" with "2" argument(s): "Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available." At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7455 char:8

    • if($Force -or $psCmdlet.ShouldContinue($shouldContinueQueryMessag ...
      
    •    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      • CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
      • FullyQualifiedErrorId : PSInvalidOperationException

    Script is Find-Module -name "pswindowsupdate" |install-module

    0
    Comment actions Permalink

Please sign in to leave a comment.