# PowerShell modification help

**URL:** <https://forums.powershell.org/t/powershell-modification-help/17076>\
**Category:** PowerShell Help\
**Created:** [July 14, 2021, 11:35am UTC](https://forums.powershell.org/t/powershell-modification-help/17076 "2021-07-14T11:35:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavanpala.vja](https://avatars.discourse-cdn.com/v4/letter/p/d26b3c/32.png) [@pavanpala.vja](https://forums.powershell.org/u/pavanpala.vja)\
**Post date:** [July 14, 2021, 11:35am UTC](https://forums.powershell.org/t/powershell-modification-help/17076/1 "2021-07-14T11:35:27Z")

</div>

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”  
Members=$members  
}  
} -computer computer1,computer2 -HideComputerName |  
Select \* -ExcludeProperty RunspaceID | Export-CSV D:\Pavan\local\_admins.csv -NoTypeInformation

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 14, 2021, 11:45am UTC](https://forums.powershell.org/t/powershell-modification-help/17076/2 "2021-07-14T11:45:36Z")

</div>

Pavanpala,  
Welcome to the forum. 👋🏽

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:

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

```

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

> **[Get-LocalUser (Microsoft.PowerShell.LocalAccounts) - PowerShell](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/get-localuser?view=powershell-5.1)**
>
> The Get-LocalUser cmdlet gets local user accounts. This cmdlet gets default built-in user accounts, local user accounts that you created, and local accounts that you connected to Microsoft accounts. Note The Microsoft.PowerShell.LocalAccounts module...

It will return proper objects not just stupid text. 😉

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:23pm UTC](https://forums.powershell.org/t/powershell-modification-help/17076/3 "2024-05-16T20:23:50Z")

</div>

Closed on May 16, 2024, 8:23pm UTC


