Issues with copying *.automaticdestinations-ms files

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?

Jim,
Welcome to the forum. :wave:t4:

before we proceed … could you please go back, edit your question again and fix the formatting of the code?
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

1 Like