6
我有问题将变量提供给New-MsolUser cmdlet。我收到以下错误。办公室365 cmdlet的参数错误
New-MsolUser : A positional parameter cannot be found that accepts argument 'â?UserPrincipalName [email protected] â?UsageLocation'.
At C:\users\test\Documents\test.ps1:148 char:1
+ New-MsolUser -DisplayName $TargetFullname â?"UserPrincipalName $TargetEmail â?" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-MsolUser], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.Online.Administration.Automation.NewUser
我使用的代码是:
$Source = "AnotherADUser"
$TargetFname = "New"
$TargetLname = "User"
$Target = "ausertest"
$TargetFullname = [string]::Concat($TargetFname ," ", $TargetLname)
$SourceEmail = (Get-ADUser $source -Property EmailAddress).EmailAddress
$SourceDomain = $SourceEmail.split("@")[1]
$TargetEmail = ([string]::Concat($Target , "@" , $SourceDomain))
New-MsolUser -DisplayName $TargetFullname –UserPrincipalName $TargetEmail –UsageLocation "IE" | Set-MsolUserLicense -AddLicenses "TESTINSTALL:EXCHANGESTANDARD"
此命令的作用时,我硬编码的细节..
它看起来像是窒息了'$ TargetFullname'中的值。你使用的是给定的值(“新用户”)还是别的? –
上面的代码是我正在测试的值,并获得上述错误。 – barconr
如果在括号中包装'[string] :: Concat($ TargetFname,“”,$ TargetLname)',你还会得到错误吗? –