Server Local Group Auditing Question

This script is modified from web to perform auditing of local server groups 
and their members.  Since I have to do this on a large number of servers I 
would like the results written to a Access Database instead of on large text 
file.  Since I am fairly new to powershell and scripting I dont know how to 
do this.  Any assistance would be greatly appreciated.


########################
#Functions
########################
$arrExclude = "NT AUTHORITY\LocalService",
            "NT AUTHORITY\Local Service",
            "NT AUTHORITY\NETWORK SERVICE",
            "NT AUTHORITY\NetworkService",
            "LocalSystem",
            ".\ASPNET" 

function checkExclusions([string]$strval)
    {
    foreach ($val in $arrExclude)
        {if ($val.ToLower() -eq $strval){return $true}  }
    return $false
    }

function Ping (  [string] $strComputer )
{
  $timeout=120;
  trap { continue; }

  $ping = new-object System.Net.NetworkInformation.Ping
  $reply = new-object System.Net.NetworkInformation.PingReply

  $reply = $ping.Send($strComputer, $timeout);
  if( $reply.Status -eq "Success"  )
  {
     return $true;
  }
  return $false;
}

########################
#Script
########################
$pathFolder = "D:\ServerBiYearlyScan\CRB\Group"
$computersList = get-content "$pathFolder\CRBServer001.txt"
$ArrayUser = @()
$ArrayGroup = @()
$ArrayKey = @()
$ArrayService = @()
$ArrayShare = @()
$ArrayAccess = @() 

foreach($computer in $computersList)
{

#################################################################################################
$retPing = Ping $computer
if($retPing -eq $true)
    {
    #Disabling the error on the screen
    $errorActionPreference="SilentlyContinue"
    $testAccss = get-wmiobject Win32_OperatingSystem -computername $computer 
-ErrorVariable ERR
        If($ERR)
            {$Access = $false}
        else{$Access = $true}
    }
else{$Access = $false}

if($Access -eq $false)
    {
    #Srv not ping or denied
    $obj=New-Object PSObject
    $obj | Add-Member Noteproperty -Name "ServerName" -Value 
(($computer).trim()).ToUpper()
    $obj | Add-Member Noteproperty -Name "PING" -Value $retPing
    $obj | Add-Member Noteproperty -Name "ACCESS" -Value $Access
    $ArrayAccess += $obj
    }
else{
    #Working on it

#################################################################################################

$namespace = "root\CIMV2"
$results = Get-WmiObject -class Win32_Group -computername $computer 
-namespace $namespace -filter "localaccount=true"
foreach($result in $results)
    {
   
    $GroupName = $result.name
    $group =[ADSI]"WinNT://$computer/$GroupName"
    $members = @($group.psbase.Invoke("Members"))
    $list = $members | foreach {$_.GetType().InvokeMember("Name", 
'GetProperty', $null, $_, $null)}
    if($list -ne $null)
        {
        foreach($member in $list)
            {
           
            $obj=New-Object PSObject
            $obj | Add-Member Noteproperty -Name "ServerName" -Value 
(($computer).trim()).ToUpper()
            $obj | Add-Member Noteproperty -Name "GroupName" -Value 
(($result.name).trim()).ToUpper()
            $obj | Add-Member Noteproperty -Name "Member" -Value 
(($member).trim()).ToUpper()
            $ArrayGroup += $obj
            }
        }
    else
        {
        $obj=New-Object PSObject
        $obj | Add-Member Noteproperty -Name "ServerName" -Value 
(($computer).trim()).ToUpper()
        $obj | Add-Member Noteproperty -Name "GroupName" -Value 
(($result.name).trim()).ToUpper()
        $obj | Add-Member Noteproperty -Name "Member" -Value ""
        $ArrayGroup += $obj
        }

    }

#################################################################################################

    }

}

$ArrayGroup | select ServerName, GroupName, Member | out-file 
"$pathFolder\CRBLocalGroups001.txt"


-- 
Tim Dixon
0
Utf
6/28/2010 3:05:40 PM
windows.powershell 690 articles. 0 followers. Follow

1 Replies
1505 Views

Similar Articles

[PageSpeed] 54

Search is your friend.  As the PowerShell community continues to grow, 
chances are that you'll find something already written to help.

I searching for "powershell access database" with bing.com, and one of the 
first hits:
http://technet.microsoft.com/en-us/magazine/2009.05.scriptingguys.aspx?pr=blog

Take a read at that first.  Come back if you still have any questions.

