redman20111
asked on
List of server admin groups using Powershell
Hi
I have a couple of servers running Windows 2008 Server, they are running various applications for our company.
Within each server there is the Administrator group and also some specific (local) groups for our company:
ITAdmins
Helpdesk Admins
Vendors
Every week, I would like to run a script that will pull the membership of the local groups on the server. I have an admin server running Powershell 2 and I was thinking of using this.
Please note, the groups I mentioned above aren't Domain Security/Distribution Groups within Active Directory, they are local groups on the servers themselves.
Thanks in advance for any assistance.
I have a couple of servers running Windows 2008 Server, they are running various applications for our company.
Within each server there is the Administrator group and also some specific (local) groups for our company:
ITAdmins
Helpdesk Admins
Vendors
Every week, I would like to run a script that will pull the membership of the local groups on the server. I have an admin server running Powershell 2 and I was thinking of using this.
Please note, the groups I mentioned above aren't Domain Security/Distribution Groups within Active Directory, they are local groups on the servers themselves.
Thanks in advance for any assistance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, but these are local groups (i.e. not Domain Groups), so why are we using ADSI?
[ADSI] is the adapter, that establishes the connection to "WinNT://..." for local
ASKER
Hi x-men thanks for your solution (copied below)...but are you able to explain how it works for me?
$hostnames = get-content c:\hostnames.txt
foreach ($hostname in $Hostnames) {"$hostname`tITAdmins`t$(( [ADSI]"Win NT://$host name/ITAdm ins,group" ).psbase.I nvoke("Mem bers") | % {$_.GetType().InvokeMember ("Name",'G etProperty ',$null,$_ ,$null)})
$hostname`t"Helpdesk Admins"`t$(([ADSI]"WinNT:/ /$hostname /"Helpdesk Admins",group").psbase.Inv oke("Membe rs") | % {$_.GetType().InvokeMember ("Name",'G etProperty ',$null,$_ ,$null)})
$hostname`t Vendors`t$(([ADSI]"WinNT:/ /$hostname /Vendors,g roup").psb ase.Invoke ("Members" ) | % {$_.GetType().InvokeMember ("Name",'G etProperty ',$null,$_ ,$null)})
" }
$hostnames = get-content c:\hostnames.txt
foreach ($hostname in $Hostnames) {"$hostname`tITAdmins`t$((
$hostname`t"Helpdesk Admins"`t$(([ADSI]"WinNT:/
$hostname`t Vendors`t$(([ADSI]"WinNT:/
" }
Foreach ($Hostname in $hostnames) {
([ADSI]"WinNT://$Hostname/
% {$_.GetType().InvokeMember
([ADSI]"WinNT://$Hostname/
% {$_.GetType().InvokeMember
([ADSI]"WinNT://$Hostname/
% {$_.GetType().InvokeMember
}