So I have made a little GUI tool to Create a "privileged Super Account" well I am setting variables that gets information from their Standard Account and then using those to set on the new account. For every Button.add_click I have to type out the load of variables I have set for each domain.
I was trying to create a function where it would get the variables and then make it simple by calling the function to reduce my code. example:
FunctionGet-AccountInfo {
$Fullname = (get-aduser$textfield1.text).name
$Firstname = (Get-ADUser$textfield1.text).givenname
$Lastname = (Get-ADUser$textfield1.text).Surname
$button1.add_click({
Get-AccountInfo
New-QADUser-ParentContainer"BLAH" `
-Name $("Super"+$textfield1.text) `
-SamAccountName $("Super"+$textfield1.text) `
-FirstName$Firstname `
-LastName$Lastname `
}
Well that isn't working for me, so I tried this:
FunctionGet-AccountInfo {
$Fullname = (get-aduserUser).name
$Firstname = (Get-ADUserUser).givenname
$Lastname = (Get-ADUserUser).Surname
}
Get-accountinfo
$Fullname
Why cant I set variables in a function and simple use that function to call on those variables, When I try this, during the New-QADUSER part, it simple doesn't read the variables and doesn't populate the attributes that I am specify.
Sorry if I am doing a bad job of explaining this.