there is maybe one thing I would modify/change/try.
In your function you are using this three times (Get-DhcpServerDatabase -ComputerName $_.Dnsname)
and this two times (Get-DhcpServerAuditLog -ComputerName $_.Dnsname)
.
Each line will do a new "get-query".
Maybe you like to test the function below. This will run each "get-query" only one time.
function Get-DHCPServersSettings
{
$allDHCP = Get-DhcpServerInDC
$allDHCP | Foreach-Object {
$DHCPServerDB = Get-DhcpServerDatabase -ComputerName $_.Dnsname
$DHCPServerAuditLog = Get-DhcpServerAuditLog -ComputerName $_.Dnsname
[PSCustomObject]@{
Name = $_.DnsName
DBPath = $DHCPServerDB.FileName
BackupPath = $DHCPServerDB.BackupPath
Logging = $DHCPServerDB.LoggingEnabled
AuditState = $DHCPServerAuditLog.Enable
AuditPath = $DHCPServerAuditLog.path
}
}
}
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten