Get-LocalAdminGroupMember.ps1

This is a sample script that shows how to use WMI retrieve members of the local Administrators group on one or more computers. This script uses the group's SID (S-1-5-32-544) rather than the English name 'Administrators'.

 
 
 
 
 
(0)
3,308 times
Add to favorites
7/19/2017
E-mail Twitter del.icio.us Digg Facebook
  • Can't get the 4th example to work
    2 Posts | Last post July 31, 2014
    • Hi Bill,
      
      I'm not great a PowerShell, but am finding I am using it more and more in my day to day work.  I have come across your script as I need to fid the Local Admin group members and have a text file of computers in my environment. However, when I run
      
      PS T:\Scripts> Get-Content ComputerName.txt | Get-LocalAdminGroupMember -BlockSize 20
      
      I get the following error:
      
      et-LocalAdminGroupMember : The term 'Get-LocalAdminGroupMember' is not recognized as the name of 
      a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path 
      was included, verify that the path is correct and try again.
      At line:1 char:32
      + Get-Content ComputerName.txt | Get-LocalAdminGroupMember -BlockSize 20
      +                                ~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : ObjectNotFound: (Get-LocalAdminGroupMember:String) [], CommandNotFou 
         ndException
          + FullyQualifiedErrorId : CommandNotFoundException
      
      If I wrap the whole in 'function Get-LocalAdminGroupMember () {...}' it won't accept the Get-Content cmdlet as an Input parameter. 
      
      As I say, I am relatively in-experienced at PowerShell and would appreciate any help you can give on this.
      Thanks
      Tony
    • Get-LocalAdminGroupMember.ps1 has to be in a directory in your path. If it's in the current directory, you have to write ".\GetLocalAdminGroupMember" instead of just "GetLocalAdminGroupMember".
      
      This article may be helpful: http://windowsitpro.com/powershell/running-powershell-scripts-easy-1-2-3