@@ -18,87 +18,89 @@ Removes the scheduled task
18
18
#>
19
19
[CmdletBinding (DefaultParameterSetName = ' Fix' )]
20
20
param (
21
- [Parameter (ParameterSetName = ' Install' )]
22
- [switch ] $Install = $false ,
23
- [Parameter (ParameterSetName = ' Uninstall' )]
24
- [switch ] $Uninstall = $false
21
+ [Parameter (ParameterSetName = ' Install' )]
22
+ [switch ] $Install = $false ,
23
+ [Parameter (ParameterSetName = ' Uninstall' )]
24
+ [switch ] $Uninstall = $false
25
25
)
26
26
27
27
Begin
28
28
{
29
- $taskName = ' Disable-BioLogin'
30
-
31
- function DeleteNgcIosBackup
32
- {
33
- param ($arc )
34
- $0 = " C:\Windows\WinSxS\$arc `_microsoft-windows-security-ngc-trustlet*\"
35
- if (Test-Path $0 )
36
- {
37
- Get-ChildItem - Path $0 - filter NgcIso.exe - Recurse | % `
38
- {
39
- $name = $_.FullName
40
- Write-Host " ... delete backup $name "
41
- Set-ItemOwner $name
42
- Remove-item - Path $name - Force - Confirm:$false
43
- }
44
- }
45
- }
46
-
47
- function HideOffender
48
- {
49
- param ($offender )
50
- if (Test-Path $offender )
51
- {
52
- Write-Host " ... hiding $offender "
53
- Set-ItemOwner $offender
54
- mv $offender " $offender `-hide" - Force - Confirm:$false
55
- }
56
- }
57
-
58
- function RegisterTask
59
- {
60
- $user = [System.Security.Principal.WindowsIdentity ]::GetCurrent().Name
61
-
62
- $pwsh = [System.Diagnostics.Process ]::GetCurrentProcess().Path
63
- $command = " & '${PSCommandPath} '"
64
- $command = [Convert ]::ToBase64String([System.Text.Encoding ]::Unicode.GetBytes($command ))
65
-
66
- $action = New-ScheduledTaskAction - Execute $pwsh `
67
- - Argument " -NonInteractive -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -EncodedCommand ${command} "
68
-
69
- $startupTrigger = New-ScheduledTaskTrigger - AtStartup
70
-
71
- Register-ScheduledTask $taskName - Action $action - Trigger $startupTrigger - User $user - RunLevel Highest
72
- }
29
+ $taskName = ' Disable-BioLogin'
30
+
31
+ function DeleteNgcIosBackup
32
+ {
33
+ param ($arc )
34
+ $0 = " C:\Windows\WinSxS\$arc `_microsoft-windows-security-ngc-trustlet*\"
35
+ if (Test-Path $0 )
36
+ {
37
+ Get-ChildItem - Path $0 - filter NgcIso.exe - Recurse | % `
38
+ {
39
+ $name = $_.FullName
40
+ Write-Host " ... delete backup $name "
41
+ Set-ItemOwner $name
42
+ Remove-item - Path $name - Force - Confirm:$false
43
+ }
44
+ }
45
+ }
46
+
47
+ function HideOffender
48
+ {
49
+ param ($offender )
50
+ if (Test-Path $offender )
51
+ {
52
+ Write-Host " ... hiding $offender "
53
+ Set-ItemOwner $offender
54
+ mv $offender " $offender `-hide" - Force - Confirm:$false
55
+ }
56
+ }
57
+
58
+ function RegisterTask
59
+ {
60
+ $user = [System.Security.Principal.WindowsIdentity ]::GetCurrent().Name
61
+
62
+ $pwsh = ' powershell.exe' # [System.Diagnostics.Process]::GetCurrentProcess().Path
63
+
64
+ $log = Join-Path $env: USERPROFILE " task-logs\$taskName .log"
65
+ $command = " Start-Transcript $log ; & '${PSCommandPath} '"
66
+ # $command = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($command))
67
+
68
+ $action = New-ScheduledTaskAction - Execute $pwsh `
69
+ - Argument " -WindowStyle Hidden -ExecutionPolicy Bypass -Command "" ${command} "" "
70
+
71
+ $trigger = New-ScheduledTaskTrigger - AtStartup
72
+ Register-ScheduledTask - TaskName $taskName - Action $action - Trigger $trigger - User $user - RunLevel Highest
73
+ }
73
74
74
- function UnregisterTask
75
- {
76
- Unregister-ScheduledTask $taskName
77
- }
75
+
76
+ function UnregisterTask
77
+ {
78
+ Unregister-ScheduledTask $taskName - Confirm:$false
79
+ }
78
80
}
79
81
Process
80
82
{
81
- if ($PSCmdlet.ParameterSetName -eq ' Install' )
82
- {
83
- RegisterTask
84
- return
85
- }
86
-
87
- if ($PSCmdlet.ParameterSetName -eq ' Uninstall' )
88
- {
89
- UnregisterTask
90
- return
91
- }
92
-
93
- # hide them!
94
-
95
- # ngciso might get started first, so deal with it first to try to
96
- # catch it before it starts
97
- HideOffender " $ ( $env: windir ) \system32\ngciso.exe"
98
- HideOffender " $ ( $env: windir ) \system32\bioiso.exe"
99
-
100
- # delete WinSxS backup files
101
- DeleteNgcIosBackup ' amd64'
102
- DeleteNgcIosBackup ' wow64'
103
- DeleteNgcIosBackup ' x86'
83
+ if ($PSCmdlet.ParameterSetName -eq ' Install' )
84
+ {
85
+ RegisterTask
86
+ return
87
+ }
88
+
89
+ if ($PSCmdlet.ParameterSetName -eq ' Uninstall' )
90
+ {
91
+ UnregisterTask
92
+ return
93
+ }
94
+
95
+ # hide them!
96
+
97
+ # ngciso might get started first, so deal with it first to try to
98
+ # catch it before it starts
99
+ HideOffender " $ ( $env: windir ) \system32\ngciso.exe"
100
+ HideOffender " $ ( $env: windir ) \system32\bioiso.exe"
101
+
102
+ # delete WinSxS backup files
103
+ DeleteNgcIosBackup ' amd64'
104
+ DeleteNgcIosBackup ' wow64'
105
+ DeleteNgcIosBackup ' x86'
104
106
}
0 commit comments