Homepage 5 How-to Articles 5 How to Shutdown Computers via Powershell Remotely

How to Shutdown Computers via Powershell Remotely

Monitor and manage endpoints, deploy software and patches, access and control remote machines with Action1 RMM robust cloud-based IT management solution.

June 25, 2020

It is logical that most people will always use graphic windows and a mouse to complete work on the computer, this is correct since it is simpler and faster, but there are a number of cases when you, as an advanced user or a system administrator, are simply obliged to be able to perform all tasks without a GUI interface. PowerShell has been recognized as one of the core Windows remote management tools. It will be useful, for example, to massively shut down computers on a list. PowerShell performs the shutdown remote computers in bulk without enabling remote shutdown capability (which can pose a major security risk).

How to Shutdown Single Computer via PowerShell

In order to turn off the computer, let’s turn to a modern tool, namely PowerShell. We open it in administrator mode, we will be interested in the Stop-Computer cmdlet. If you simply enter it in a shell on the local computer, then you will begin shutting down.

Shutdown Remote Computers via PowerShell

Now let’s see the help for this cmdlet, for this enter the following command:

Get-Help Stop-Computer

Shutdown Remote Computers. Get Help Stop Computer

Shutdown Remote Computers Using PowerShell cmdlet

The Stop-Computer cmdlet has the -ComputerName switch, through which you can specify a list of systems that require shutdown. I have two remote computers with Windows 10, w10-cl02 and w10-cl03. Let’s turn them off, enter the command:

Stop-Computer -ComputerName w10-cl02, w10-cl03

If someone is currently working on remote computers, you will get an error.

To solve this, you can add the -Force key, which will do a forced shutdown:

Stop-Computer -ComputerName w10-cl02, w10-cl03 -Force

If you need to perform a shutdown on behalf of a specific account, then you can use the -Credential switch:

Stop-Computer -ComputerName w10-cl02, w10-cl03 -Credential root\sem -Force

root is the name of the domain, and sem is the username.

In the Windows credential prompt, specify a password.

A situation may arise that you or your colleagues may prepare a test file with a list of computers that need to be turned off. Stop-Computer will easily cope with this task. I put on the C:\drive the computers.txt file, and then I execute the commands.

$s = Get-Content -Path C:\computers.txt

$c = Get-Credential root\sem

Stop-Computer -ComputerName $s -Force -Credential $c

Shutdown Remote Computers. Shutdown a list of computers

Also, you can shutdown multiple remote computers from AD domain. The following script is suitable for this.

  • $room=Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -SearchBase 'OU=Workstations,DC=sid-666,DC=com' -SearchScope OneLevel | Select-Object DistinguishedName | Out-GridView -PassThru -Title 'Select Computers OU to shutdown all Computers in that OU'
  • $comp=(Get-ADComputer -SearchBase $room.distinguishedname -Filter *).Name
  • Foreach ($c in $comp)
  • {Stop-Computer -ComputerName $c -ErrorAction SilentlyContinue -Force -Verbose}

Time-delayed Computer Shutdown via PowerShell

And so, how to turn off the computer after a certain time, since you can easily have such a scenario. To resolve the issue over time, there is the Start-Sleep cmdlet.

Start-Sleep -Seconds 60; Stop-Computer -ComputerName w10-cl02, w10-cl03 -Force

Time-delayed Computer Shutdown via PowerShell

As a result of the command, work will be completed on two remote computers. Or you can like this with a list of computers in a text file.

  • $s = Get-Content -Path C:\computers.txt
  • $c = Get-Credential root\sem
  • Start-Sleep -Seconds 60; Stop-Computer -ComputerName $s -Force -Credential $c

Note: Remember that you have to adapt line 1 to suit your OU structure.

How to Shutdown a Computer via a WMI Query

Also using the command line or PowerShell, you can execute the command using WMI to shut down the computer. To do this, enter the command:

(Get-WmiObject Win32_OperatingSystem -EnableAllPrivileges).Win32Shutdown(1)

Shutdown a Computer via a WMI

As a result, you will have the correct shutdown in your Windows system, you can also do a forced shutdown, to do this:

(Get-WmiObject Win32_OperatingSystem -EnableAllPrivileges).Win32Shutdown(5)

Consider Using Action1 to Shutdown Remote Computers if:

  • You need to perform an action on multiple computers simultaneously.
  • You have remote employees with computers not connected to your corporate network.

Action1 RMM is a cloud-based solution for patch management, software deployment, remote desktop, IT asset inventory, and remote endpoint management.

Related Articles

How To Delete User Profiles Remotely with PowerShell

When a user logs onto the computer for the first time (not via the network to access shared folders or printers), Windows creates a user profile. Among its contents are the NTUSER.DAT file (user profile settings), user-specific folders (My Documents, Desktop, etc.),...

About Action1 RMM

Action1 RMM is a cloud-based IT solution for remote monitoring and management, cybersecurity, and remote support.

Start your free two-week trial of Action1, or use RMM tools for free forever on 50 endpoints with no functionality limitations!


Submit a Comment

Your email address will not be published.

cloud patch management solutions action1

MSP Solution

Centralize endpoint management and boost efficiency of IT service delivery.

automated server patch management action compliance

Patch Management

Identify and deploy missing OS and third-party software updates.

cloud software deployment tools windows

Software Deployment

Distribute software and updates across managed endpoints.

software distribution tools software inventory action1

IT Asset Inventory

Keep a detailed inventory and manage hardware and software assets.

web client remote desktop

Remote Desktop

Support users via seamless remote desktop connection.

web based rdp client

Unattended Access

Provide administrative support and manage remote devices.

automated patch management action1

Endpoint Management

Run PowerShell, custom scripts, reboot computers and restart services.

API integrations action1


Integrate Action1 RMM to your IT ecosystem.

computer inventory tool for compliance

Reports and Alerts

Conduct endpoint security audits with comprehensive reporting.