File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed
jumpcloud-ADMU/Powershell Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -1547,21 +1547,16 @@ Function Start-Migration {
1547
1547
}
1548
1548
Write-ToLog - Message:($localComputerName + ' is currently Domain joined to ' + $WmiComputerSystem.Domain + ' NetBiosName is ' + $netBiosName )
1549
1549
1550
- # Get all schedule tasks that have State of "Running " and " Ready" and not disabled
1551
- $ScheduledTasks = Get-ScheduledTask | Where-Object { $_.TaskPath -notlike " *\Microsoft\Windows*" -and $_.State -ne " Disabled" }
1550
+ # Get all schedule tasks that have State of "Ready" and not disabled and "Running"
1551
+ $ScheduledTasks = Get-ScheduledTask | Where-Object { $_.TaskPath -notlike " *\Microsoft\Windows*" -and $_.State -ne " Disabled" -and $_ .state -ne " Running " }
1552
1552
# Disable tasks before migration
1553
1553
Write-ToLog - message:(" Disabling Scheduled Tasks..." )
1554
1554
try {
1555
1555
$scheduledTasks | ForEach-Object {
1556
- # Write-ToLog -message:("Disabling Scheduled Task: $($_.TaskName)")
1557
- # If state is running stop it
1558
- if ($_.State -eq " Running" ) {
1559
- Write-ToLog - message:(" Task is still running, stopping... $ ( $_.TaskName ) " )
1560
- # Stop-ScheduledTask -TaskName $_.TaskName -TaskPath $_.TaskPath
1561
- # Disable-ScheduledTask -TaskName $_.TaskName -TaskPath $_.TaskPath
1562
- } else {
1563
- Disable-ScheduledTask - TaskName $_.TaskName - TaskPath $_.TaskPath | Out-Null
1564
- }
1556
+ Write-ToLog - message:(" Disabling Scheduled Task: $ ( $_.TaskName ) " )
1557
+
1558
+ Disable-ScheduledTask - TaskName $_.TaskName - TaskPath $_.TaskPath | Out-Null
1559
+
1565
1560
# Check task is disabled
1566
1561
$task = Get-ScheduledTask - TaskName $_.TaskName - TaskPath $_.TaskPath
1567
1562
if ($task.State -eq " Disabled" ) {
You can’t perform that action at this time.
0 commit comments