Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Need Help with Advanced Functions

$
0
0

Hell yes it is a nightmare, but that’s the way this place is at times. Just gotta go with the punches. Anyway, I have written a separate advanced function to help me understand how advanced functions work before i get started on the much more involved script that will be adding users to AD groups, then adding them to computer local admin groups and it’s actually working quite well.

The name of test advanced funcction script as well as the name of the advanced function are both “Check-ADUserExist”. Here is the beginning portion of my script:

Function Check-ADUserExist
{
#Requires -Version 3.0
#Requires -Modules ActiveDirectory

[CmdletBinding()]
[OutputType([String])]
Param
(
[Parameter(Position=0,
Mandatory=$true,
HelpMessage="Enter a user name, or type 'userlist' to add multiple users to query in the UserList.txt file")]
[Alias('user')]
[ValidateNotNullOrEmpty()]
[String]
$UserName
)

The problem I am having is that i can basically enter any parameter and it will try to process. What is the best way to tell PowerShell that the only parameter allowed is the -username parameter?

Thanks


Viewing all articles
Browse latest Browse all 13067

Trending Articles