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)',你還會得到錯誤嗎? –