Recent Visitor 296
A colleague of mine recently reached out to me to ask whether I had a script that would retrieve computer objects in an Active Directory OU and check each item for a service status and its Startup Type configuration. What he was trying to do specifically was check whether devices on his network had the Carbon Black Endpoint protection services started and configured with the appropriate Startup Type. I had an old script that did something similar so I took the script, did a bit of research and provided him the code to test.
The script can be found at my following GitHub repo:
… and will generate a CSV that contain the following columns in sequence:
A. Computer name
B. Operating System
C. The full path of the registry key
D. Registry Value Name
E. Whether the registry was reachable
F. The value of the registry key
G. The status of the service (running, stopped, etc.)
H: The service start type
I: Repeat the above with next registry
This script has the following properties:
- Defines the registry path and key on the Windows machine to search
- Defines an OU to search (includes sub OUs)
- Retrieves the operating system
- Retrieves the service status (running, stopped, etc.)
- Retrieves the registry values and translates it to the configuration of the Startup Type (Automatic, Manual, Disabled, Unknown if not found)
- Saves each result into an array
- Writes results to an array after going through all found computer objects
Here is a sample of the exported CSV file:
Feel free to modify the script as needed for any other services.