我们正在更改 5 个网络共享站点上的 URL,以便它们仅响应 HTTPS 和 FQDN 请求。我们的许多用户在他们的收藏夹中有“内部”链接,当我们更改 URL 时这些链接会中断。
我需要一种方法来打开每个“收藏夹”并查看是否有任何链接指向旧 URL,然后将其更改为新 URL。
这就是我想要做的(没有错误出现,但链接没有修改):
# Set folder variable
$folder = $env:HOMEPATH + '\' + 'favorites' #'
# Backup the folder
Copy-Item $folder $env:homepath\favorites1 -recurse
# set the stringtofind variables
$stringToFind1 = "http://wss1/"
$stringToFind2 = "http://iwds/"
$stringToFind3 = "http://webshare/"
$stringToFind4 = "http://mysites/"
$stringToFind5 = "http://eforms/"
# Set the stringtoplace variables
$stringToPlace1 = "https://wss1.FQDN.com"
$stringToPlace2 = "https://iwds.FQDN.com"
$stringToPlace3 = "https://webshare.FQDN.com"
$stringToPlace4 = "https://mysites.FQDN.com"
$stringToPlace5 = "https://eforms.FQDN.com"
# Execute the content changes
gci $folder\*.url -recurse | foreach-object { (Get-Content $_) | ForEach-Object { $_ -replace $stringToFind1, $stringToPlace1 } | Set-Content $_ }
gci $folder\*.url -recurse | foreach-object { (Get-Content $_) | ForEach-Object { $_ -replace $stringToFind2, $stringToPlace2 } | Set-Content $_ }
gci $folder\*.url -recurse | foreach-object { (Get-Content $_) | ForEach-Object { $_ -replace $stringToFind3, $stringToPlace3 } | Set-Content $_ }
gci $folder\*.url -recurse | foreach-object { (Get-Content $_) | ForEach-Object { $_ -replace $stringToFind4, $stringToPlace4 } | Set-Content $_ }
gci $folder\*.url -recurse | foreach-object { (Get-Content $_) | ForEach-Object { $_ -replace $stringToFind5, $stringToPlace5 } | Set-Content $_ }