Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Trying to write a script to retrieve servers and users on that each server and paste it in an excel file

$
0
0

Please help me with the script below:

searchOU='ou=DYCD-Servers,dc=dycd,dc=nycnet'

$file = Get-Content C:\scripts\Servers.txt

Get-ADComputer -filter * -SearchBase $searchOU | 

  Foreach-($server in $file{

    $group = $[ADSI]"WinNT://$($_.'WinNT)/(Administrators".psbase.invoke('Members') | 

      ForEach-Object {

            $user = $_.GetType().InvokeMember('Name', 'GetProperty', $null, $_, $null)

 

            New-Object 'PSObject' -property @{'Server'=$server; 'Admin'=$user}

       }

 }


Viewing all articles
Browse latest Browse all 6937

Trending Articles