简体   繁体   English

自动执行连接到“Connect-ExchangeOnline”的 Power Shell 脚本

[英]Automate the execution of a Power Shell script which connect to `Connect-ExchangeOnline`

    $EndDate = ($Today.AddDays(-$i)).AddHours($j + 1)
    $Audit = Search-UnifiedAuditLog -StartDate $StartDate -EndDate $EndDate -ResultSize 5000
    $ConvertAudit = $Audit | Select-Object -ExpandProperty AuditData | ConvertFrom-Json
    $ConvertAudit | Select-Object CreationTime,UserId,Operation,Workload,ObjectID,SiteUrl,SourceFileName,ClientIP,UserAgent | Export-Csv $OutputFile -NoTypeInformation -Append
    Write-Host $StartDate `t $Audit.Count
  }
}
Disconnect-ExchangeOnline

now we can manually copy/paste the script inside Windows Power Shell windows >> login to our tenant for MFA >> and run the script.现在我们可以在 Windows Power Shell 窗口中手动复制/粘贴脚本 >> 登录我们的 MFA 租户 >> 并运行脚本。

but my question, is how we can automate the execution of this Power Shell to run daily on the background?但我的问题是,我们如何才能自动执行此 Power Shell 以每天在后台运行? in other words how we can login to ExchnageOnline without human interaction?换句话说,我们如何在没有人工交互的情况下登录 ExchnageOnline?

Thanks谢谢

For Connect-ExchangeOnline look at using certificate authentication see https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps对于 Connect-ExchangeOnline 查看使用证书身份验证,请参阅https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM