How To Manage PCs On The Local Network With PowerShell

Let’s see how it is possible to connect to the various Windows PCs connected in the local network from a single workstation that will act as an administration console.

How to Manage PCs on the Local Network with PowerShell

Windows offers everything you need tocheck the status of PCs connected to the local network through the PowerShell window.

PowerShell, introduced by Microsoft, is a command-line shell and scripting language designed for system administration. It combines the power of a traditional command prompt with the flexibility of scripting, making it ideal for automating complex tasks.

In a local network setup, where multiple PCs need to be managed, PowerShell enables administrators to perform tasks such as:

  • Monitoring system performance
  • Installing or updating software
  • Managing user accounts
  • Configuring network settings
  • Troubleshooting common issues

PowerShell’s remote capabilities make it a go-to solution for IT professionals tasked with managing distributed systems efficiently.

How to Manage PCs on the Local Network with PowerShell

And that systems need not be attested on the same domain and managed through Active Directory: the ability tomanage the LAN connected PC Remote can also be used on machines belonging to the same workgroup(workgroup).

In this way, using your personal console, you willbeable tocheck the configuration of the other PCs, the installed updates, change their operating parameters, run scripts, arrange for a restartand much more.

Before trying your hand at the systems you use in production, we suggest carrying out some tests using virtual machines connected to the local network as if they were physical systems (Cardsettingwith bridgein the case of the virtual network interface of the Virtualboxvirtual machine ).

Tomanage the PCs in the local network remotely using only PowerShellthe procedure is all in all quite simple but it is important to pay the utmost attention to each step.

Setting Up PowerShell for Network Management

Before managing PCs on a local network with PowerShell, you need to ensure the environment is set up correctly. Follow these steps:

1. Enable PowerShell Remoting

PowerShell Remoting allows you to run commands on remote PCs. To enable it:

  1. Open PowerShell as an administrator.
  2. Run the following command:
    Enable-PSRemoting -Force
  3. Ensure that all target PCs have PowerShell Remoting enabled.

2. Configure Network Settings

  • Ensure that all PCs are on the same local network and can communicate with each other.
  • Disable any firewalls or configure them to allow PowerShell traffic:
    Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP" -Enabled True

3. Set Up Credentials

To execute commands on remote machines, you need valid administrative credentials:

$credentials = Get-Credential

4. Verify Connection

Test the connection to a remote PC using the Test-Connection cmdlet:

Test-Connection -ComputerName "RemotePCName"

PowerShell Cmdlets for Managing Local Network PCs

Here are some commonly used PowerShell cmdlets for managing PCs in a local network:

1. Retrieve System Information

Use Get-ComputerInfo to gather detailed system information:

Get-ComputerInfo -ComputerName "RemotePCName"

2. Manage Processes

List running processes on a remote PC:

Get-Process -ComputerName "RemotePCName"

3. Manage Services

Start, stop, or restart services:

Start-Service -Name "ServiceName" -ComputerName "RemotePCName"
Stop-Service -Name "ServiceName" -ComputerName "RemotePCName"

4. Manage Software

Install software remotely using Invoke-Command:

Invoke-Command -ComputerName "RemotePCName" -ScriptBlock {
Start-Process "PathToInstaller" -ArgumentList "/silent" -Wait
}

5. Manage User Accounts

Add a new user account:

Invoke-Command -ComputerName "RemotePCName" -ScriptBlock {
New-LocalUser -Name "NewUser" -Password (ConvertTo-SecureString "Password" -AsPlainText -Force) -FullName "User Full Name"
}

6. Monitor Network Performance

Get network adapter statistics:

Get-NetAdapterStatistics -Name "AdapterName" -ComputerName "RemotePCName"

7. Transfer Files

Copy files to a remote PC:

Copy-Item -Path "LocalFilePath" -Destination "\\RemotePCName\C$\DestinationPath"

Advanced Use Cases

PowerShell’s capabilities extend beyond basic management. Here are some advanced scenarios:

1. Active Directory Integration

Automate user management in Active Directory using cmdlets like:

Get-ADUser -Filter *
New-ADUser -Name "NewUser"

5.2. Bulk Operations

Perform tasks on multiple PCs simultaneously:

$computers = Get-Content "ComputerList.txt"
Invoke-Command -ComputerName $computers -ScriptBlock {
Restart-Computer
}

5.3. Security Auditing

Generate security reports for the network:

Get-WinEvent -LogName Security -ComputerName "RemotePCName"

5.4. Custom Scripts

Create scripts to address unique requirements. Example: Monitoring disk usage:

$computers = Get-Content "ComputerList.txt"
foreach ($computer in $computers) {
Get-WmiObject -Class Win32_LogicalDisk -ComputerName $computer | Select-Object DeviceID, FreeSpace
}

Benefits of Managing PCs with PowerShell

Managing PCs using PowerShell offers several advantages:

  1. Automation
    Routine tasks can be automated using scripts, saving time and reducing human error.
  2. Remote Administration
    PowerShell allows administrators to execute commands on remote systems without physical access.
  3. Scalability
    With a single script, you can manage multiple machines, making it ideal for large networks.
  4. Integration
    PowerShell integrates seamlessly with other Microsoft tools like Active Directory, Exchange Server, and Azure.
  5. Customizability
    PowerShell scripts can be tailored to meet specific requirements, ensuring flexibility.

Conclusion

PowerShell is a powerful tool for managing PCs on a local network. Its flexibility, combined with robust scripting capabilities, allows administrators to perform tasks efficiently and effectively. By mastering the techniques outlined in this guide, you can optimize your network management workflows and reduce manual effort.

Whether you are managing a small office network or an enterprise-scale infrastructure, PowerShell provides the tools needed to streamline operations and maintain control. Start experimenting with these commands and scripts, and gradually explore advanced functionalities to unlock the full potential of PowerShell.

Leave a Reply

Your email address will not be published. Required fields are marked *