52 lines
1.8 KiB
PowerShell
52 lines
1.8 KiB
PowerShell
|
|
<#
|
||
|
|
Author: Gabe Kerntke
|
||
|
|
Date: 03-11-2024
|
||
|
|
|
||
|
|
.Synopsis
|
||
|
|
|
||
|
|
.Modified
|
||
|
|
2024-03-11 (GabeK) - Original script created
|
||
|
|
|
||
|
|
#>
|
||
|
|
|
||
|
|
#Region Variables
|
||
|
|
|
||
|
|
$users = (Get-ChildItem -path c:\users).name
|
||
|
|
$CurrentUser = ((get-ciminstance win32_computersystem | % username) -split '\\')[1]
|
||
|
|
|
||
|
|
#Region Functions
|
||
|
|
Function RegAdd {
|
||
|
|
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS -ErrorAction SilentlyContinue
|
||
|
|
|
||
|
|
foreach ($user in $users) {
|
||
|
|
If ($user -eq $currentuser) { continue; }
|
||
|
|
reg load "hku\$user" "C:\Users\$user\NTUSER.DAT"
|
||
|
|
# Do whatever you need with "hkey_users\$user" here which links to each users' HKU
|
||
|
|
If (Test-Path "HKU:$user\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\MSTeams_8wekyb3d8bbwe\TeamsTfwStartupTask") {
|
||
|
|
Set-ItemProperty "HKU:$user\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\MSTeams_8wekyb3d8bbwe\TeamsTfwStartupTask" -Name "State" -Value 1 -Force | Out-Null
|
||
|
|
Start-Sleep 5
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
foreach ($user in $users) {
|
||
|
|
If ($user -eq $currentuser) { continue; }
|
||
|
|
Start-Sleep 5
|
||
|
|
reg unload "hku\$user"
|
||
|
|
}
|
||
|
|
RegAdd2
|
||
|
|
}
|
||
|
|
|
||
|
|
Function RegAdd2 {
|
||
|
|
$Keys = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" -Recurse
|
||
|
|
Foreach ($Key in $Keys) {
|
||
|
|
If (($key.GetValueNames() | % { $key.GetValue($_) }) -match "\b$CurrentUser\b" ) { $sid = $key }
|
||
|
|
}
|
||
|
|
|
||
|
|
$sid = $sid.pschildname
|
||
|
|
|
||
|
|
Set-ItemProperty "HKU:\$sid\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\MSTeams_8wekyb3d8bbwe\TeamsTfwStartupTask" -Name "State" -Value 1 -Force | Out-Null
|
||
|
|
}
|
||
|
|
|
||
|
|
#Region Script Start
|
||
|
|
RegAdd
|
||
|
|
#Region Script End
|