无价值的表达

时间:2017-07-12 18:26:21

标签: powershell powershell-v2.0

foreach ($OldAccount in $forwarderarray) {

$OldAccount.ForwardingAddress = $OldAccount.ForwardingAddress.substring(0,1).toupper()+$OldAccount.ForwardingAddress.substring(1).tolower() 

$Separatorforwarderaddress = $OldAccount.UserPrincipalName.IndexOf("@") # This section truncates the SMTP address to the firstname.surname to remove the @
$LeftPartforwarderaddress = $OldAccount.UserPrincipalName.Substring(0, $Separatorforwarderaddress) 
$RightPartforwarderaddress = $OldAccount.UserPrincipalName.Substring($Separatorforwarderaddress + 2)  
$SeparatorOwnerAddress = $OldAccount.ForwardingAddress.IndexOf(".") # This section truncates the SMTP address to the firstname.surname to remove the @
$LeftPartOwnerAddress = $OldAccount.ForwardingAddress.Substring(0, $SeparatorOwnerAddress)$RightPartOwnerAddress = 
$OldAccount.ForwardingAddress.Substring($SeparatorOwnerAddress + 2) 

奇怪的是写主机显示预期的值 但是当我尝试SMTP

Send-MailMessage -to $OldAccount.ForwardingAddress

我是:

  

您无法在空值表达式上调用方法

有人可以帮忙吗?我想要实现的是取出电子邮件地址用于显示目的,并使名称以大写字母开头。

那为什么会显示正确的信息

Write-Host "Sending message, to:"$OldAccount.ForwardingAddress

0 个答案:

没有答案