bar*_*onr 6 powershell office365
我有问题将变量提供给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
Run Code Online (Sandbox Code Playgroud)
我使用的代码是:
$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"
Run Code Online (Sandbox Code Playgroud)
当我对细节进行硬编码时,此命令有效.
\xe2\x80\x93UserPrincipalName并且\xe2\x80\x93UsageLocation不要使用减号字符,而使用\n代码为 8211 的字符。也许可以,但为了确定起见,请尝试使用标准减号\n。
| 归档时间: |
|
| 查看次数: |
838 次 |
| 最近记录: |