banshee est en développement actif : les collecteurs vont encore changer, et une version que vous publiez demandera sans doute des ajustements. Pour un usage stable, attendez la version 1.0.0.

Active Directory

banshee/active-directory-collection/active-directory/winrm/

dc-services

The state of the services of a domain controller: NTDS, Netlogon, KDC, DNS, W32Time and DFSR, by WinRM and PowerShell

  • active-directory
  • domain-controller
  • winrm
  • powershell
  • services

par banshee1 installation2 versions

v2Dernière

Publiée le 28 octobre 2026. One naming convention across collections; documentation completed.

Keen 1.0.0 · 48 lignes
// The services a domain controller runs, by WinRM: Active Directory Domain Services (NTDS), Netlogon, the
// Kerberos Key Distribution Center (Kdc), the DNS Server (DNS), the Windows Time service (W32Time) and DFS
// Replication (DFSR), which replicates SYSVOL. Each one is expected to run.
// Runs one PowerShell script that only reads Win32_Service (Name, State). A service is named by its service
// name, the same in every language of Windows; WMI writes State in English whatever the language.
// Windows does not keep the case of a service name the same everywhere: a name is matched whatever its
// case, and given back as written below.
// The script is the one of active-directory/ssh/dc-services, without the powershell -Command "..." that
// cmd.exe needs there.
need('protocol:winrm');

per('service', 'Services');
output('state', 'text', array('label' => 'State', 'per' => 'service'));

watch.expect('stopped', 'Service stopped', 'state', array('critical' => array('running')));
// A domain controller that does not serve DNS takes DNS out of the list on the probe.
watch.missing('missing', 'Service missing', 'state', array(
    'critical' => array('NTDS', 'Netlogon', 'Kdc', 'DNS', 'W32Time', 'DFSR'),
));

$read = winrm.run("[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding; "
    . "ConvertTo-Json -Compress -Depth 4 -InputObject @{"
    . "services = @(Get-CimInstance Win32_Service"
    . " | Where-Object { @('NTDS', 'Netlogon', 'Kdc', 'DNS', 'W32Time', 'DFSR') -contains $_.Name }"
    . " | Select-Object Name, State)}");
$answer = text.trim($read['output']);
if (list.count(text.match($answer, '^\{')) == 0) {
    fail('misconfigured', 'PowerShell did not return the services', $answer . $read['errors']);
}
$read_services = json.read($answer);

$names = array(
    'ntds' => 'NTDS',
    'netlogon' => 'Netlogon',
    'kdc' => 'Kdc',
    'dns' => 'DNS',
    'w32time' => 'W32Time',
    'dfsr' => 'DFSR',
);
// State is "Running", "Stopped", "Start Pending"...: given in lower case, words joined by "-".
$services = 0;
foreach ($read_services['services'] as $service) {
    $services = $services + 1;
    value('state', text.lower(text.join(text.words($service['State']), '-')), $names[text.lower($service['Name'])]);
}
if ($services == 0) {
    fail('misconfigured', 'None of the services of a domain controller is installed', $answer);
}