Marco

"Tim Dixon" <TimDixon@discussions.microsoft.com> wrote in message 
news:787EE63D-E6C4-4B51-BB0C-9C4440BC4369@microsoft.com...
> This script is modified from web to perform auditing of local server 
> groups
> and their members.  Since I have to do this on a large number of servers I
> would like the results written to a Access Database instead of on large 
> text
> file.  Since I am fairly new to powershell and scripting I dont know how 
> to
> do this.  Any assistance would be greatly appreciated.
 

0
Marco
6/28/2010 10:21:28 PM
Reply:

Similar Artilces:

NO DEFAULT SMTP SERVER..
Hello, I had a problem with exadmin.dll, unregistered it, copied new one and registered it and now the default smtp server is gone under SMTP in my systems manager but everything still works.... HELP where is it ? and how can i get it back ? tnnx. Philippe ...

Upgrading from server 2000 to server 2008R2?
We would like to upgrade our servers to Windows server 2008 R2. Currently we have two Windows 2000 (SP 4) domain controllers, we want to replace the Forest Root Domain box with new hardware & upgrade the other DC to server 2008 R2. I understand it's not possible to upgrade from 2000 straight to 2008 but is server 2003 still available to ugrade to in between? I'm also not sure of what the implications of retiring the Forest Root Domain box would be? Would the best plan be to add the new 2008 server (domain function & forest function level: 2000); upgrade the se...

MS Project Server Admin // Denver, CO
MS Project Server Admin Location: Denver, CO Duration: 6 months Pay Rate: DOE =95 MSProject Server ver 2010, SQL database and Sharepoint 2010 =95 Ongoing support and maintenance involving activities such as =96 Monitoring logs, Patches, resolving support tickets, Dev/Test/Prod support =95 Routine troubleshooting =95 Technical APS maintenance (Project Server & SharePoint 2010) =95 User administration / Password resets etc. =95 Work with Microsoft for any critical issues that might need intervention from Microsoft =95 Application of Patches & migration to Production =95 SQL services mo...

Can Recovery Storage Groups be used if original server gone?
We had an Exchange server die on us a few months back due to hardware issues. All accounts were moved to another box and that one was flattened and taken out of the Exchange org. It was replaced by new hardware that does NOT have the storage groups or databases that the old one did. We have a request to recover data from an info store back up prior to the events above and are running into problems with our backup vendor. Would it be possible to use a Recovery Storage Group to retrieve this data? The mailbox still exists (but may have been moved via Exmerge) so I believe I will pas...

Question #2
Is there a way to use the sumif function in regards to a cell's format? For example, I want to sum all cells that are filled in red. Hi Tom! Try a visit to Chip Pearson's site for this issue: Chip Pearson: http://www.cpearson.com/excel/colors.htm Here's an extract that covers what you want: Start Extract>> The following function will return the sum of cells in a range that have either an Interior (background) or Font of a specified color. InRange is the range of cells to examine, WhatColorIndex is the ColorIndex value to count, and OfText indicates whether to return ...

Removed server, exchange still looking for it?
Exchange 5.5, I removed a server from the site using exchange admin, and now am getting event 9318, saying MTA can't contact it. Why is it doing that? I had the same problem after a 5.5 to 2000 migration. Rebooting the Exchange server that was trying to connect resolved the problem. MTA must keep the information cached. Tim "dlw" <dlw@discussions.microsoft.com> wrote in message news:C431500C-F78D-47E5-AAC5-B8C611592E97@microsoft.com... > Exchange 5.5, I removed a server from the site using exchange admin, and > now > am getting event 9318, saying MTA can...

Small Business Server in Windows Server 2000 Environment
I have a requirement to install Microsoft CRM for about 10 CRM Users. The existing Windows 2000 has about 120 users with two Exchange Servers. Is it possible to set up a separate Small Business Server to run CRM within the Windows 2000 domain as this is the most cost effective way of implementing CRM for such a low User count? ...

Project Cost Categories grouped by Phase
Cost Categories assigned to projects should be able to be grouped by phase. One way to make this possible is to add a Phase or user-defined field to the PA Budget Master (PA01301) table. You might consider Extender since I don't think PA is going to be rewritten to have phases any time soon. "Lisa Williams" <LisaWilliams@discussions.microsoft.com> wrote in message news:D4B7D465-CF0A-45BC-B7BF-F7012046FBDD@microsoft.com... > Cost Categories assigned to projects should be able to be grouped by > phase. > One way to make this possible is to add a Phase or use...

