none
invoke-command multiple PC bat fie issue RRS feed

  • Question

  • I am trying to run the following command (Below) and I am getting a bunch of errors. Is my syntax correct?

    $comp = get-content "c:\temp\PClist.txt" 
    invoke-command -computername $comp -scriptblock {start-process c:\temp\avupdate.bat}

    The batch file commands are

    

    Monday, May 14, 2018 4:08 PM

Answers

  • Try it like this:

    $comp = get-content c:\temp\PClist.txt
    $sb = {
    . "$env:ProgramFiles\Windows Defender\MpCmdRun.exe" -RemoveDefinitions -DynamicSignatures
    . "$env:ProgramFiles\Windows Defender\MpCmdRun.exe" -signatureUpdate
    } invoke-command -computername $comp -scriptblock $sb


    \_(ツ)_/


    • Edited by jrv Monday, May 14, 2018 11:42 PM
    • Marked as answer by Jedi_Administrator Tuesday, May 15, 2018 2:43 PM
    Monday, May 14, 2018 11:41 PM
  • You can try :

    $credentials  = Get-Credential
    $comp = get-content "c:\temp\PClist.txt" 

    $comp | foreach {
        Invoke-Command -ComputerName $_ -Credential $credentials -ScriptBlock { & c:\temp\avupdate.bat}
        }

    Tuesday, May 15, 2018 8:14 AM

All replies

  • What errors? (Remember, we can't see your screen.)


    -- Bill Stewart [Bill_Stewart]

    Monday, May 14, 2018 5:08 PM
    Moderator
  • Try it like this:

    $comp = get-content c:\temp\PClist.txt
    $sb = {
    . "$env:ProgramFiles\Windows Defender\MpCmdRun.exe" -RemoveDefinitions -DynamicSignatures
    . "$env:ProgramFiles\Windows Defender\MpCmdRun.exe" -signatureUpdate
    } invoke-command -computername $comp -scriptblock $sb


    \_(ツ)_/


    • Edited by jrv Monday, May 14, 2018 11:42 PM
    • Marked as answer by Jedi_Administrator Tuesday, May 15, 2018 2:43 PM
    Monday, May 14, 2018 11:41 PM
  • This command only works on Windows 10.


    \_(ツ)_/

    Monday, May 14, 2018 11:45 PM
  • You can try :

    $credentials  = Get-Credential
    $comp = get-content "c:\temp\PClist.txt" 

    $comp | foreach {
        Invoke-Command -ComputerName $_ -Credential $credentials -ScriptBlock { & c:\temp\avupdate.bat}
        }

    Tuesday, May 15, 2018 8:14 AM
  • These are all Windows 10 machines.

    I the following:

    WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall
    exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet.

    This command cannot be run due to the error: The system cannot find the file specified.

     The WinRM client cannot process the request because the server name cannot be resolved.

    I did not run into this issue on win 10 machines with 1803 installed. 

    Tuesday, May 15, 2018 2:43 PM
  • You cannot have any blank lines in your computer file.

    If you insist on a batch file then it must be stored on all remote systems.


    \_(ツ)_/

    Tuesday, May 15, 2018 2:56 PM