Skip to content

Commit cdca9bc

Browse files
committed
added -ne running state
1 parent 43222b6 commit cdca9bc

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

jumpcloud-ADMU/Powershell/Start-Migration.ps1

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,21 +1547,16 @@ Function Start-Migration {
15471547
}
15481548
Write-ToLog -Message:($localComputerName + ' is currently Domain joined to ' + $WmiComputerSystem.Domain + ' NetBiosName is ' + $netBiosName)
15491549

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" }
15521552
# Disable tasks before migration
15531553
Write-ToLog -message:("Disabling Scheduled Tasks...")
15541554
try {
15551555
$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+
15651560
# Check task is disabled
15661561
$task = Get-ScheduledTask -TaskName $_.TaskName -TaskPath $_.TaskPath
15671562
if ($task.State -eq "Disabled") {

0 commit comments

Comments
 (0)