PowerShell modification help

HI Team,

Need help while adding to calling servers from text fille block for adding below script.
its just like : -computer D:\remoted\data.txt

the current block in my script was computer computer1,computer2

invoke-command {
$members = net localgroup administrators |
where {$_ -AND $_ -notmatch “command completed successfully”} |
select -skip 4
New-Object PSObject -Property @{
Computername = $env:COMPUTERNAME
Group = “Administrators”
} -computer computer1,computer2 -HideComputerName |
Select * -ExcludeProperty RunspaceID | Export-CSV D:\Pavan\local_admins.csv -NoTypeInformation

Welcome to the forum. :wave:t4:

Please when you post code, error messages, console output or sample data format it as code using the preformatted text button ( </> ).

Thanks in advance.

To provide a parameter -ComputerName with a list of computer names you stored in a file you can use a subexpression like this:

Invoke-Command -ComputerName (Get-Content -Path D:\remoted\data.txt) -ScriptBlock { .... }

Regardless of that … instead of the external command net.exe you should use

It will return proper objects not just stupid text. :wink: