【问题标题】:Argument errors with office 365 cmdletoffice 365 cmdlet 的参数错误
【发布时间】:2014-08-13 18:28:39
【问题描述】:

我在将变量输入到 New-MsolUser cmdlet 时遇到问题。我收到以下错误。

New-MsolUser : A positional parameter cannot be found that accepts argument 'â?UserPrincipalName ausertest@test.ie â?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 中的值阻塞了。您是在使用给定的值(“新用户”)还是其他?
  • 上面的代码是我正在测试并得到上述错误的值。
  • 如果将[string]::Concat($TargetFname ," ", $TargetLname) 括在括号中,是否还会出现错误?
  • –UserPrincipalName–UsageLocation 不使用 minus 字符,而是使用代码为 8211 的字符。也许没问题,但请尝试使用标准减号,以确保.
  • @RomanKuzmin 将您的评论转换为right 答案!

标签: powershell office365


【解决方案1】:

–UserPrincipalName–UsageLocation 不使用 minus 字符,而是使用 代码为 8211 的字符。也许没问题,但请尝试使用标准减号 相反,只是为了确定。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-06
    • 1970-01-01
    • 2019-10-24
    • 2013-06-03
    • 1970-01-01
    • 1970-01-01
    • 2015-09-05
    相关资源
    最近更新 更多