I want to write a little Tool like a little CLI where I can get Informations out of our AD-Domain. I have that function (listed below) which works but I want it not to ask me the Parameter in the second place. The Goal is to let the Tool run in a Loop where I can type the Function-Shortcuts with given Parameter like "Username"
ListUserInformation -Username "Firstname, Lastname" (Something like that.) I tryed double and single quotes but it keeps asking in the next line about a Username. Can some1 help me with that? Here is the Function:
function ListUserInformation {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)][String]$Username
)
$target = $Username
$x = Get-ADUser -Filter "CN -like '$target'" -SearchBase $SearchBase -Properties CN,Title,SamAccountName,emailaddress,officephone | Out-String
Select-Object CN,Title,SamAccountName,emailaddress,officephone
write-host $x }
| Out-Stringand also make a second parameter for the$SearchBasevariable.