bsharath
asked on
Delete a scheduled task on all machines in a txt file. Scheduled task called "AT01"
Hi,
Delete a scheduled task on all machines in a txt file. Scheduled task called "AT01"
Need to get the success & failure to just know on how many machines it was deleted.
And need to skip ping failure machines permission issu machines.
Regards
Sharath
Delete a scheduled task on all machines in a txt file. Scheduled task called "AT01"
Need to get the success & failure to just know on how many machines it was deleted.
And need to skip ping failure machines permission issu machines.
Regards
Sharath
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does that mean that all jobs will be deleted. Or do i need to see something in the task and let you know.
Any help on the 2 posts
Add Administrator to each group....
Any help on the 2 posts
Add Administrator to each group....
no it mean only at1 will be deleted as you asked
i'm checking now the other posts
i'm checking now the other posts
ASKER
Thanks i think its working.
What is the change i need to do in the script to just log them without deleting.
So i can see if the script is deleting the right one please...
What is the change i need to do in the script to just log them without deleting.
So i can see if the script is deleting the right one please...
ASKER
Thanks i think its working.
What is the change i need to do in the script to just log them without deleting.
So i can see if the script is deleting the right one please...
What is the change i need to do in the script to just log them without deleting.
So i can see if the script is deleting the right one please...
try this
Const ForReading = 1
Const ForWriting = 2
Set objfso = CreateObject("Scripting.FileSystemObject")
Set objlist = objfso.OpenTextFile("c:\list.txt", ForReading)
Set objlog = objfso.CreateTextFile("c:\log.txt", ForWriting)
Do Until objlist.AtEndOfStream
strComputer = objlist.ReadLine
If Reachable(strcomputer) Then
If per(strcomputer) then
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
On Error Resume Next
Set objInstance = objWMIService.Get("Win32_ScheduledJob.JobID=1")
If Err.Number = 0 Then
Err.Clear
On Error Goto 0
objlog.WriteLine "the job deleted on " & strcomputer
Else
objlog.WriteLine "the job didn't find on " & strcomputer
End if
Else
objlog.WriteLine "you don't have permission on " & strcomputer
End If
Else
objlog.WriteLine strcomputer & " isn't reachable"
End if
Loop
Function Reachable(strComputer)
strCmd = "ping -n 1 " & strComputer
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec(strCmd)
strTemp = UCase(objExec.StdOut.ReadAll)
If InStr(strTemp, "REPLY FROM") Then
Reachable = True
Else
Reachable = False
End If
End Function
Function per(computer)
strcomputer = computer
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
If err.number <> 0 Then
err.Clear
per = False
On Error goto 0
Else
per = True
On Error goto 0
End If
End Function
ASKER
How and what does the script delete. why i ask is there are machines that show 10 + scheduled scans as
AT1
AT2
AT3
and so on
Can we set to delete anything with AT
AT1
AT2
AT3
and so on
Can we set to delete anything with AT
sorry what i tryed with my knowledge it's only the job id
you can live the question open a new one and maybe one of ther other experts can help you
you can live the question open a new one and maybe one of ther other experts can help you
ASKER
Thank U
thanks you
ASKER
Any help on the 2 posts
Add Administrator to each group....