<# .Synopsis Create-BasicTask cmdlet registers a scheduled task definition on a local computer .DESCRIPTION Creating basic scheduled task in Windows - this will not configure it for Windows 10 .EXAMPLE TaskPath TaskName State -------- -------- ----- \ Win32_LogicalDisk Ready .SYNTAX Create-BasicTask [[-execute] ] [[-argument] ] [[-MultipleInstances] ] [[-description] ] [[-taskname] ] []] .PARAMETERS -LogonType Required? false Position? 2 Accept pipeline input? true (ByValue, ByPropertyName, FromRemainingArguments) Parameter set name (All) Aliases None Dynamic? false -MultipleInstances Required? false Position? 2 Accept pipeline input? true (ByValue, ByPropertyName, FromRemainingArguments) Parameter set name (All) Aliases None Dynamic? false -RunLevel Required? false Position? 2 Accept pipeline input? true (ByValue, ByPropertyName, FromRemainingArguments) Parameter set name (All) Aliases None Dynamic? false -argument Required? false Position? 1 Accept pipeline input? true (ByValue, ByPropertyName, FromRemainingArguments) Parameter set name (All) Aliases None Dynamic? false -description Required? false Position? 3 Accept pipeline input? true (ByValue, ByPropertyName, FromRemainingArguments) Parameter set name (All) Aliases None Dynamic? false -execute Required? false Position? 0 Accept pipeline input? true (ByValue, ByPropertyName, FromRemainingArguments) Parameter set name (All) Aliases None Dynamic? false -taskname Required? false Position? 4 Accept pipeline input? true (ByValue, ByPropertyName, FromRemainingArguments) Parameter set name (All) Aliases None Dynamic? false -time Required? false Position? 2 Accept pipeline input? true (ByValue, ByPropertyName, FromRemainingArguments) Parameter set name (All) Aliases None Dynamic? false -userID Required? false Position? 2 Accept pipeline input? true (ByValue, ByPropertyName, FromRemainingArguments) Parameter set name (All) Aliases None Dynamic? false This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216). .INPUTS System.String .OUTPUTS System.Object .NOTES .COMPONENT .ROLE .FUNCTIONALITY .Aliases cbs Basic-Task New-BasicTask .REMARKS None .LINKS None #> function Create-BasicTask{ [CmdletBinding( ConfirmImpact='Medium')] [Alias("cbs","Basic-Task", "New-BasicTask")] Param ( [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$true, Position=0)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [string]$execute="Powershell.exe", [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$true, Position=1)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [string]$argument="C:\scripts\Win32_LogicalDisk.ps1", [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$true, Position=2)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [string]$time="9PM" , [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$true, Position=3)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [string]$userID="NT AUTHORITY\SYSTEM" , [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$true, Position=4)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [string]$LogonType="ServiceAccount" , [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$true, Position=2)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [string]$RunLevel="Highest" , [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$true, Position=5)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [string]$MultipleInstances="Parallel" , [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$true, Position=6)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [string]$description="TESTWin32_LogicalDisk", [Parameter(Mandatory=$false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, ValueFromRemainingArguments=$true, Position=7)] [ValidateNotNull()] [ValidateNotNullOrEmpty()] [string]$taskname=$description ) Begin { $action = New-ScheduledTaskAction -Execute $execute -Argument $argument $trigger = New-ScheduledTaskTrigger -Daily -At $time $principal = New-ScheduledTaskPrincipal -UserID $userID -LogonType $LogonType -RunLevel $RunLevel $settings = New-ScheduledTaskSettingsSet -MultipleInstances $MultipleInstances Register-ScheduledTask -Action $action -Description $description -Trigger $trigger -TaskName $taskname -Settings $settings -Principal $principal } Process { } End { } } Create-BasicTask # SIG # Begin signature block # MIIFagYJKoZIhvcNAQcCoIIFWzCCBVcCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUYwDy98bdery1Z9Rw3IcE842x # UwSgggMGMIIDAjCCAeqgAwIBAgIQEtSZ1T/kOptFn60oc6QVGTANBgkqhkiG9w0B # AQsFADAZMRcwFQYDVQQDDA5HbyBMaXZlIFVLIEx0ZDAeFw0yMjA3MTYxMTU4MDRa # Fw0yNzA3MTUyMTAwMDBaMBkxFzAVBgNVBAMMDkdvIExpdmUgVUsgTHRkMIIBIjAN # BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6sGeW+q3SYpKYZDPQu7JlI3+EWSP # CoyXoSwzgC1SpE6vkEJYv0A4INSi4qRpiZhx7bxEREB9nDEWZTLhnXj55xe/0f6Z # 1Xvszi9AZb0S7Hs9rIdPOYI0+FCLLauKShC7re2Gb7Yneh1GOnyLBzilj4tf2NIL # SgaVBSS1UOH50i+MXwsBBjtGuIX8mipoGFXz2KQB7RLg0f8B4fM17X/to9/Mvh64 # LkJ641g9YbfG8hMyV49GgtOamJ8Vs0hc5M5k2T01Xen1ohDH7CT7N2MJ8DZdHWyE # T7HCc3DFihGiELCDTL8mSeCW/9y0IZfGe/wXjswN5lumVkmg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