Powershell-Office 365安全性和合规性

时间:2019-10-01 19:25:13

标签: powershell office365

我正在尝试获取此PowerShell脚本以自动生成命令的关键部分,从而以最少的交互运行。

脚本如下:

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

#Create Search with parameters
$SearchName = Read-Host "Enter Search name"
$date = Get-Date -format "MM/dd/yyyy"
$Subject = Read-Host "Enter Subject"
New-ComplianceSearch -Name "$SearchName" -ExchangeLocation all -ContentMatchQuery "'sent>=$date AND sent<=$date AND subject:"$Subject"'"

错误...

  

New-ComplianceSearch-名称“ $ SearchName” -ExchangeLocation全部   -ContentMatchQuery“'sent> = $ date AND发送<= $ date AND subject:” $ Subject“'”找不到位置参数,   接受参数“ t”。       + CategoryInfo:InvalidArgument:(:) [New-ComplianceSearch],ParameterBindingException       + FullyQualifiedErrorId:PositionalParameterNotFound,New-ComplianceSearch       + PSComputerName:nam01b.ps.compliance.protection.outlook.com

1 个答案:

答案 0 :(得分:0)

您需要添加Powershell墓碑`才能使双引号不会引起字符串破坏

这应该有效:

@for $i from 1 through 10 {
  .mb-#{$i} {
     margin-bottom: #{$i}rem;
  }
}