【发布时间】:2013-12-03 02:44:43
【问题描述】:
我在准备一些基于 PS 的有用脚本时遇到了一些问题。
我尝试制作将从 Active Directory 和 Exchange(用户/邮箱)收集数据的脚本,然后这些数据将在脚本的进一步部分(例如在某些函数中)进行处理
function toProcess($userObj, $mailboxObj)
{
echo $userObj.enabled #the output is null
}
$users = get-adusers -Filter * -properties *
foreach($user in $users)
{
$guid = $user.objectGuid.toString()
if($user.mail -ne $null)
{
$mailbox = get-mailbox $guid | select-object *
if($mailbox -ne $null)
{
toProcess($user, $mailbox)
}
}
}
当 onProcess() 只分配一个参数 ($user) 时,函数正确执行并显示帐户状态。当我分配两个对象时,值变为空。 怎么了?
我使用的是 powershell 2.0
【问题讨论】:
标签: object powershell exchange-server