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