PowerShell : AT Commands Module
AT Command is an old DOS external command (not included in command.com) which enables users to schedule tasks on local/remote computer. You can use the AT command to schedule a command, a script, or a program to run at a specified date and time. You can also use this command to view existing scheduled tasks (Only AT Tasks).

Differences between OS versions
- Task scheduler in Vista and above needs to be refreshed in order to display new tasks, whereas in windows XP the refresh is automatically
- In Vista and above tasks are not deleted after expiration
- Dated tasks, in Vista and above Runs Repeatedly. Task in Windows XP can set to run once in a specific date.
- In Vista and above Tasks cannot run Interactively,I suppose Microsoft excluded this option for security reasons.
Prerequisites
To use AT Command, the Task Scheduler service must be running. and you must be logged on as a member of the local Administrators group (on local and remote machine)
PowerShell Module PowerShell version 2 doesn't include scheduled task cmdlets, so I wrote my own module which includes three advanced functions: New-AtTask, Get-AtTask and Remove-AtTask.
PowerShell version 3 includes many new and improved cmdlets, among them 'Scheduled Job' and 'Scheduled task' modules (Supported Operating Systems: Windows 7 Service Pack 1, Windows Server 2008 R2 SP1). You can download PowerShell version 3 CTP1 from HERE .
New-AtTask
Enables an administrator to create scheduled AT tasks on a local or remote system.
Tasks can be configured to run at a specific date or time, and can be specified to run repeatedly. You can schedule a task to run at selected days of the week or month.
If the InteractWithDesktop switch is specified, the job would be interactive (only on XP and lower versions).
C:\PS> Get-help New-ATTask –Full
Gets cmdlet full help

C:\PS> New-ATTask -Command "ipconfig /flushdns" -Time 11:40
Create a new AT Task on Remote computer, to flush dns cache at 11:40, Run only once


C:\PS> New-ATTask –Command "Cmd /c GPUpdate.exe" -Time 11:50 -ComputerName server1,server2,server3 -DayOfWeek Sunday,Thursday –RunRepeatedly
- OR-
C:\PS> "server1","server2","server3" | New-ATTask –Command "Cmd /c GPUpdate.exe" -Time 11:50 -DayOfWeek Sunday,Thursday –RunRepeatedly
Create new AT Task on server1,server2 and server3, to run GPUpdate at 11:50 next Sunday & next Thursday, every week

C:\PS> Get-Content d:\Computers.txt | Get-ATTask
Read computer list from Computers.txt file and Get AT Task list from each of them
Get-AtTask
Enables an administrator to get scheduled AT tasks from a local or remote systems.
C:\PS> Get-help Get-ATTask –Full
Gets CmdLet full help
C:\PS> Get-ATTask
Get AT Task list from local computer (only AT tasks).

C:\PS> "Server1","Server2" | Get-ATTask | Format-Table
-OR-
C:\PS> Get-ATTask –ComputerName Server1,Server2 | Format-Table

Remove-AtTask
Enables an administrator to remove scheduled AT tasks from a local or remote system.
C:\PS> Get-help Remove-ATTask –Full
Gets CmdLet full help
C:\PS> Remove-ATTask -JobID 2 -ComputerName Server1
Remove AT job number 2 from remote computer Server1, only if you are sure 

To avoid confirmation write the following command:
C:\PS> Remove-ATTask -JobID 2 -Confirm:$false
C:\PS> Get-ATTask -ComputerName Server1,Server2 | Where-Object {$_.Command -eq 'ipconfig /renew'} | Remove-ATTask -WhatIf
The above example shows what would have happen if the actual command would have run. It gets the AT Task list from Server1 and Server2 and filters jobs which have the 'ipconfig /renew' command.
Remove the WhatIf switch to actually run the command.
How to use
- Download and run the setup file
- Load the module – Import-Module ATCommands
