【问题标题】:Insert Sharepoint Credentials using Powershell使用 Powershell 插入 Sharepoint 凭据
【发布时间】:2019-04-03 21:43:18
【问题描述】:
当尝试通过 powershell 打开或有时关闭我公司网络中托管的 sharepoint 目录中的 word 文档时,会弹出 windows 安全框。
我怎样才能验证这个?这是我的脚本的一部分:
$docpath = "\\sharepoint.[Domain].com\[...]\mydoc.docx"
$word = New-Object -ComObject Word.Application
$word.Visible = $true
$doc = $word.Documents.Open("$docpath")
{...process...}
$doc.Close([ref]$true)
$word.Quit()
$word = $null
[gc]::collect()
[gc]::WaitForPendingFinalizers()
Here is a visual example of what happens.
【问题讨论】:
标签:
powershell
sharepoint
ms-word
windows-security
【解决方案1】:
我发现了一些有用的东西,但前提是有管理员用户。仍然想知道是否有办法在没有这种许可的情况下做到这一点。
代码如下:
$User = "domain\useradmin"
$Cred = Get-Credential -Credential $User
$srv = "sharepoint.[Domain].com"
Invoke-Command -ComputerName $srv -Credential $Cred -ScriptBlock{
$docpath = "\\sharepoint.[Domain].com\[...]\mydoc.docx"
$word = New-Object -ComObject Word.Application
$word.Visible = $true
$doc = $word.Documents.Open("$docpath")
{...process...}
$doc.Close([ref]$true)
$word.Quit()
$word = $null
}