Monitor & Export Windows Services on Remote Computers Using PowerShell
- Avijit Dutta
- Jul 15
- 3 min read
Updated: 2 days ago
Article No :: 31

🛠️Monitor & Export Windows Services on Remote Computers Using PowerShell
🧭 Introduction
Managing service statuses across multiple Windows clients can be tedious without automation. Whether you're a sysadmin maintaining uptime or a compliance officer checking service behaviour, visibility into remote systems is crucial. This script will help sysadmins to monitor & export Windows Services on Remote Computers Using PowerShell.
This blog introduces a PowerShell script that fetches:
✅ Hostname
✅ Service Name
✅ Status (Running/Stopped)
✅ Startup Type
✅ Log On As
The script saves this data into a daily-named Excel file and emails it automatically to designated recipients.
⚙️ Prerequisites
Before using this PowerShell script, ensure the following are in place:
💻 Windows PowerShell 5.1 or later
🧑💼 Administrator privileges
🔄 WinRM enabled on all remote machines
📦 ImportExcel PowerShell module
Install using:
Install-Module -Name ImportExcel -Scope CurrentUser -Force
📁 Create the folder and input file:
C:\Services\hostname.txt ← List of target machine names (one per line)
📜 The PowerShell Script
This script does the following:
Reads computer names from C:\Services\hostname.txt
Checks if the computers are online
Retrieves service information via WMI
Saves the data in C:\Services\YYYYMMDD_Services.xlsx
Emails the report as an attachment
<#
.SYNOPSIS
Collects Windows service information from remote hosts and logs to Excel.
.DESCRIPTION
Reads hostnames from C:\Services\hostname.txt, collects service status, and writes the output to an Excel file (one per day). The report is also emailed.
Script written by: Bondhu & Avijit
DISCLAIMER:
This script is provided for educational and administrative use only. Test thoroughly before using in production. The authors are not responsible for any system impact or data loss.
#>
Import-Module ImportExcel -ErrorAction Stop
$hostnames = Get-Content -Path "C:\Services\hostname.txt"
$date = Get-Date -Format "yyyyMMdd"
$excelPath = "C:\Services\${date}_Services.xlsx"
foreach ($hostname in $hostnames) {
if (Test-Connection -ComputerName $hostname -Count 1 -Quiet) {
try {
$services = Get-WmiObject -Class Win32_Service -ComputerName $hostname | Select-Object `
@{Name='Hostname'; Expression={$_.SystemName}},
DisplayName, State, StartMode, StartName
$services | Export-Excel -Path $excelPath -WorksheetName $hostname -Append -AutoSize
} catch {
Write-Warning "Failed to fetch services from $hostname"
}
} else {
Write-Warning "$hostname is offline or unreachable."
}
}
# Email Configuration
$smtpServer = "smtp.companyname.com"
$smtpFrom = "noreply@companyname.com"
$smtpTo = "abc.xyz@companyname.com"
$smtpCc = "serveradmin@companyname.com"
$subject = "Windows Services Report - $date"
$body = "Attached is the services report for $date."
Send-MailMessage -From $smtpFrom -To $smtpTo -Cc $smtpCc -Subject $subject -Body $body `
-SmtpServer $smtpServer -Attachments $excelPath
💡 Tip: Make sure you run PowerShell as Administrator to avoid permission issues.
📊 Sample Output
Here’s a sample of what the Excel file will contain:
Hostname | DisplayName | State | StartMode | StartName |
DESKTOP-001 | Windows Update | Running | Manual | LocalSystem |
LAPTOP-002 | Print Spooler | Stopped | Automatic | NT AUTHORITY\LocalService |
The Excel file is named like: C:\Services\20250704_Services.xlsx
📩 Email Report Delivery
Once the Excel file is generated, it is sent via email to:
You can customise the recipients and SMTP settings in the script.
📥 Download the Full Script Package
📦 Download
Includes:
Full PowerShell script (Get-WindowsServicesReport.ps1)
Sample hostname.txt
README with setup and disclaimer
🧾 Conclusion
This PowerShell automation helps Windows admins:
Save hours of manual auditing
Generate and share daily reports with service insights
Enhance system compliance and visibility
✅ You can also schedule it via Task Scheduler or Intune
✅ Modify to include only critical services or specific patterns
📥 Download the Full Package
✅ Download :
📁 Inside the Package:
RemoteUserLogoff.ps1 – Full working script.
User.txt – Sample list of usernames.
computers.txt – Sample list of remote computers.
README.txt – Setup instructions and usage guide.
⚠️ Disclaimer
Important: This PowerShell script is provided for educational and administrative use. Before deploying it in a production environment, thoroughly test the script in a controlled test environment. This script performs user logoff operations and interacts with remote systems; improper use may cause data loss or session disruption. The author of this article is not responsible for any issues, data loss, or system impact that may occur from the use or misuse of this script.Administrators should review and execute it at their own risk, with proper change management and backups in place.
If you liked this article, do share the same. You can also buy me a Coffee using PayPal at "paypal.me/duttaavijit". This is purely a volunteer effort. THANK YOU !!!
#PowerShell #WindowsAdmin #SysAdminTools #RemoteManagement #ITAutomation #LogoffScript #WinRM #SecurityCompliance #WindowsScripting #PowerShellScripting
#PowerShell #Windows11 #SysAdminTools #RemoteMonitoring #ITAutomation #ServiceAudit #ExcelReports #WinRM #BondhuAndAvijit
Comments