Good day;
Today is the first time I’m on the site, and it’s mainly to ask on how to solve an issue I have with a script I wrote.
The script reads old computer and new computer names, along with the user’s ID into an array, then saves locally-saved files to a network share. On the other side, a different script copies those files to the user’s new computer after they’ve logged in for the first time.
All that seems to work except for two instances: Pinned items and Outlook signatures.
I’ve tried code like this:
<#
This sets up the situation. I will not post the value of $NetworkPath. It’s the server where I’m saving the data.
#>
$LocalPath = -Join(“\$OldComputerName\c$\users",$UserName)
$NetworkPath = -join($SavePath,”$OldComputerName$UserName")
$OutlookSignaturesPath = -join($LocalPath,“\AppData\Roaming\Microsoft\Signatures”)
$PinnedFolder = “$LocalPath\AppData\Roaming\Microsoft\Windows\Recent Items\AutomaticDestinations”
$PinnedFiles = “*.automaticDestinations-ms”
<#
Here’s where the code fails
#>
Write-Host (“Copying pinned folders/files to Network n") $DirsProcessed +=1 Copy-Item -Path $PinnedFolder -Destination $NetworkPath -Filter $PinnedFiles -PassThru -ErrorAction SilentlyContinue -Force Write-Host ("Copying Outlook Signatures to Network
n”)
$DirsProcessed +=1
Copy-Item -Path $LocalPath$OutlookSignaturesPath $NetworkPath$OutlookSignaturesPath -Recurse -PassThru -ErrorAction SilentlyContinue -Force
<#
The result is that no files get copied.
I’ve even attempted to change the attributes on each to ‘Normal’ then back to ‘Hidden’ when I copy them to the new computer.
#>
Set-ItemProperty $PinnedFolder -Name Attribures -Value Normal
Still, nada.
Too bad I can’t just write this in one of the older languates I know, like Cobol…
Help?