Our Windows servers are provisioned with a set of default services. Application teams deploy applications on these servers. We need to capture these application services for the purpose of monitoring.
Basically, I need to use Powershell to compare the services running on our servers, compare this list with the list of our default services and output the difference in a .CSV file named after the host. For example, if the application server is named “xyz” then the output file should also be named "xyz.csv
I have not produced any code yet. I have tried but it has proven extremely difficult.
you’re not even asking any question? What help would expect?
“I have tried” means you wrote code.
For the vast majority of the tasks an administrator has to get done you’re not the very first one. There are very likely already code examples out there what either already fits your particular needs or can be adapted easily.
So why don’t you start searching the internet using your preferred internet search engine to find something you can start with. If you get stuck you’re welcome to come here, post your code, along with the explanation what’s not working as expected and along with the error messages you might get and we would be pleased to help you further.
BTW: Getting a list of running services from a given computer is one of the easiest tasks you can accomplish with PowerShell. Very often it is used as an example in beginner tutorials or books teaching basic PowerShell.
I know how to get services running on Windows machines using the get-service commandlet. My problem is comparing these with services running on another computer, detecting and outputting the difference.
I have searched for a solution, but what I found assumed that the number of rows (services) would be identical, only the data would be different. What I need is the opposite.
And why don’t you explain that in your initial question?
In PowerShell we work with objects and their properties. Now, if you want to compare objects you can use the cmdlet
Most of us comming here not asking for help are eager to help others because it is fun for us and it is very satisfying. So we only expect a very tiny amount of effort from the questioneer to show that we won’t just be used. So just show your efforts and post the code snippets you have so far even if it’s not doing what you want yet and describe what you need. I’d bet it will not take long for someone to either point you to the right direction or even deliver what you need.
I recieved the output below in "difference.csv
DHCP Server =>
The above result is correct.
We have a network share that contains the list of services installed on our servers. Each in its own .CSV file. The assistance I need now is to loop the “Compare-Object” against each of this .csv files. We have more than 2000 of them. Otherwise, I would have to do this manually.
I’d expect you know how to do a loop … so my question would be … what kind of assistance exactly do you need?
So you have more than 2000 servers to check or how do I understand this? How do distinguish the CSV files from each other or how to you match a CSV file with the according server?
AND PLEASE Format your code as code - DO NOT FORMAT IT AS QUOTE!
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.