Lokale Administratoren aller Domänen Computer auflisten – Powershell

Möchte man eine Übersicht aller lokalen Administratoren-Konten / -Gruppen der Computer innerhalb einer Domäne erhalten, kann man das via Powershell Skript automatisiert laufen lassen. Das Ergebnis ist entweder in der Konsole sichtbar oder kann via Out-file in eine Datei geschrieben werden. Für das Skript wird das Active Directory Modul benötigt.

[fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”]

function get-adminmember-ofall{
$searchOU='ou=06computergruppen,dc=example,dc=local'
$anz_comp = Get-ADComputer -filter * -SearchBase $searchOU
$anz_comp = $anz_comp.count
$i=1
Get-ADComputer -filter * -SearchBase $searchOU|
     Foreach-Object{
			write-host "$i von $anz_comp"
			$server=$_.Name
			if(Test-Connection $_.Name -q){
				$i++
                Write-Host "Ueberpruefe $server" -fore green
                ([ADSI]"WinNT://$server/Administratoren").psbase.invoke('Members') |
                ForEach-Object{
                     $member=$_.GetType().InvokeMember('Name', 'GetProperty', $null, $_, $null)
                     New-Object PSObject -Property @{Server=$server;Account=$member}
                }
			}else{
				$i++
                Write-Host "$server - keine Verbindung" -fore red
           }
     }
}

lokale admins[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s