Reputation: 13
I am working on Microsoft Teams package and MSI is installing the files in Profiles Files x86 and I want to copy these files to the user profile. This is a per machine installation.
# Installing Teams 1.3.12058
$Parms=' /I Teams_windows_x64.msi ALLUSER=1 ALLUSERS=1 /qn
$CMDS= "msiexec.exe"
LogWrite "Executing $CMDS $Parms"
$Proces=Start-Process $CMDS $Parms -PassThru -Wait -WorkingDirectory $InstDir
$Extval=$Proces.ExitCode
LogWrite "Installed Teams 1.3 exit code:$Extval"
# Copying files and folders from "C:\program files X86" to User profile
$userFolder = Get-ChildItem -Path 'C:\Users' -Exclude 'Default*','All Users','Administrator', 'Public' | Select -ExpandProperty FullName
foreach ($uf in $userFolder)
$Dest = "C:\Users\$user\AppData\Local\Microsoft"
$Source = "C:\Program Files (x86)\Microsoft\"
{
Copy-Item -LiteralPath "$Source" -Destination $Dest -Force -Recurse
}
It's throwing an error at the copy-item command. Can someone kindly help me on this one.
Upvotes: 0
Views: 38
Reputation: 310
foreach loop is not closed properley. kindly close it and excute again
foreach ($uf in $userFolder) {
$Dest = "C:\Users$user\AppData\Local\Microsoft" $Source = "C:\Program Files (x86)\Microsoft"
{ Copy-Item -LiteralPath "$Source" -Destination $Dest -Force -Recurse }}
Upvotes: 2