Powershell Script to List an Account by "name description" in Windows AD
I need an example of a PowerShell script or a script that will list all accounts on a domain that begin with the letter 'b'. If any one has an example or a script in your repository that could help me with the problem I would greatly appreciate your support. Any examples will be extremely helpful.
Thank you. I am testing your recommendation now. I am new to PowerShell, but have experience with other programming languages. I will let you know what results I experience.
Thank you tremendously for your support.
Lipotech
lipotech
ASKER
Will,
How can I determine if these 'b' accounts are connect to a windows service?
Lipotech
Will Szymkowski
Unfortunately you will not be able to verify this. The script simply retrieves all of the Accounts that have a "B" that is the first character.
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.
PS C:\Users\bobbbatt01> import-module activedirectory
import-module : The specified module 'activedirectory' was not loaded because no valid module file was found in any
module directory.
At line:1 char:1
+ import-module activedirectory
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (activedirectory:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\Users\bobbbatt01> import-module activedirectory
import-module : The specified module 'activedirectory' was not loaded because no valid module file was found in any
module directory.
At line:1 char:1
+ import-module activedirectory
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (activedirectory:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\Users\bobbbatt01> Get-ADUser -Filter {name -like "B*"} -Properties name, samaccountname | select name, samaccountn
ame
Get-ADUser : The term 'Get-ADUser' 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:1
+ Get-ADUser -Filter {name -like "B*"} -Properties name, samaccountname | select n ...
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-ADUser:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Open in new window
Will.