Share via

Script not working

Anonymous
2023-02-13T06:16:23+00:00

This scripts was working normal, and suddenly it is not working, can someone please tell,

same issue is with my all scripts all sudden all showing same error,

$computers = Get-Content -Path E:\Newfolder\Input\List_computers.txt $password = convertTo-SecureString "123456" -AsPlainText -Force$cred = New-Object System.Management.Automation.PSCredential ("user", $password)$session = New-PSSession -ComputerName $computers -Credential $cred$command = {Get-LocalUser| where-Object -Property Enabled -EQ True | Select-Object -Property  Name, Enabled, Description }$res = Invoke-Command -Session $session -ScriptBlock $command | Export-Csv \10.1.1.1\e$\usercheckResult.csv -NoTypeInformation | Start-Sleep -Seconds 5 |  Exit-PSSession

ERROR message

New-PSSession : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At E:\Newfolder\runningForUser_IP.ps1:4 char:40+ $session = New-PSSession -ComputerName $computers -Credential $cred+                                        ~~~~~~~~~~+ CategoryInfo          : InvalidData: (:) [New-PSSession], ParameterBindingValidationException+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.NewPSSessionCommandInvoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.At E:\Newfolder\runningForUser_IP.ps1:6 char:32+ $res = Invoke-Command -Session $session -ScriptBlock $command | Expor ...+                                ~~~~~~~~+ CategoryInfo          : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand

Windows for home | Windows 10 | Input and language

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-02-13T06:47:39+00:00

    Hi, I’m Nicole, I’ll be happy to help you out today.

    Due to the scope of your question, It is best to ask this on Learn Microsoft which is a technical community platform where most of the members were IT professionals that would greatly help you with the issue.

    https://learn.microsoft.com/en-us/answers/quest...

    Regards.

    Was this answer helpful?

    0 comments No comments