NameTable questions
Hello, is there a way to disable or reset the entries in a NameTable? Background is that is that i create small XmlElements and send them over the wire with a TCP connection. I can't create XmlElements without having a document. The XmlElements are only created, but never added to the document. After i sent them they get disposed. In my code will be lots of classes derived from Element which help me building my XML. The problem here is that the NameTable blows up with each XmlElement i create. Of course i could inherit all my classes from XmlDocument to solve this issue. But the d...

windows 2008 server cord and windows 2008 std
we have 20+ New server to install windows 2008 for trading purpose. still can not decide to install server core or std full, can someone advise what is the benefit to install core rather than std edition or to install std edition ? DD, There is: Server Standard Server Standard Core Server Enterprise Server Enterprise Core Core is (not quite correctly called) 'Server without Graphical User Interface (GUI)'. There are several reasons why Core was introduced: - *Nix purists were saying that there's no real need/use for GUI on a server and *real* sysadmins ar...

Help with Report Grouping
If I have 2 sections in a report like this: Reviewer Header Vendor Header Detail Vendor Footer Reviewer Footer with a txtbox in each section. I want the txtbox in the Vendor Footer to calculate the total for each Vendor and I want the txtbox in the Reviewer Footer to sum up all the values in the Vendor Footer and put it in the txtbox of the Reviewer Footer. Is this possible? If so, how would I do this? Thank you. Ayo wrote: >If I have 2 sections in a report like this: > >Reviewer Header >Vendor Header >Detail >Vendor Footer >Reviewer Footer > > with a txtbox...

question about restoring an exchange 5.5 priv.edb
Exchange 5.5(SP4) server is running on a Windows 2000(SP 4) server in my domain. I used Windows 2000 NTBACKUP to do an online backup to file. What I need to do is restore this online backup to a different server to recover a mailbox. I created a recovery server and installed Exchange 5.5(SP4) to it as a new site using the same site and organization as my original server. When I try to use NTBACKUP on the recovery server to restore the online backup file, it will not let me change server to restore to my new recovery server. It is grayed out with my original server's name. What can ...

Outlook won't leave messages on the server
I have tried and tried to keep Outlook 2003 from deleting my email off my server. I have found the check box under advanced send\receive setting in "options" and I have tried variations of the 3 check boxes in this window and they work until I close Outlook and reopen it, then all of my settings return to the default of deleting my email off the server. Wasn't MS suppose to stop doing things like this? Any help in steering me to the answer (which i am sure is here) to this question is appreciated. Regards Paul A. Walters Hi, Goto Tools --> Email Accounts --> V...

Basic questions about Personal vs. Offline folders
I've done some reading and research but cannot seem to find a concise solution to my dilema. I use a Microsoft Exchange server for Outlook. 1. I would like to be able to read my mail offline when I don't have access to the server 2. I would also like to be able to limit the amount of mail on the server. >From what I have read, Offline folders would be a good solution for #1 but not for #2, because offline folders need to be sync'ed with the server from time to time. Personal folders sound like a solution to #2 but not to #1. Am I misinformed? Is there a solution that will sat...

Shapes Stencils Question
Greetings, I am running Visio 2003. Is there a simple way to rearrange the order of the stencils? I would like to place those used most above the others in rank order. I have looked and searched, however, have found no help. Drag and drop seems to work somewhat, however, creates a mess which I can't use. Thanks in advance for your help! Hi Ray, You can probably drag them all out of their docked position, then re-dock them in the order that you want. You'll probably have to save the document as a new template (ie: Ray Flowchart.vst) to get the settings to stick. -- Hope t...

Project Server Provisioned
Hello, I have provisioned Project Server and added it to the trusted zone, but it still comes up unresolved. Hello, You mean PWA home page is not loading or issue with connecting from MS Project Professional? Also mention the version of Project Server. Thanks Chak pVector Technologies http://www.pvectortech.com http://www.epmcentral.com On Apr 16, 11:04=A0am, me <mtyso...@yahoo.com> wrote: > Hello, I have provisioned Project Server and added it to the trusted > zone, but it still comes up unresolved. On Apr 16, 12:20=A0pm, Chak <chak...@hotmail.com>...

