14634
Dec 14, 2010
2693
1
0
Script Listet nur 522 Rechner auf!
Hallo, habe mir ein Powerpack von Powergui runtergeladen und nun das problem, dass das Script mir nur 522 Rechner auflistet.
Ich habe aber wessentlich mehr Pc`s.
Kann mir hier evt jemand helfen?
Anbei der Code:
#region Get the current PowerPack configuration.
$configuration = Get-WindowsSecurityPowerPackConfiguration
#endregion
#region Connect if we're not already connected.
$configuration.Connect()
#endregion
#region Set the data object on the current node.
Set-AdminConsoleNodeData -AssociatedObject @{'Connection'=$configuration.Connection}
#endregion
#region Check the current domain mode to see if all DCs need to be checked.
[bool]$checkAllDCs = ($configuration.Connection.Domain.DomainMode -le 'Windows2003Domain')
#endregion
#region Retrieve the computer accounts with their last logon information.
$otherParameters = @{
IncludedProperties = @('LastLogon')
LdapFilter = '(!(lastLogon=0))'
pagesize = $configuration.DefaultPageSize
SizeLimit = $configuration.DefaultSizeLimit
ErrorAction = 'SilentlyContinue'
}
switch ($configuration.ComputerRolesToSearch) {
'Workstations' {
$otherParameters['LdapFilter'] = "(&(!(operatingSystem=*Server*))$($otherParameters['LdapFilter']))"
break
}
'Member Servers' {
$otherParameters['LdapFilter'] = "(&(operatingSystem=*Server*)(isCriticalSystemObject=FALSE)$($otherParameters['LdapFilter']))"
break
}
'Member Servers and Workstations' {
$otherParameters['LdapFilter'] = "(&(isCriticalSystemObject=FALSE)$($otherParameters['LdapFilter']))"
break
}
'Domain Controllers' {
$otherParameters['LdapFilter'] = "(&(isCriticalSystemObject=TRUE)$($otherParameters['LdapFilter']))"
break
}
'Domain Controllers and Workstations' {
$otherParameters['LdapFilter'] = "(&(|(isCriticalSystemObject=TRUE)(!(operatingSystem=*Server*)))$($otherParameters['LdapFilter']))"
break
}
'Domain Controllers and Member Servers' {
$otherParameters['LdapFilter'] = "(&(operatingSystem=*Server*)$($otherParameters['LdapFilter']))"
break
}
default {
break
}
}
if (-not $configuration.IncludeDisabledAccounts) {
$otherParameters['LdapFilter'] = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))$($otherParameters['LdapFilter']))"
}
if ($configuration.UseGlobalCatalog) {
$otherParameters['UseGlobalCatalog'] = $true
}
if ($configuration.ConnectionAccount) {
$otherParameters['Credential'] = Get-Credential -Credential $configuration.ConnectionAccount
}
$computerSearchRoots = $configuration.ComputerOUsToSearch
if (-not $computerSearchRoots) {
$computerSearchRoots = @($configuration.Connection.DefaultNamingContext.DN)
}
$dcCount = 0
Write-Progress -Activity 'Searching Active Directory' -Status 'Retrieving discoverable domain controllers.'
$configuration.Connection.Domain.FindAllDiscoverableDomainControllers() `
| ForEach-Object {
try {
Write-Progress -Activity 'Searching Active Directory' -Status "Searching for computer account last logon information on $($_.Name)."
$dcCount++
foreach ($searchRoot in $computerSearchRoots) {
Get-QADComputer -SearchRoot $searchRoot -Service $_.Name @otherparameters
}
}
catch {
Write-Warning $_.Exception.Message
}
} `
| Group-Object -Property dn `
| Where-Object {$_.Count -eq $dcCount} `
| ForEach-Object {
$_.Group `
| Sort-Object -Property LastLogon -Descending `
| Select-Object -First 1 `
| Add-Member -MemberType AliasProperty -Name Disabled -Value AccountIsDisabled -PassThru `
| Add-Member -MemberType ScriptProperty -Name Role -Value {if ($this.ComputerRole -eq 'DomainController') {'Domain Controller'} elseif ($this.operatingSystem -match 'Server') {'Member Server'} else {'Workstation'}} -PassThru
}
Write-Progress -Activity 'Searching Active Directory' -Status 'Search complete.' -Completed
#endregion
Ich habe aber wessentlich mehr Pc`s.
Kann mir hier evt jemand helfen?
Anbei der Code:
#region Get the current PowerPack configuration.
$configuration = Get-WindowsSecurityPowerPackConfiguration
#endregion
#region Connect if we're not already connected.
$configuration.Connect()
#endregion
#region Set the data object on the current node.
Set-AdminConsoleNodeData -AssociatedObject @{'Connection'=$configuration.Connection}
#endregion
#region Check the current domain mode to see if all DCs need to be checked.
[bool]$checkAllDCs = ($configuration.Connection.Domain.DomainMode -le 'Windows2003Domain')
#endregion
#region Retrieve the computer accounts with their last logon information.
$otherParameters = @{
IncludedProperties = @('LastLogon')
LdapFilter = '(!(lastLogon=0))'
pagesize = $configuration.DefaultPageSize
SizeLimit = $configuration.DefaultSizeLimit
ErrorAction = 'SilentlyContinue'
}
switch ($configuration.ComputerRolesToSearch) {
'Workstations' {
$otherParameters['LdapFilter'] = "(&(!(operatingSystem=*Server*))$($otherParameters['LdapFilter']))"
break
}
'Member Servers' {
$otherParameters['LdapFilter'] = "(&(operatingSystem=*Server*)(isCriticalSystemObject=FALSE)$($otherParameters['LdapFilter']))"
break
}
'Member Servers and Workstations' {
$otherParameters['LdapFilter'] = "(&(isCriticalSystemObject=FALSE)$($otherParameters['LdapFilter']))"
break
}
'Domain Controllers' {
$otherParameters['LdapFilter'] = "(&(isCriticalSystemObject=TRUE)$($otherParameters['LdapFilter']))"
break
}
'Domain Controllers and Workstations' {
$otherParameters['LdapFilter'] = "(&(|(isCriticalSystemObject=TRUE)(!(operatingSystem=*Server*)))$($otherParameters['LdapFilter']))"
break
}
'Domain Controllers and Member Servers' {
$otherParameters['LdapFilter'] = "(&(operatingSystem=*Server*)$($otherParameters['LdapFilter']))"
break
}
default {
break
}
}
if (-not $configuration.IncludeDisabledAccounts) {
$otherParameters['LdapFilter'] = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))$($otherParameters['LdapFilter']))"
}
if ($configuration.UseGlobalCatalog) {
$otherParameters['UseGlobalCatalog'] = $true
}
if ($configuration.ConnectionAccount) {
$otherParameters['Credential'] = Get-Credential -Credential $configuration.ConnectionAccount
}
$computerSearchRoots = $configuration.ComputerOUsToSearch
if (-not $computerSearchRoots) {
$computerSearchRoots = @($configuration.Connection.DefaultNamingContext.DN)
}
$dcCount = 0
Write-Progress -Activity 'Searching Active Directory' -Status 'Retrieving discoverable domain controllers.'
$configuration.Connection.Domain.FindAllDiscoverableDomainControllers() `
| ForEach-Object {
try {
Write-Progress -Activity 'Searching Active Directory' -Status "Searching for computer account last logon information on $($_.Name)."
$dcCount++
foreach ($searchRoot in $computerSearchRoots) {
Get-QADComputer -SearchRoot $searchRoot -Service $_.Name @otherparameters
}
}
catch {
Write-Warning $_.Exception.Message
}
} `
| Group-Object -Property dn `
| Where-Object {$_.Count -eq $dcCount} `
| ForEach-Object {
$_.Group `
| Sort-Object -Property LastLogon -Descending `
| Select-Object -First 1 `
| Add-Member -MemberType AliasProperty -Name Disabled -Value AccountIsDisabled -PassThru `
| Add-Member -MemberType ScriptProperty -Name Role -Value {if ($this.ComputerRole -eq 'DomainController') {'Domain Controller'} elseif ($this.operatingSystem -match 'Server') {'Member Server'} else {'Workstation'}} -PassThru
}
Write-Progress -Activity 'Searching Active Directory' -Status 'Search complete.' -Completed
#endregion
Please also mark the comments that contributed to the solution of the article
Content-Key: 156949
Url: https://administrator.de/contentid/156949
Printed on: May 4, 2024 at 16:05 o'clock
1 Comment