Skip to content

Commit bf3b21d

Browse files
authored
Merge pull request #108 from craigcomstock/inventory-windows-services
Added inventory-windows-services module
2 parents 3055538 + 3d6e49a commit bf3b21d

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

cfbs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@
135135
"bundles inventory_unshadowed_users:main"
136136
]
137137
},
138+
"inventory-windows-services": {
139+
"description": "Inventory running Windows services.",
140+
"subdirectory": "inventory",
141+
"steps": [
142+
"copy inventory-windows-services.cf services/cfbs/inventory-windows-services/",
143+
"policy_files services/cfbs/inventory-windows-services/",
144+
"bundles inventory_windows_services_running"
145+
]
146+
},
138147
"library-for-promise-types-in-bash": {
139148
"description": "Library enabling promise types implemented in bash.",
140149
"subdirectory": "libraries/bash",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
bundle agent inventory_windows_services_running
2+
# @brief Inventory Windows services that are running
3+
# @inventory Windows services running
4+
{
5+
vars:
6+
windows::
7+
"_cache" string => "$(sys.statedir)/windows-services-running.json";
8+
9+
"_data" data => readjson("$(_cache)");
10+
"_indices" slist => getindices(_data);
11+
12+
"i[$(_indices)]"
13+
string => "$(_data[$(_indices)][DisplayName])",
14+
meta => { "inventory", "attribute_name=Windows services running"};
15+
16+
17+
commands:
18+
windows::
19+
"Get-Service | Where-Object {$_.Status -eq 'Running'} | ConvertTo-Json | Set-Content -Path '${_cache}'"
20+
contain => powershell;
21+
22+
}
23+
24+
bundle agent __main__
25+
{
26+
methods:
27+
"inventory_windows_services_running";
28+
}

0 commit comments

Comments
 (0)