OT: SVN server
Hi, Sorry for the OT, I am not 100% sure where to ask. I want to setup a subversion repo on a personal website. Would anyone know the best forum/NG to ask such a question? (Or where I could find a tutorial for installing such a repo). Thanks Simon Simon wrote: > Hi, > > Sorry for the OT, I am not 100% sure where to ask. > > I want to setup a subversion repo on a personal website. > Would anyone know the best forum/NG to ask such a question? > (Or where I could find a tutorial for installing such a repo). > > Thanks > > Simon ...

Home Group
I created a home group on my main PC and it is visible on my laptop. However on the Laptop using Explorer the main PC is not visible. Both PC's are running Windows 7 Ultimate. What should I do? "topcat" <topcat@discussions.microsoft.com> wrote in message news:3E46DBC6-E7D3-4997-91D8-7C8A0358D099@microsoft.com... > I created a home group on my main PC and it is visible on my laptop. > However > on the Laptop using Explorer the main PC is not visible. Both PC's are > running Windows 7 Ultimate. What should I do? Post in a group for Windo...

Data Import/ Data Map Questions
Hello, I am developing a solution that will allow various new and updated entities to be loaded from several source systems into a Microsoft Dynamics 4.0 installation on an ongoing basis. There are some up- front components to the solution that detect new/changed source system data that are custom but I wanted to be able to use the built-in Data Import facilities within 4.0 to take the data from Excel files and load it into the CRM. I've looked at the sample code in the SDK and have been able to write code that will do this, including use of Picklist and Lookup (ie parent account) type ...

Another Excel11.xlb Question
I have run across another problem customizing the main Menu but found a way to solve it. My questions are about understanding what happened. Before I tried to customize the menu, there was no Excel11.xlb file in my user/Application Data folder. (I am 99% sure of that.) It was in XLSTART I think. I made a change and exited Excel. Now there was new xlb file in my user/Application Data folder. When I opened Excel again, the menu reflected the change briefly and then reverted to the menu defined in the XLSTART Excel11.xlb. My changed menu didn't 'stick.' I removed the XLSTA...

Windows Server 2008 RC2 in Windows Server 2003 Domain
I'm having trouble with one domain controller that has all of the FSMO roles (I have 6 Domain controllers in total running server 2003) I updated my schema to version 47 (Windows server 2008 RC2) and would like to add a new physical server with W2K8 R2 on it and transfer all of the FSMO roles on it. I don't want to upgrade all DC's yet to 2008 R2 yet, so the domain functional level will stay the same for a while (Windows Server 2003). Is there anything I should watch out for with this scenario? Or by just adding a W2k8 R2 box with all the FSMO roles and then decomm...

Exchange Router setup/Setting More than one Exchange Server up in one organisation with two active directories?
Forgive the version difference, but on Exchange 2003 is there a way to install a secondary Exchange Server on a different domain and somehow have it routed to from the other domain or act as a connector to be able to see those emails without removing them? I don't know enough about routing on Exchange to figure if its capable. Or perhaps I need to utilise a different registered email domain and I should use this for testing instead of trying to somehow route emails from one to the other? eg instead of companyname.com I could use companynamecrm.com or something. Would I still want to setu...

pop3 server response
When opening outlook recently it has been saying my pop3 server hasn't respoded in 60 seconds and asks if I would like to wait longer for the server to respond. but sometimes it goes right through. is there any reason why this might be happening. i can only get e-mail about 60% of the time. any help would be greatly appreciated. J.H. Try removing and reinstalling your mail account settings. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the Swen virus, all e-mails sent to my actual account will be deleted w/out reading. After...

E-Mail Messages Reappear When Server is rebooted
Hello All, I had reason to reboot a windows2003 SBS a few months ago. When it rebooted clients reported old emails had reappeared in their inbox. I was then on a windows2000 SBS site yesterday and when I rebooted the server old emails reappeared. The Windows2003 server rebooted today and again old email reappear. I cannot find any info on web re: this problem. Any help would be appreciated. Sam wrote: > Hello All, > > I had reason to reboot a windows2003 SBS a few months ago. When it > rebooted clients reported old emails had reappeared in their inbox. I > was then on...

Manually run message rules on the server
Hi, Is there a way to run message rules (created by the end-user on Outlook) on the server, say on a daily basis ? The reason is that that person has ~50 rules, moving all incoming messages from his inbox to specific folders. Since he now owns a BES-enabled BlackBerry, these rules prevent him from getting his emails onto his handheld. The idea would be to run all the rules once a day, on his behalf, on the server. Exchange 2007 SP1 Thanks Christian Some rules, like moving messages to another folder in the same mailbox, will run server-side by default, depending on how they're create...