Duplicate Shortcuts in Microsoft Edge for Business

References

Microsoft Edge for Business | Microsoft Learn

Suddenly so many Microsoft Edge profile shortcut icon appears on my – Microsoft Community

Background

If you’re an IT Systems Admin, you may have noticed the introduction of Microsoft Edge for Business. Looking at Microsoft’s write up, the feature looks to separate the configuration between work and personal use cases; offering different policy sets and browser appearances for each scenario. I would recommend looking over the guidance below:

Microsoft Edge for Business | Microsoft Learn

Since it’s introduction, we’ve noticed that a subset of our users have at least one or more Edge shortcuts with an appended computer name suffix. Upon troubleshooting, it appears that this occurs when the user syncs their Desktop to OneDrive (In our case, this is applied via a policy), is logged on simultaneously to a different machine on the same domain, and launches Edge on both.

I prefer to remediate the root cause in this type of scenario. However, the only solution I’ve found so far is to disable the Edge for Business feature. As this only affects a handful of our users who work according to the example above, I’ve decided to implement an SCCM/MECM Configuration Baseline to remove the unwanted shortcuts when they appear.

Solution Overview

SCCM/MECM Configuration Baseline Script to remove specified files from a Windows Endpoint. In this case, additional Edge shortcuts. (I’ve also included Teams in this example).

How to use

Use the Discovery and Remediation scripts listed under the headings below.

See the following article on how to configure and implement a configuration Baseline. In this case, we’re using two PowerShell scripts.

Create configuration baselines – Configuration Manager | Microsoft Learn

For this solution, Compliance Rules should be set as follows:

Data Type: String

Value: Compliant

You may also need to modify the OneDrive path to reflect your organisations tenant:

Note: Do not modify the FileName, WildcardPrefix and WildcardSuffix values from the illustrated location above. The WildcardSuffix Boolean Value is set to $True in order to delete files with unique file names. In this example if a shortcut was named “Work – Edge-Computer1.lnk” it would be removed.

I will be writing a post on how this script can be modified to remove other files at a later date.

Discovery Script
#Policy_FileRemoval
#Removes Files based on defined values
#Discovery Script
#Version | 1.0
#Contact | Josh Woods | joshua@jwblog.uk
###################
#Variables
###################
#Configuration
$Version = "1.0"
#Currently Logged on User Variable
$Username = Get-WMIObject -class Win32_ComputerSystem | select-object -ExpandProperty username
$Username = $Username.Split("\")[1]
#Removal List
$Files = @(
[pscustomobject]@{FolderPath="C:\Users\$Username\OneDrive\Desktop";FileName="Work – Edge-";WildcardPrefix=$False;WildcardSuffix=$true}
[pscustomobject]@{FolderPath="C:\Users\$Username\OneDrive\Desktop";FileName="Microsoft Teams-";WildcardPrefix=$False;WildcardSuffix=$true}
)
#Discovery Array
$Match = @()
###################
#Variables End
###################
#Stop Install on Error and output to log
try {
#Log
#Start Log Transcript
Start-Transcript -Path "C:\Windows\Logs\Policy_FileRemoval_Discovery_$Version.txt" -append | Out-Null
foreach ($File in $Files) {
########################################
#Generate FileName Based on Variables
########################################
$ParsedFileName = $File.FileName
#Add Wildcard values
if ($File.WildcardPrefix -eq $True) {
$ParsedFileName = "*" + $ParsedFileName
}
if ($File.WildcardSuffix -eq $True) {
$ParsedFileName = $ParsedFileName + "*"
}
#Generate Final String
$RemovalString = $null
$RemovalString = $File.Folderpath + "\" + $ParsedFileName
########################################
#Detect Present Files
$DetectFile = $null
$DetectFile = Get-Item $RemovalString
#Detection Method Non-Compliance | Output to console
if ($DetectFile) {
#Write Detected Files to Console
Write-Output "Files for the following entry found | $RemovalString"
Write-Output "$($DetectFile.Name -join "`n")"
Write-Output " "
#Used for the Remediation script logic below
$Match = $Match + "FileExists"
}
}
}
catch {
#Failed. Write error and exit.
Write-Output "Error: $($_.Exception.Message)"
#Output Logs to File
Stop-Transcript
}
#Run Remediation Script if an File exists
if ($Match -NotContains "FileExists") {
Write-Host "Compliant"
}
else {
Write-Host "Remediation Script Will Run. Files Present."
}
view raw Discovery.ps1 hosted with ❤ by GitHub
Remediation Script
#Policy_FileRemoval
#Removes Files based on defined values
#Remediation Script
#Version | 1.0
#Contact | Josh Woods | joshua@jwblog.uk
#References
###################
#Variables
###################
#Configuration
$Version = "1.0"
#Currently Logged on User Variable
$Username = Get-WMIObject -class Win32_ComputerSystem | select-object -ExpandProperty username
$Username = $Username.Split("\")[1]
#Removal List
$Files = @(
[pscustomobject]@{FolderPath="C:\Users\$Username\OneDrive\Desktop";FileName="Work – Edge-";WildcardPrefix=$False;WildcardSuffix=$true}
[pscustomobject]@{FolderPath="C:\Users\$Username\OneDrive\Desktop";FileName="Microsoft Teams-";WildcardPrefix=$False;WildcardSuffix=$true}
)
#Stop Install on Error and output to log
try {
#Log
#Start Log Transcript
Start-Transcript -Path "C:\Windows\Logs\Policy_FileRemoval_Remediation_$Version.txt" -append
########################################################################################################################################################################################################################################
#This section will remove each shortcut based on the names listed
########################################################################################################################################################################################################################################
foreach ($File in $Files) {
########################################
#Generate FileName Based on Variables
########################################
$ParsedFileName = $File.FileName
#Add Wildcard values
if ($File.WildcardPrefix -eq $True) {
$ParsedFileName = "*" + $ParsedFileName
}
if ($File.WildcardSuffix -eq $True) {
$ParsedFileName = $ParsedFileName + "*"
}
#Generate Final String
$RemovalString = $File.Folderpath + "\" + $ParsedFileName
########################################
#Run Removal Command
Remove-Item "$RemovalString" -Force -Verbose
}
########################################################################################################################################################################################################################################
#Output Logs to File
Stop-Transcript
}
catch {
#Failed. Write error and exit.
Write-Output "Error: $($_.Exception.Message)"
#Output Logs to File
Stop-Transcript
}
view raw Remediation.ps1 hosted with ❤ by GitHub