invoke-wmimethod issue RRS feed

  • Question

  • I'm trying to run the following script to execute a batch file on remote pc's but get the following error:

    Invoke-WmiMethod : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that is not null or empty and then try the 
    command again.
    At C:\temp\scripts\web browser\uninstall_IE10.ps1:4 char:32


    $computerlist = Get-Content "C:\temp\IE10computers.txt"

    Invoke-WMIMethod -ComputerName $computerlist -Class Win32_Process -Name Create -ArgumentList 'cmd /c "echo y | C:\temp\IE10Uninstall\uninstall_IE10.bat"'

    any ideas to why would be appreciated.

    thank you.

    Tuesday, February 11, 2014 3:04 PM


  • Hi,

    Do you have any blank lines or trailing spaces in your input file?

    Don't retire TechNet! - (Don't give up yet - 12,575+ strong and growing)

    That's probably exactly what's going on.  You can remove those pretty easily, though:

    $computerlist = @(Get-Content "C:\temp\IE10computers.txt") -match '\S'

    Only lines that contain at least one non-whitespace character will wind up in the $computerlist variable.

    • Marked as answer by KD627 Tuesday, February 11, 2014 3:29 PM
    Tuesday, February 11, 2014 3:16 PM

All replies