none
Help: Invoke-Command : One or more computer names are not valid. RRS feed

  • Question

  • Hello All,

    Im Learning Powershell and quite often i see this error and i cannot figure out what the answer is. 

    $computers = Import-CSV "S:\IT\_Projects\Traps\export.csv" 

    $Credentials= $host.ui.PromptForCredential("Need credentials", "Please enter your 'Glasgow\' user name and password.", "", "NetBiosUserName")

    foreach ($computer in $computers) {Invoke-Command -ComputerName $computer -ScriptBlock {start-process "\\ukfile\group\public folder\Uninstall_Tool_Silent.exe"} -Credential $Credentials} 

    i always receive the below error. 

     
    Invoke-Command : One or more computer names are not valid. If you are trying to pass a URI, use the -ConnectionUri parameter, or pass URI objects instead of strings.
    At line:1 char:36
    + ... computers) {Invoke-Command -ComputerName $computer -ScriptBlock {star ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (System.String[]:String[]) [Invoke-Command], ArgumentException
        + FullyQualifiedErrorId : PSSessionInvalidComputerName,Microsoft.PowerShell.Commands.InvokeCommandCommand

    I have tried to google it and also make sure there are no spaces after the computer names in the export.CSV


    Could someone please point me in the rite direction? 

    Also, Is there any secret way to better troubleshoot power-shell script issues rather than google? lol

    Thanks in Advance :)

    Monday, June 3, 2019 2:31 PM

All replies