Dustin Wade
asked on
Trouble making o365 user using text inputs to create new variables.
Working on a script that creates an o365 user via powershell and it's breaking when I try to append or combine text inputs to make new variables.
The following is supposed to take the inputs from the textbox input '$o365UserFirst.text', '$o365UserLast.text' and merge them into a $displayname for use later, then take the textbox input '$o365useralias.text' and add the domain at the end for use later. Then finally it uses the text inputs to make a new mailbox, but it errors out with a "Cannot bind argument ot parameter 'MicrosoftOnlineServicesID ' because it is null" error. For some reason the first bits appear to be creating empty variables. This obviously isn't the entire script, but just the broken part.
$displayname = ($O365UserFirst.text + " " + $O365UserLast.text)
$O365UserEmail = ($O365UserAlias.text + "@domain.com")
New-Mailbox -Alias $O365UserAlias.Text -Name $O365UserAlias.Text -FirstName $O365UserFirst.Text -LastName $O365UserLast.Text -DisplayName $displayname -MicrosoftOnlineServicesID $0365UserEmail -Password (ConvertTo-SecureString -String $O365UserPassword -AsPlainText -Force)
$Results.AppendText("`r`n" )
$Results.AppendText("User Mailbox Created... Continuing Script")
The following is supposed to take the inputs from the textbox input '$o365UserFirst.text', '$o365UserLast.text' and merge them into a $displayname for use later, then take the textbox input '$o365useralias.text' and add the domain at the end for use later. Then finally it uses the text inputs to make a new mailbox, but it errors out with a "Cannot bind argument ot parameter 'MicrosoftOnlineServicesID
$displayname = ($O365UserFirst.text + " " + $O365UserLast.text)
$O365UserEmail = ($O365UserAlias.text + "@domain.com")
New-Mailbox -Alias $O365UserAlias.Text -Name $O365UserAlias.Text -FirstName $O365UserFirst.Text -LastName $O365UserLast.Text -DisplayName $displayname -MicrosoftOnlineServicesID
$Results.AppendText("`r`n"
$Results.AppendText("User Mailbox Created... Continuing Script")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to help.
ASKER
I did copy/paste or ctrl+H just about everything, but I must have done some manualness when I was modifying this part of the script since it's improved and repurposed from a user delete script.