I have the following command:
$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}}
It returns:
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 :
The SearchName field is always an empty string when I run in PowerShell ISE, but if I copy and run the same command in shell, it returns SearchName as "test search 2 to 7" which is the required value.
Why is the behaviour different in both places? What am I doing wrong here?