Forum Discussion
I could'nt create a new user in Azure with powershell
- Jul 15, 2022
Here comes the solution.
$PasswordProfile = New-Object -TypeName 'Microsoft.Open.AzureAD.Model.PasswordProfile' ($PasswordProfile.Password = "fGGGGGtyHHHHjj#$5g@@56" )Many thanks to all
You need to remove the double-qoute from the password
-PasswordProfile "$PasswordProfile"
Make it like this
$PasswordProfile = New-Object -TypeName 'Microsoft.Open.AzureAD.Model.PasswordProfile'
$PasswordProfile.Password ='fGGGGGtyHHHHjj#$5g@@56'
New-AzureADUser -DisplayName "AZDemoAccount1" -PasswordProfile $PasswordProfile -UserPrincipalName "email address removed for privacy reasons" -MailNickName "AZDemoAccount1" -CompanyName "MyCompany" -Department "Abteilung XY" -JobTitle "Position XY" -UsageLocation DE -AccountEnabled $true
- MSpangJul 15, 2022Brass Contributor
farismalaeb Thx first of all.
Here ist the result of your solution.
$PasswordProfile = New-Object -TypeName 'Microsoft.Open.AzureAD.Model.PasswordProfile' $PasswordProfile.Password ='fGGGGGtyHHHHjj#$5g@@56' New-AzureADUser -DisplayName "100010-Vorname-Nachname" -PasswordProfile $PasswordProfile -UserPrincipalName "email address removed for privacy reasons"` -MailNickName "100010-Vorname-Nachname" -CompanyName "Firma XY" -Department "Abteilung XY" -JobTitle "Position XY" -UsageLocation DE -AccountEnabled $true Cmdlet Get-Credential an der Befehlspipelineposition 1 Geben Sie Werte für die folgenden Parameter an: Account Environment TenantId TenantDomain AccountType ------- ----------- -------- ------------ ----------- email address removed for privacy reasons AzureCloud xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx palettecad.net User New-Object : Es wurde kein Positionsparameter gefunden, der das Argument "=fGGGGGtyHHHHjj#$5g@@56" akzeptiert. In Zeile:5 Zeichen:20 + ... rdProfile = New-Object -TypeName 'Microsoft.Open.AzureAD.Model.Passwo ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [New-Object], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.NewObjectCommand ExtensionProperty : {[odata.metadata, https://graph.windows.net/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/$metadata#directoryObjects/@Element], [odata.type, Microsoft.DirectoryServices.User], [createdDateTime, ], [employeeId, ]...} DeletionTimestamp : ObjectId : 123456-12345-1234-12345-xxxxxxxxx ObjectType : User AccountEnabled : True AgeGroup : AssignedLicenses : {} AssignedPlans : {} City : CompanyName : Firma XY ConsentProvidedForMinor : Country : CreationType : Department : Abteilung XY DirSyncEnabled : DisplayName : 100010-Vorname-Nachname FacsimileTelephoneNumber : GivenName : IsCompromised : ImmutableId : JobTitle : Position XY LastDirSyncTime : LegalAgeGroupClassification : Mail : MailNickName : 100010-Vorname-Nachname Mobile : OnPremisesSecurityIdentifier : OtherMails : {} PasswordPolicies : PasswordProfile : class PasswordProfile { Password: ForceChangePasswordNextLogin: True EnforceChangePasswordPolicy: False } PhysicalDeliveryOfficeName : PostalCode :
but a new user was created
- MSpangJul 15, 2022Brass Contributor
Command:
$PasswordProfile = New-Object -TypeName 'Microsoft.Open.AzureAD.Model.PasswordProfile' $PasswordProfile.Password = "fGGGGGtyHHHHjj#$5g@@56"
ERROR:
New-Object : Es wurde kein Positionsparameter gefunden, der das Argument "=" akzeptiert.
- MSpangJul 15, 2022Brass Contributor
Here comes the solution.
$PasswordProfile = New-Object -TypeName 'Microsoft.Open.AzureAD.Model.PasswordProfile' ($PasswordProfile.Password = "fGGGGGtyHHHHjj#$5g@@56" )Many thanks to all