Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows

วิธี Export รายการ Windows Services โดยใช้ Command Line

คุณสามารถใช้ Command Prompt หรือ Get-Service PowerShell Cmdlet เพื่อสร้างรายการ Windows Services ที่กำลัง Running หรือ Stopped บทความนี้จะแสดงวิธีสร้างรายการ Windows Services ที่ทำงานบนคอมพิวเตอร์ Windows 11/10/8/7 ของคุณ

วิธี Export Windows Services List

Export Windows Services List ใช้ Command Line ใน CMD

เปิด Command Prompt แบบ Elevated (Run as Administrator) พิมพ์คำสั่งต่อไปนี้และกด Enter:

sc query type= service > "%userprofile%\Desktop\ServicesList.txt"

นี่จะบันทึกรายการเป็นไฟล์ข้อความบน Desktop ของคุณ

ใช้ PowerShell สร้างรายการ Windows Services

Cmdlet Get-Service ถูกออกแบบมาเพื่อดึงข้อมูลเกี่ยวกับ Services ที่ติดตั้งบนคอมพิวเตอร์ของคุณ โดยใช้ Get-Service PowerShell Cmdlet คุณสามารถสร้างรายการ Windows Services ที่ทำงานบนคอมพิวเตอร์ Windows 10/8/7 ของคุณ

วิธี Export รายการ Windows Services โดยใช้ Command Line

เปิด PowerShell Console แบบ Elevated พิมพ์ Get-Service และกด Enter คุณจะเห็นรายการ Services ทั้งหมดที่ติดตั้งบนระบบ Windows ของคุณ

คุณยังสามารถกรองผลลัพธ์โดยใช้ความสามารถในการกรองของ Windows PowerShell ใช้ Parameters เพื่อบรรลุเป้าหมายนี้ คุณสามารถสร้างรายการ Running Services และ Stopped Services ได้ คุณยังสามารถเรียงลำดับตามชื่อโดยใช้ Cmdlet Sort-Object คุณสามารถก้าวไปข้างหน้าอีกขั้นและ Output รายการไปยัง GridView

ตัวอย่างเช่น คุณสามารถใช้ Cmdlet Get-Service กรองสถานะด้วยคำว่า Running และ Output ไปยัง GridView โดยใช้คำสั่งต่อไปนี้:

Get-Service | Where Status -eq "Running" | Out-GridView

นี่จะสร้างรายการ Running Services และเปิดหน้าต่างอื่นเพื่อแสดงผลลัพธ์

เพื่อดึงข้อมูลเกี่ยวกับ Stopped Services บน Remote Computer และ Output ไปยัง GridView ให้ใช้ Parameter -ComputerName ตามตัวอย่างด้านล่าง:

Get-Service -ComputerName RemoteComputerName | Where Status -eq "Stopped" | Out-GridView

เพื่อ Export รายการ Windows Services ให้ใช้คำสั่งต่อไปนี้:

Get-Service | Where-Object {$_.Status -eq "Running"} | Out-File -filepath "$Env:userprofile\Desktop\ServicesList.txt"

นี่จะบันทึกรายการเป็นไฟล์ข้อความบน Desktop ของคุณ

นี่คือเพียง 3 ตัวอย่าง อ่านเพิ่มเติมเกี่ยวกับ Get-Service บน TechNet

ตอนนี้ ลองดูวิธี Export และ Backup Device Drivers ใน Windows โดยใช้ PowerShell

โดยใช้ Windows PowerShell คุณยังสามารถ อัปเดต Windows Defender Definitions, รายการ Drives, Uninstall Universal Apps, หา Scheduled Tasks Queued Status, สร้าง System Image, สร้าง Desktop Shortcut เพื่อเปิด Windows Store Apps, ได้ Installed Driver List, Export Drivers และอื่นๆ อีกมากมาย!

วิธี Export รายการ Windows Services โดยใช้ Command Line