windows - 在没有提示的情况下在 powershell 中获取 Office 365 凭据
问题描述
我想使用 powershell 自动将文件从 Sharepoint 下载到本地磁盘,但我不希望我的用户输入密码,因为脚本将在每次系统启动时运行。
Windows 密码与 Office 365 的密码相同,所以我可以使用这个密码,有什么技巧可以在 PS 中实现吗?
解决方案
您可以使用 DefaultNetworkCredentials
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$ctx.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$web = $ctx.Web
$ctx.Load($web);
$ctx.ExecuteQuery();
推荐阅读
- python-3.x - 如何通过 Pyrebase4 设置 FastAPI 与 Firestore 的通信
- javascript - 如何修复错误 componentWillUpdate 或 componentDidUpdate。React 限制嵌套更新的数量以防止无限循环
- testing - Chaostoolkit istio 扩展在玩实验时挂起
- java - Junit - 断言两个相同的数组列表会使测试失败
- c# - 发布到 .NET Core Web API 时出现 Angular 空白屏幕
- aws-lambda - AWS API Gateway 返回整个 Lambda 响应对象作为正文
- python - Python Tkinter Treeview - 如何确定是否显示最后一个孩子?
- python - Scipy优化:输入和输出的约束
- javascript - 如何使用带有页脚的 CSS 制作粘性底部导航
- logging - 在Odoo V11 CE中,服务器花费大量时间删除bus.bus记录是否正常?