Hi,
I create a user in AD and then I want to create a 365 account in a domain that is not the same as the AD.
For this I configure in the script the connection with administrator username and password 365. If I execute it from the machine by hand it does it well, but once I include it in the ADManager I get the following error:
Result:ConvertTo-SecureString : Key not valid for use in specified state.
At C:\ManageEngine\ADManager Plus\bin\usernewcomer365.ps1:5 char:17
+ $SecureString = ConvertTo-SecureString -String $EncryptedPassWord
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [ConvertTo-SecureString], CryptographicException
+ FullyQualifiedErrorId : ImportSecureString_InvalidArgument_CryptographicError,Microsoft.PowerShell.Commands.Conv
ertToSecureStringCommand
New-Object : Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument
"password" is null. Change the value of argument "password" to a non-null value."
At C:\ManageEngine\ADManager Plus\bin\usernewcomer365.ps1:6 char:16
+ ... edentials = New-Object System.Management.Automation.PSCredential "Adm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Connect-MsolService : Showing a modal dialog box or form when the application is not running in UserInteractive mode
is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a
service application.
At C:\ManageEngine\ADManager Plus\bin\usernewcomer365.ps1:9 char:1
+ Connect-MsolService -Credential $Credentials
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Online.Administration.Automation.ConnectMsolS
ervice
Get-MsolUser : You must call the Connect-MsolService cmdlet before calling any other cmdlets.
At C:\ManageEngine\ADManager Plus\bin\usernewcomer365.ps1:41 char:17
+ $informacion1 = Get-MsolUser -UserPrincipalName $usu1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Get-MsolUser], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.MicrosoftOnlineException,Microsoft.Online.Adm
inistration.Automation.GetUser
Get-MsolUser : You must call the Connect-MsolService cmdlet before calling any other cmdlets.
At C:\ManageEngine\ADManager Plus\bin\usernewcomer365.ps1:42 char:17
+ $informacion2 = Get-MsolUser -UserPrincipalName $usu2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Get-MsolUser], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.MicrosoftOnlineException,Microsoft.Online.Adm
inistration.Automation.GetUser
New-MsolUser : You must call the Connect-MsolService cmdlet before calling any other cmdlets.
At C:\ManageEngine\ADManager Plus\bin\usernewcomer365.ps1:56 char:1
+ New-MsolUser -DisplayName $displayName -FirstName $givenName -LastNa ...
+ ~~~~~~
How can I solve this? The domain where I have to create the new account is not configured in the ADManager, I simply make the connection by script