Based on your function this is how you could get it to work in the way you
seem to want to. Notice the return statement at the end of the function
function create-user{
# Asks the user to input the Account name they wish to create.
$strLogonName = read-host "Enter the users Logon Name, use ** as a
wildcard where you would want the State Code to go"
# Asks the user to input the Domain Suffix of the user.
$strDomainSuffix = read-host "Enter the users Domain Suffix, ex.
@cars.com"
# Asks the user to input the First Name of the user.
$strFirstName = read-host "Enter the users First Name, use ** as a
wildcard where you would want the State Code to go"
# Asks the user to input the Last Name of the user.
$strLastName = read-host "Enter the users Last Name, use ** as a
wildcard where you would want the State Code to go"
# Asks the user to input the Description for the user.
$strDescription = read-host "Enter the users Description, use ** as a
wildcard where you would want the State Code to go"
# Asks the user to input the Password of the user.
$strPassword = read-host "Enter the users Password, use ** as a
wildcard where you would want the State Code to go"
# Asks the user to input the OU Path they wish to create the user in,do not
include the Domain DN.
$strOUPath = read-host "Enter the OU Path. Leave out all domain
specific information, use ## as a wildcard where you would want the
State Code to go"
return $strLogonName, $strDomainSuffix, $strFirstName, $strLastName,
$strDescription, $strPassword, $strOUPath
}
$strLogonName = ""
$strDomainSuffix = ""
$strFirstName = ""
$strLastName = ""
$strDescription = ""
$strPassword = ""
$strOUPath = ""
create-user
$strLogonName = ""
$strDomainSuffix
$strFirstName
$strLastName
$strDescription
$strPassword
$strOUPath
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog:
http://richardsiddaway.spaces.live.com/
PowerShell User Group:
http://www.get-psuguk.org.uk
"bryan.rutkowski@gmail.com" wrote:
> Here is the exact output when I run it.
>
> PS C:\Documents and Settings\bryan.rutkowski> function create-user{
> >>
> >> # Asks the user to input the Account name they wish to create.
> >>
> >> $strLogonName = read-host "Enter the users Logon Name, use ** as a wildcard where you would want the State Code to go
> "
> >>
> >> # Asks the user to input the Domain Suffix of the user.
> >>
> >> $strDomainSuffix = read-host "Enter the users Domain Suffix, ex. @cars.com"
> >>
> >> # Asks the user to input the First Name of the user.
> >>
> >> $strFirstName = read-host "Enter the users First Name, use ** as a wildcard where you would want the State Code to go
> "
> >>
> >> # Asks the user to input the Last Name of the user.
> >>
> >> $strLastName = read-host "Enter the users Last Name, use ** as a wildcard where you would want the State Code to go"
> >>
> >> # Asks the user to input the Description for the user.
> >>
> >> $strDescription = read-host "Enter the users Description, use ** as a wildcard where you would want the State Code to
> go"
> >>
> >> # Asks the user to input the Password of the user.
> >>
> >> $strPassword = read-host "Enter the users Password, use ** as a wildcard where you would want the State Code to go"
> >>
> >> # Asks the user to input the OU Path they wish to create the user in, do not include the Domain DN.
> >>
> >> $strOUPath = read-host "Enter the OU Path. Leave out all domain specific information, use ## as a wildcard where you
> would want the State Code to go"
> >> }
> >>
> PS C:\Documents and Settings\bryan.rutkowski> create-user
> Enter the users Logon Name, use ** as a wildcard where you would want
> the State Code to go: ** Logon Name
> Enter the users Domain Suffix, ex. @cars.com: @cars.com
> Enter the users First Name, use ** as a wildcard where you would want
> the State Code to go: John
> Enter the users Last Name, use ** as a wildcard where you would want
> the State Code to go: Doe
> Enter the users Description, use ** as a wildcard where you would want
> the State Code to go: John Doe
> Enter the users Password, use ** as a wildcard where you would want
> the State Code to go: 12345
> Enter the OU Path. Leave out all domain specific information, use ##
> as a wildcard where you would want the State Code t
> o go: ou=cars
> PS C:\Documents and Settings\bryan.rutkowski> $strlogonname
> PS C:\Documents and Settings\bryan.rutkowski> $strDomainSuffix
> PS C:\Documents and Settings\bryan.rutkowski>
>
> As you can see nothing is set in the variables. Am I doing something
> wrong, or calling them the wrong way?
>
>
>
> On Feb 9, 2:19 pm, RichS <R...@discussions.microsoft.com> wrote:
> > How are you returning this information from your function?
> >
> > I've just tried the function & the variables seem to pick up the input OK
> > --
> > Richard Siddaway
> > Please note that all scripts are supplied "as is" and with no warranty
> > Blog:http://richardsiddaway.spaces.live.com/
> > PowerShell User Group:http://www.get-psuguk.org.uk
> >
> > "bryan.rutkow...@gmail.com" wrote:
> > > I am prompting the user to enter new user information in using Read-
> > > Host. The only problem is, when I run my function and enter the data
> > > in, it doesn't exists, all the variables are null. If I just do each
> > > one, one at a time outside of the function I can get read-host to work
> > > fine. But whenever I try to do more then one at a time it doesn't
> > > work at all. Below is my code. So once I run the function create-
> > > user and try to get the data in any of the variables (ex.
> > > $strLogonName) they are all ways null. Does anyone have any ideas?
> >
> > > function create-user{
> >
> > > # Asks the user to input the Account name they wish to create.
> >
> > > $strLogonName = read-host "Enter the users Logon Name, use ** as a
> > > wildcard where you would want the State Code to go"
> >
> > > # Asks the user to input the Domain Suffix of the user.
> >
> > > $strDomainSuffix = read-host "Enter the users Domain Suffix, ex.
> > > @cars.com"
> >
> > > # Asks the user to input the First Name of the user.
> >
> > > $strFirstName = read-host "Enter the users First Name, use ** as a
> > > wildcard where you would want the State Code to go"
> >
> > > # Asks the user to input the Last Name of the user.
> >
> > > $strLastName = read-host "Enter the users Last Name, use ** as a
> > > wildcard where you would want the State Code to go"
> >
> > > # Asks the user to input the Description for the user.
> >
> > > $strDescription = read-host "Enter the users Description, use ** as a
> > > wildcard where you would want the State Code to go"
> >
> > > # Asks the user to input the Password of the user.
> >
> > > $strPassword = read-host "Enter the users Password, use ** as a
> > > wildcard where you would want the State Code to go"
> >
> > > # Asks the user to input the OU Path they wish to create the user in,
> > > do not include the Domain DN.
> >
> > > $strOUPath = read-host "Enter the OU Path. Leave out all domain
> > > specific information, use ## as a wildcard where you would want the
> > > State Code to go"
> > > }
>
>
>