Menu

windows powershell project

Windows Services Administration with PowerShell

Introduction

In Windows NT operating systems, a Windows Service is a program that runs in the background without direct user interaction. Windows Services are essential for operating system functionality and application support. System Administrators are expected to understand how to manage services using PowerShell, including viewing service information, checking status, starting and stopping services, changing service accounts, and modifying startup types.

---

Task 1: List the Service Named "BrokerInfrastructure"

To display information about the BrokerInfrastructure service, the following PowerShell command was used:

Get-Service -Name BrokerInfrastructure

This command returns the service name, display name, and current status.

---

Task 2: Check the Service Status

To check the current status of the BrokerInfrastructure service, the following command was used:

Get-Service -Name BrokerInfrastructure | Select-Object Status

This command displays whether the service is Running, Stopped, or in another state.

---

Task 3: Start and Stop the Windows Service

To start the service:

Start-Service -Name BrokerInfrastructure

To stop the service:

Stop-Service -Name BrokerInfrastructure

To verify the current status after performing either action:

Get-Service -Name BrokerInfrastructure

Note: Some Windows services are critical to the operating system and may not allow stopping.

---

Task 4: Change the Service Username

To view the current service account:

Get-WmiObject Win32_Service -Filter "Name='BrokerInfrastructure'" | Select-Object Name,StartName

To change the service account:

$service = Get-WmiObject Win32_Service -Filter "Name='BrokerInfrastructure'"
$service.Change($null,$null,$null,$null,$null,$null,".\NewUser","Password")

Alternatively:

sc.exe config BrokerInfrastructure obj= ".\NewUser" password= "Password"

This changes the account under which the service runs.

---

Task 5: Change the Startup Type

To configure the service to start automatically:

Set-Service -Name BrokerInfrastructure -StartupType Automatic

To configure the service for manual startup:

Set-Service -Name BrokerInfrastructure -StartupType Manual

To disable the service:

Set-Service -Name BrokerInfrastructure -StartupType Disabled

These commands allow administrators to control when the service starts during system operation.

---

Conclusion

Windows Services are a fundamental component of the Windows operating system. Through PowerShell, administrators can efficiently manage services by viewing their status, starting or stopping them, changing service accounts, and configuring startup behavior. Understanding these tasks is an essential skill for Windows System Administration and helps ensure stable, secure, and reliable system operations.