Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeploymentMX/ab1e9965af400de323b0af6050750ba1 to your computer and use it in GitHub Desktop.
Save DeploymentMX/ab1e9965af400de323b0af6050750ba1 to your computer and use it in GitHub Desktop.
set-executionpolicy bypass
if (Test-Path "$($Env:Appdata)\Microsoft\Teams\Backgrounds\Uploads") {
#Remove-Item -path "$($Env:Appdata)\Microsoft\Teams\Backgrounds\Uploads\*.*"
New-item -path C:\temp –type directory
.\azcopy copy 'https://deploymentmx.blob.core.windows.net/token/azcopy.exe' 'C:\temp\'
.\azcopy copy 'https://deploymentmx.blob.core.windows.net/token/background.jpg' 'C:\temp\'
$route = 'C:\temp\'
copy-item $route\background.jpg "$($Env:Appdata)\Microsoft\Teams\Backgrounds\Uploads\"
write-host "End of Script"
Remove-Item -path "C:\temp\azcopy.exe"
Remove-Item -path "C:\temp\background.jpg"
Remove-Item -path "C:\temp"
exit
}
else
{
$Excluded_Profiles = @( 'Default User', 'All Users', 'Default', 'Public' )
$Profiles = Get-ChildItem 'c:\users\' -Directory -force | Where-Object { $_.BaseName -notin $excluded_profiles }
$targetFolder = "\AppData\Roaming\Microsoft\Teams\Backgrounds\Uploads"
foreach ($ProfilePath in $Profiles.FullName) {
$Destination = Join-Path -Path $ProfilePath -ChildPath $TargetFolder
try {
if (-not (Test-Path $Destination -ErrorAction Stop)) {
New-Item -Path $Destination -Itemtype Directory -ErrorAction Stop
New-item -path C:\temp –type directory
.\azcopy copy 'https://deploymentmx.blob.core.windows.net/token/azcopy.exe' 'C:\temp\'
.\azcopy copy 'https://deploymentmx.blob.core.windows.net/token/background.jpg' 'C:\temp\'
$route = 'C:\temp\'
copy-item $route\background.jpg "$($Env:Appdata)\Microsoft\Teams\Backgrounds\Uploads\"
write-host "End of Script"
Remove-Item -path "C:\temp\azcopy.exe"
Remove-Item -path "C:\temp\background.jpg"
Remove-Item -path "C:\temp"
}
Copy-Item -Path $pictures -Destination $Destination -Force -ErrorAction Stop
} catch {}
}
}
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment