我正在尝试通过PowerShell从SharePoint站点下载文件。此脚本的目标是获取SharePoint文件,并将其应用于Outlook以获得员工签名。我们已经创建了所需的员工签名,只需将这些.htm文件部署到员工设备。我正在通过Office 365 Endpoint Manager (不再是Intune)运行此脚本以部署到我的最终用户。脚本将在本地机器上创建.htm文件,但是当打开.htm文件时,它会将我带到站点url,而不是给我提供实际的电子邮件签名-几乎就像命令只是复制而不是实际下载。关于如何添加到此脚本以从存储电子邮件签名的SharePoint站点下载相应的文件,您有什么想法吗?或者,有没有另一种更简单的选择,我没有考虑过,可以更好地工作?对于一些Sharepoint功能以及如何让Powershell与SharePoint进行通信还是个新手,所以请耐心等待。谢谢你的帮助。
使用以下代码帮助构建脚本:https://github.com/marcusburst/scripts/blob/master/Powershell/Exchange/AutomaticOutlookSignature.ps1
做了一些调整以满足我的需求。
# Checks if outlook profile exists - we only want it to run on people who have a profile so they don't get an annoying profile popup #
$OutlookProfileExists = Test-Path
"C:\Users\$env:Username\AppData\Local\Microsoft\Outlook"
if ($OutlookProfileExists -eq $true) {
Write-Host "User Outlook profile exists.. continuing.." -ForegroundColor Yellow
# Signature Variables #
$ExternalSignatureName = 'External-Signature.htm'
$SigSource = 'https://SharePointSiteURLL'
$RepliesForwardsSignatureName = 'Replies-Forwards-Signature.htm'
$SigSource = 'https://SharePointSiteURL'
# Environment variables #
$AppData = $env:appdata
$SigPath = '\Microsoft\Signatures'
$LocalSignaturePath = $AppData + $SigPath
# Copy file #
If (!(Test-Path -Path $LocalSignaturePath)) {
New-Item -Path $LocalSignaturePath -Type Directory
}
# Check signature path #
if (!(Test-Path -path $LocalSignaturePath)) {
New-Item $LocalSignaturePath -Type Directory
}
# Copy signature templates from domain to local Signature-folder #
Write-Host "Copying Signatures" -ForegroundColor Green
Invoke-WebRequest -URI $Sigsource -Outfile "$LocalSignaturePath\$ExternalSignatureName"
Invoke-WebRequest -URI $SigSource -OutFile "$LocalSignaturePath\$RepliesForwardsSignatureName"
# Set as Default Signature #
If (Test-Path HKCU:'\Software\Microsoft\Office\16.0') {
Write-host "Setting signature for Office 2019"-ForegroundColor Green
Write-host "Setting signature for Office 2019 as available" -ForegroundColor Green
If ((Get-ItemProperty -Name 'First-Run' -Path HKCU:'\Software\Microsoft\Office\16.0\Outlook\Setup' -ErrorAction SilentlyContinue))
{
Remove-ItemProperty -Path HKCU:'\Software\Microsoft\Office\16.0\Outlook\Setup' -Name 'First-Run' -Force
}
If (!(Get-ItemProperty -Name 'External-Signature' -Path HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings' -ErrorAction SilentlyContinue))
{
New-ItemProperty -Path HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings' -Name 'Ext-Signature' -Value $ExternalSignatureName -PropertyType 'String' -Force
}
If (!(Get-ItemProperty -Name 'Replies-Forwards-Signature' -Path HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings' -ErrorAction SilentlyContinue))
{
New-ItemProperty -Path HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings' -Name 'Replies-Forwards-Signature' -Value $RepliesForwardsSignatureName -PropertyType 'String' -Force
}
}
# Removes files from recent items in file explorer #
Write-host "Cleaning up recent files list in File Explorer.." -ForegroundColor Yellow
Get-ChildItem -Path "$env:APPDATA\Microsoft\Windows\Recent" -File | Sort-Object LastWriteTime -Descending | Remove-Item
Get-ChildItem -Path "$env:APPDATA\Microsoft\Windows\Recent\AutomaticDestinations" -File | Sort-Object LastWriteTime -Descending | Remove-Item
}
发布于 2020-08-16 11:33:07
我想我前段时间遇到了这个问题。我认为你的脚本很好,你只需要确保你的blob存储中有一个有效的令牌。
https://stackoverflow.com/questions/63363330
复制相似问题