When I run the following command, I receive an error. All commands complete successfully up until this point and it does find 67 items.
PS C:\WINDOWS\system32> New-ComplianceSearchAction -SearchName 'PhishingSearch' -Preview
A parameter cannot be found that matches parameter name 'Preview'.
+ CategoryInfo : InvalidArgument: (:) [New-ComplianceSearchAction], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,New-ComplianceSearchAction
+ PSComputerName : can01b.ps.compliance.protection.outlook.com
I'm hoping to preview my results to compare them with what I get in the GUI, but without the -Preview parameter, I'm not able to do that. Microsoft includes the parameter in their documentation here:
New-ComplianceSearchAction Examples
Here is the entirety of my code:
# Create a credential object
$UserCredential = Get-Credential
# Configure a remote session to the Exchange Compliance and Security Module
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid -Credential $UserCredential -Authentication Basic -AllowRedirection
# Connect session and import commands
Import-PSSession $Session -AllowClobber -DisableNameChecking
# Create a search query specifying a name, where to look, and the search parameters
New-ComplianceSearch -Name "PhishingSearch" -ExchangeLocation 'All' -ContentMatchQuery "(c:c)(Subject: 'Urgent Request') AND (From:abc@123.com)"
# Start the search query created above
Start-ComplianceSearch -Identity 'PhishingSearch'
# Check status of the search query
Get-ComplianceSearch -Identity 'PhishingSearch'
Get-ComplianceSearch -Identity 'PhishingSearch' | Format-List -Property Items
# Preview the results to compare with the web-results,
New-ComplianceSearchAction -SearchName 'PhishingSearch' -Preview
Get-ComplianceSearchAction -Identity 'PhishingSearch_Preview' | Format-List -Property Results
# Purge the emails
New-ComplianceSearchAction -SearchName 'PhishingSearch' -Purge -PurgeType SoftDelete
Get-ComplianceSearchAction -Identity 'PhishingSearch_Purge'
Get-ComplianceSearchAction -Identity 'PhishingSearch_Purge' | Format-List -Property Results