Environment
This script works on the following versions of LANDesk Management Suite:
- LDMS 9.6
- LDMS 9.5 SP2
- LDMS 9.0 SP4
Description
There are times when it is desired to STOP/Start all LANDesk services on the Core Server or on a LANDesk agent. LANDesk services include some Intel services as well.
Windows does not provide a method to Start/Stop multiple services at once, instead they must be stopped one a time.Update: PowerShell can do it!
PowerShell for Stopping\Starting All LANDesk Services
First, it's a good idea to see what the services are doing now:
PS H:\> Get-Service -DisplayName LANDesk*,Managed* | Sort-Object Status,DisplayName | Format-Table -AutoSize Status Name DisplayName ------ ---- ----------- Stopped LDGSB LANDesk(R) Management Gateway Service Running LANDesk Inventory Server LANDesk Inventory Server Running ApmTcs LANDesk Policy Server Running Intel Scheduler LANDesk Scheduler Service Running LANDeskTIM LANDesk Transport Initiator Module Running LANDesk(r) Usage Service LANDesk Usage Service Running Agent_Portal LANDesk(R) Agent Portal Service Running CBA8Alert LANDesk(R) Alert Service Running LANDesk(R) AMT Notification Service LANDesk(R) AMT Notification Service Running ASFProxyService LANDesk(R) ASF Proxy Service Running IPMI_Redirection LANDesk(R) Console Redirection Service Running CoreSyncService LANDesk(R) Core Sync Service Running CBA8 LANDesk(R) Management Agent Running LSM_SNMP LANDesk(R) System Manager SNMP Message Relay Service Running Managed Planet Barcode Core Managed Planet Barcode Core Running MPCore Managed Planet Core Scan Processor Running Managed Planet Discovery Core Managed Planet Discovery Core Running Managed Planet Rapid Deployment Managed Planet Rapid Deployment Running Managed Planet Software Manager Managed Planet Software Manager Running Managed Planet Software Store Auto Uninstall Managed Planet Software Store Auto Uninstall Running Managed Planet Software Store LDAP Cache Update Managed Planet Software Store LDAP Cache Update Running Managed Planet Software Store Maintenance Managed Planet Software Store Maintenance Running Managed Planet Software Store User Cache Update Managed Planet Software Store User Cache Update Running Managed Planet Task Listener Managed Planet Task Listener
This command will list all services that have a display name that starts with "landesk" & "managed" (it is NOT case sensitive). If you leave off "Format-Table -AutoSize", the columns will be truncated.
Now that you know what is running, it's time to stop them. THESE MUST BE RUN AS AN ADMINISTRATOR.
PS C:\> Stop-Service -DisplayName LANDesk*,Managed* -Verbose -Force - OR - PS C:\> Get-Service -DisplayName LANDesk*,Managed* | Where-Object {$_.Status -EQ "Running"} | Stop-Service -Verbose
The command will only display output for services that take their time to stop (unless you use -verbose).
Once you get back to the prompt, run "Get-Service... " to make see if all the services are actually shutdown. Sometimes it takes another go around, so just repeat the "Stop-Service... " command.
Please note that according to TCP protocol, ports can be locked open by the operating system for a maximum of 4 minutes after the process terminate. This *may* cause problems when restarting services. This is one of the reasons why the "Restart-Service" command is not used in this example.
Now, let's start them back up:
PS C:\> Start-Service -DisplayName LANDesk*,Managed* -Verbose - OR - PS C:\> Get-Service -DisplayName LANDesk*,Managed* | Where-Object {$_.Status -EQ "Stopped"} | Start-Service -Verbose
The services should be up and running now. Check with "Get-Service... " or refresh the services.msc and if some are still "Stopped". Repeat the "Start-Service... " command if needed.
If they are any in the"Starting" state for an extened period of time (which usually presents itself as "WARNING: Waiting for service 'DisplayName (Name)' to finish starting..."), check the application event logs for errors. Usually it has something to do with the database (connectivity, authetication, etc.). It may be that it just needs some time and it is NOT an error condition, i.e., don't panic. Diasabled services will always through an error.
Sometimes, it is helpful to change services from automatic to manual for troubleshooting pruposes, etc.
Get-Service -DisplayName landesk* | Set-Service -StartupType Manual -Verbose Get-Service -DisplayName landesk* | Set-Service -StartupType Automatic -Verbose
The first command will NOT stop services BUT it WILL prevent your core services from starting. The second command sets them to automatic again.
For more information about these standardPowerShell commands, please see Get-Service, Start-Service, & Stop-Service.
Batch File for Stopping\Starting All LANDesk Services
Attached is a batch file that will stop/start all LANDesk services, as well as one that will stop/start all LANDesk and DA (Managed Planet) services.
Just double-click on the batch file or to get the proper usage run the batch file with a -?.
c:\> LANDeskServices.bat -? Usage: LANDeskServices.bat [ STOP|START ] START = Starts all LANDesk and Intel Services. STOP = Stops all LANDesk and Intel Services. c:\>