【问题标题】:Powershell ISE returning empty string but working fine in shellPowershell ISE 返回空字符串,但在 shell 中工作正常
【发布时间】:2014-03-26 11:35:19
【问题描述】:

我有以下命令:

$startDate='01/02/2013'
$endDate='26/03/2014'
Search-AdminAuditLog -Cmdlets set-mailboxsearch -StartDate $startDate -EndDate $endDate | where {$_.cmdletparameters.name -notcontains "inplaceholdenabled"}|Add-Member -Name "SearchName" -MemberType ScriptProperty -PassThru -Value {Get-MailboxSearch -Identity $this.objectmodified} | select "objectmodified","Caller","Rundate","cmdletname",@{Name="SearchName";Expression={$_.searchname.Name}}  

返回:

ObjectModified : XXXXXXXX
Caller         : Administrator
RunDate        : 25/03/2014 4:33:17 PM
CmdletName     : Set-MailboxSearch
SearchName     : 

ObjectModified : AAMkADQyZDMxY2UwL 
Caller         : Administrator
RunDate        : 25/03/2014 9:35:02 AM
CmdletName     : Set-MailboxSearch
SearchName     : 

当我在 PowerShell ISE 中运行时,SearchName 字段始终为空字符串,但如果我在 shell 中复制并运行相同的命令,它会返回 SearchName 作为“测试搜索 2 到 7”,这是必需的值。

为什么这两个地方的行为不同?我在这里做错了什么?

【问题讨论】:

    标签: powershell exchange-server


    【解决方案1】:

    答案可能在这个重复的线程中,基本上 ISE 与控制台不同,并且有许多注意事项供您学习。

    Difference between PowerShell Console and PowerShell ISE

    换句话说,您的脚本可能没有问题,已知 ISE 有 issues

    http://blogs.msdn.com/b/powershell/archive/2009/04/17/differences-between-the-ise-and-powershell-console.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-29
      • 1970-01-01
      • 1970-01-01
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-05
      相关资源
      最近更新 更多