diff --git a/MyTasks.psd1 b/MyTasks.psd1 index 64f4891..ef0ce21 100644 --- a/MyTasks.psd1 +++ b/MyTasks.psd1 @@ -4,120 +4,131 @@ @{ -# Script module or binary module file associated with this manifest. -RootModule = 'MyTasks.psm1' + # Script module or binary module file associated with this manifest. + RootModule = 'MyTasks.psm1' -# Version number of this module. -ModuleVersion = '2.0.0' + # Version number of this module. + ModuleVersion = '2.1.0' -CompatiblePSEditions = @("Desktop","Core") + CompatiblePSEditions = @("Desktop", "Core") -# ID used to uniquely identify this module -GUID = '6a5db6e0-9669-4178-a176-54b4931aa4e2' + # ID used to uniquely identify this module + GUID = '6a5db6e0-9669-4178-a176-54b4931aa4e2' -# Author of this module -Author = 'Jeff Hicks' + # Author of this module + Author = 'Jeff Hicks' -# Company or vendor of this module -CompanyName = 'JDH Information Technology Solutions, Inc.' + # Company or vendor of this module + CompanyName = 'JDH Information Technology Solutions, Inc.' -# Copyright statement for this module -Copyright = '(c) 2016-2019 JDH Information Technology Solutions, Inc. All rights reserved.' + # Copyright statement for this module + Copyright = '(c) 2016-2019 JDH Information Technology Solutions, Inc. All rights reserved.' -# Description of the functionality provided by this module -Description = 'A tool set for managing tasks or to-do projects in PowerShell. Task data is stored in XML and managed through a PowerShell class.' + # Description of the functionality provided by this module + Description = 'A tool set for managing tasks or to-do projects in PowerShell. Task data is stored in XML and managed through a PowerShell class.' -# Minimum version of the Windows PowerShell engine required by this module -PowerShellVersion = '5.1' + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '5.1' -# Name of the Windows PowerShell host required by this module -# PowerShellHostName = '' + # Name of the Windows PowerShell host required by this module + # PowerShellHostName = '' -# Minimum version of the Windows PowerShell host required by this module -# PowerShellHostVersion = '' + # Minimum version of the Windows PowerShell host required by this module + # PowerShellHostVersion = '' -# Minimum version of Microsoft .NET Framework required by this module -# DotNetFrameworkVersion = '' + # Minimum version of Microsoft .NET Framework required by this module + # DotNetFrameworkVersion = '' -# Minimum version of the common language runtime (CLR) required by this module -# CLRVersion = '' + # Minimum version of the common language runtime (CLR) required by this module + # CLRVersion = '' -# Processor architecture (None, X86, Amd64) required by this module -# ProcessorArchitecture = '' + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' -# Modules that must be imported into the global environment prior to importing this module -# RequiredModules = @() + # Modules that must be imported into the global environment prior to importing this module + # RequiredModules = @() -# Assemblies that must be loaded prior to importing this module -# RequiredAssemblies = @() + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() -# Script files (.ps1) that are run in the caller's environment prior to importing this module. -# ScriptsToProcess = @() + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() -# Type files (.ps1xml) to be loaded when importing this module -# TypesToProcess = @() + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() -# Format files (.ps1xml) to be loaded when importing this module -FormatsToProcess = "MyTasks.format.ps1xml","mytaskpath.format.ps1xml" + # Format files (.ps1xml) to be loaded when importing this module + FormatsToProcess = "MyTasks.format.ps1xml", "mytaskpath.format.ps1xml" -# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -# NestedModules = @() + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + # NestedModules = @() -# Functions to export from this module -FunctionsToExport = @("New-MyTask","Set-MyTask","Remove-MyTask","Get-MyTask", -"Show-MyTask","Complete-MyTask","Get-MyTaskCategory","Add-MyTaskCategory", -"Remove-MyTaskCategory","Backup-MyTaskFile","Save-MyTask","Enable-EmailReminder", -"Disable-EmailReminder","Get-EmailReminder","Set-MyTaskPath","Get-MyTaskArchive", -"Get-MyTaskPath") + # Functions to export from this module -# Cmdlets to export from this module -# CmdletsToExport = '*' + FunctionsToExport = if ($PSEdition -eq 'Desktop') { -# Variables to export from this module -VariablesToExport = @() -#'myTaskPath','myTaskDefaultCategories','myTaskArchivePath','mytaskhome','myTaskCategory' + @("New-MyTask", "Set-MyTask", "Remove-MyTask", "Get-MyTask", + "Show-MyTask", "Complete-MyTask", "Get-MyTaskCategory", "Add-MyTaskCategory", + "Remove-MyTaskCategory", "Backup-MyTaskFile", "Save-MyTask", "Enable-EmailReminder", + "Disable-EmailReminder", "Get-EmailReminder", "Set-MyTaskHome", "Get-MyTaskArchive", + "Get-MyTaskHome") -# Aliases to export from this module -AliasesToExport = 'gmt','smt','shmt','rmt','cmt','nmt','Archive-MyTask','task' +} else { + @("New-MyTask", "Set-MyTask", "Remove-MyTask", "Get-MyTask", + "Show-MyTask", "Complete-MyTask", "Get-MyTaskCategory", "Add-MyTaskCategory", + "Remove-MyTaskCategory", "Backup-MyTaskFile", "Save-MyTask", "Set-MyTaskHome", + "Get-MyTaskArchive","Get-MyTaskHome") +} + + # Cmdlets to export from this module + # CmdletsToExport = '*' + + # Variables to export from this module + VariablesToExport = @() + #'myTaskPath','myTaskDefaultCategories','myTaskArchivePath','mytaskhome','myTaskCategory' + + # Aliases to export from this module + AliasesToExport = 'gmt', 'smt', 'shmt', 'rmt', 'cmt', 'nmt', 'Archive-MyTask', 'task', + 'Get-MyTaskPath', 'Set-MyTaskPath' -# DSC resources to export from this module -# DscResourcesToExport = @() + # DSC resources to export from this module + # DscResourcesToExport = @() -# List of all modules packaged with this module -# ModuleList = @() + # List of all modules packaged with this module + # ModuleList = @() -# List of all files packaged with this module -# FileList = @() + # List of all files packaged with this module + # FileList = @() -# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. -PrivateData = @{ + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ - PSData = @{ + PSData = @{ - # Tags applied to this module. These help with module discovery in online galleries. - Tags = 'XML', 'ToDo', 'Projects','Tasks' + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'XML', 'ToDo', 'Projects', 'Tasks' - # A URL to the license for this module. - LicenseUri = 'https://github.com/jdhitsolutions/MyTasks/blob/master/LICENSE.txt' + # A URL to the license for this module. + LicenseUri = 'https://github.com/jdhitsolutions/MyTasks/blob/master/LICENSE.txt' - # A URL to the main website for this project. - ProjectUri = 'https://github.com/jdhitsolutions/MyTasks/' + # A URL to the main website for this project. + ProjectUri = 'https://github.com/jdhitsolutions/MyTasks/' - # A URL to an icon representing this module. - # IconUri = '' + # A URL to an icon representing this module. + # IconUri = '' - # ReleaseNotes of this module - ReleaseNotes = 'https://github.com/jdhitsolutions/MyTasks/blob/master/docs/about_MyTasks.md' + # ReleaseNotes of this module + ReleaseNotes = 'https://github.com/jdhitsolutions/MyTasks/blob/master/docs/about_MyTasks.md' - } # End of PSData hashtable + } # End of PSData hashtable -} # End of PrivateData hashtable + } # End of PrivateData hashtable -# HelpInfo URI of this module -# HelpInfoURI = '' + # HelpInfo URI of this module + # HelpInfoURI = '' -# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. -# DefaultCommandPrefix = '' + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' } diff --git a/MyTasks.psm1 b/MyTasks.psm1 index 0362a86..6e3944d 100644 --- a/MyTasks.psm1 +++ b/MyTasks.psm1 @@ -20,6 +20,9 @@ $script:myTaskDefaultCategories = "Work", "Personal", "Other", "Customer" #dot source functions . $psscriptroot\MyTasksFunctions.ps1 +if ($psedition -eq 'Desktop') { + . $psscriptroot\emailfunctions.ps1 +} $cmd = "Get-MyTask", "Set-MyTask", "Complete-MyTask", "Remove-MyTask" Register-ArgumentCompleter -CommandName $cmd -ParameterName Name -ScriptBlock { diff --git a/MyTasksFunctions.ps1 b/MyTasksFunctions.ps1 index bc9a754..e128968 100644 --- a/MyTasksFunctions.ps1 +++ b/MyTasksFunctions.ps1 @@ -1215,288 +1215,14 @@ Function Save-MyTask { } } -Function Enable-EmailReminder { - #this function requires the PSScheduledJob module - [cmdletbinding(SupportsShouldProcess)] - [OutputType("None")] - - Param( - [Parameter(Position = 0, HelpMessage = "What time do you want to send your daily email reminder?")] - [ValidateNotNullOrEmpty()] - [datetime]$Time = "8:00AM", - [Parameter(HelpMessage = "What is your email server name or address?")] - [ValidateNotNullOrEmpty()] - [string]$SMTPServer = $PSEmailServer, - [Parameter(Mandatory, HelpMessage = "Enter your email address")] - [ValidateNotNullOrEmpty()] - [ValidatePattern("\S+@*.\.\w{2,4}")] - [string]$To, - [Parameter(HelpMessage = "Enter the FROM email address. If you don't specify one, the TO address will be used.")] - [ValidatePattern("\S+@*.\.\w{2,4}")] - [string]$From, - [Parameter(HelpMessage = "Include if you need to use SSL?")] - [switch]$UseSSL, - [Parameter(HelpMessage = "Specify the port to use for your email server")] - [ValidateNotNullOrEmpty()] - [int32]$Port = 25, - [Parameter(HelpMessage = "Specify any credential you need to authenticate to your mail server.")] - [PSCredential]$MailCredential, - [Parameter(HelpMessage = "Send an HTML body email")] - [switch]$AsHtml, - [ValidateNotNullOrEmpty()] - [ValidateScript( {$_ -gt 0})] - [int]$Days = 3, - [Parameter(Mandatory, HelpMessage = "Re-enter your local user credentials for the scheduled job task")] - [ValidateNotNullOrEmpty()] - [PSCredential]$TaskCredential, - [ValidateNotNullOrEmpty()] - [string]$TaskPath = $mytaskHome - ) - Begin { - Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($myinvocation.mycommand)" - Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Using these mail parameters:" - - if (-Not $From) { - $From = $To - } - $hash = @{ - To = $To - From = $From - SMTPServer = $SMTPServer - Port = $Port - } - if ($MailCredential) { - $hash.Add("Credential", $MailCredential) - } - If ($UseSSL) { - $hash.add("UseSSL", $True) - } - - $hash | Out-String | Write-Verbose - #define the job scriptblock - $sb = { - Param([hashtable]$Hash, [int]$Days, [string]$myPath) - #uncomment Write-Host lines for troubleshooting - #$PSBoundParameters | out-string | write-host -ForegroundColor cyan - #get tasks for the next 3 days as the body - - Set-MyTaskPath -Path $myPath - #get-variable mytask* | out-string | Write-Host - write-host "[$((Get-Date).ToString())] Getting tasks for the next $days days." - $data = Get-MyTask -Days $Days - if ($data) { - if ($hash.BodyAsHTML) { - Write-Host "[$((Get-Date).ToString())] Sending as HTML" -ForegroundColor green - #css to be embedded in the html document - $head = @" -Upcoming Tasks - -
-

My Tasks

-"@ - [xml]$html = $data | ConvertTo-HTML -Fragment - - #parse html to add color attributes - for ($i = 1; $i -le $html.table.tr.count - 1; $i++) { - $class = $html.CreateAttribute("class") - #check the value of the percent free memory column and assign a class to the row - if ($html.table.tr[$i].td[4] -eq 'True') { - $class.value = "alert" - $html.table.tr[$i].Attributes.Append($class) | Out-Null - } - elseif ((($html.table.tr[$i].td[3] -as [DateTime]) - (Get-Date)).totalHours -le 24 ) { - $class.value = "warn" - $html.table.tr[$i].Attributes.Append($class) | Out-Null - } - } - - $Body = ConvertTo-HTML -body $html.InnerXml -Head $head | Out-String - - } - else { - Write-Host "[$((Get-Date).ToString())] Sending as TEXT" -ForegroundColor Green - $body = $data | Out-string - } - } - else { - Write-Warning "No tasks found due in the next $days days." - #bail out - return - } - $hash.Add("Body", $body) - $hash.Add("Subject", "Tasks Due in the Next $days Days") - $hash.Add("ErrorAction", "Stop") - Try { - Send-MailMessage @hash - #if you receive the job I wanted to display some sort of result - Write-Output "[$((Get-Date).ToString())] Message ($($hash.subject)) sent to $($hash.to) from $($hash.from)" - } - Catch { - throw $_ - } - } #define scriptblock - } #begin - - Process { - Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Testing for an existing job" - Try { - $job = Get-ScheduledJob -Name myTasksEmail -ErrorAction stop - if ($job) { - Write-Warning "An existing mail job was found. Please remove it first with Disable-EmailReminder and try again." - #bail out - return - } - } - Catch { - Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] No existing job found" - } - Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Validating Requirements" - if ((Get-Module PSScheduledJob) -And (($PSVersionTable.Platform -eq 'Win32NT') -OR ($PSVersionTable.PSEdition -eq 'Desktop'))) { - - Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Creating a Daily job trigger for $($Time.TimeofDay)" - $trigger = New-JobTrigger -Daily -At $Time - - $opt = New-ScheduledJobOption -RunElevated -RequireNetwork - Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Registering the scheduled job" - if ($AsHtml) { - $hash.Add("BodyAsHTML", $True) - } - #hash table of parameters to splat Register-ScheduledJob - $regParams = @{ - ScriptBlock = $sb - Name = "myTasksEmail" - Trigger = $Trigger - ArgumentList = $hash, $Days, $TaskPath - MaxResultCount = 5 - ScheduledJobOption = $opt - Credential = $TaskCredential - } - $regParams | Out-String | Write-Verbose - Register-ScheduledJob @regParams - } - else { - Write-Warning "This command requires the PSScheduledJob module on a Windows platform." - } - } #process - - End { - Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($myinvocation.mycommand)" - } #end -} #close Enable-MailReminder - -Function Disable-EmailReminder { - [cmdletbinding(SupportsShouldProcess)] - [OutputType("None")] - - Param() - Begin { - Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($myinvocation.mycommand)" - } #begin - - Process { - Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Processing" - if ((Get-Module PSScheduledJob) -And (($PSVersionTable.Platform -eq 'Win32NT') -OR ($PSVersionTable.PSEdition -eq 'Desktop'))) { - Try { - if (Get-ScheduledJob -Name myTasksEmail -ErrorAction stop) { - #The cmdlet appears to ignore -WhatIf so I'll handle it myself - if ($PSCmdlet.ShouldProcess("myTasksEmail")) { - Unregister-ScheduledJob -Name myTasksEmail -ErrorAction stop - } #should process - } #if task found - } - Catch { - Write-Warning "Can't find any matching scheduled jobs with the name 'myTasksEmail'." - } - } - else { - Write-Warning "This command requires the PSScheduledJob module on a Windows platform." - } - } #process - - End { - Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($myinvocation.mycommand)" - } #end - -} #close Disable-EmailReminder - -Function Get-EmailReminder { - [cmdletbinding()] - Param () - - Begin { - Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($myinvocation.mycommand)" - - } #begin - - Process { - Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting scheduled job myTasksEmail" - if ((Get-Module PSScheduledJob -ListAvailable) -And (($PSVersionTable.Platform -eq 'Win32NT') -OR ($PSVersionTable.PSEdition -eq 'Desktop'))) { - $t = Get-ScheduledJob myTasksEmail - - $hash = $t.InvocationInfo.Parameters[0].where( {$_.name -eq "argumentlist"}).value - - Try { - #get the last run - Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting last job run" - $last = Get-Job -name $t.name -Newest 1 -ErrorAction stop - } - Catch { - $last = [PSCustomObject]@{ - PSEndTime = "11/30/1999" -as [datetime] - State = "The task has not yet run" - } - } - [pscustomobject]@{ - Task = $t.Name - Frequency = $t.JobTriggers.Frequency - At = $t.JobTriggers.at.TimeOfDay - To = $hash.To - From = $hash.From - MailServer = $hash.SMTPServer - Port = $hash.Port - UseSSL = $hash.UseSSL - AsHTML = $hash.BodyAsHTML - LastRun = $last.PSEndTime - LastState = $last.State - Started = $last.psBeginTime - Ended = $last.psEndTime - Result = $last.output - Enabled = $t.Enabled - Errors = $last.Errors - Warnings = $last.warnings - } - } - else { - Write-Warning "This command requires the PSScheduledJob module on a Windows platform." - } - } #process - - End { - Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($myinvocation.mycommand)" - - } #end - -} #close Get-EmailReminder - -Function Set-MyTaskPath { +Function Set-MyTaskHome { [cmdletbinding(SupportsShouldProcess)] + [alias("Set-MyTaskPath")] [OutputType("None", [System.Management.Automation.PSVariable])] + Param( - [Parameter(Mandatory, HelpMessage = "Enter the path to your new myTaskPath directory")] + [Parameter(Mandatory, HelpMessage = "Enter the path to your new myTaskHome directory")] [ValidateScript( {Test-Path $_})] [string]$Path, [switch]$Passthru @@ -1520,8 +1246,9 @@ Function Set-MyTaskPath { } } #close Set-MyTaskPath -Function Get-MyTaskPath { +Function Get-MyTaskHome { [cmdletbinding()] + [Alias("Get-MyTaskPath")] Param() [PSCustomObject]@{ diff --git a/README.md b/README.md index 5625e01..bcfc39a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MyTasks -This PowerShell module is designed as a task or simple To-Do manager. The module contains several commands for working with tasks. It should work with both Windows PowerShell and PowerShell Core with a few limitations. You can install the latest version from the PowerShell Gallery. You will need the -Scope parameter for PowerShell Core. +This PowerShell module is designed as a task or simple To-Do manager. The module contains several commands for working with tasks. It should work with both Windows PowerShell and PowerShell Core with a few limitations. You can install the latest version from the PowerShell Gallery. You will need the `-Scope`parameter for PowerShell Core. ```powershell Install-Module MyTasks [-scope currentuser] @@ -10,18 +10,96 @@ Task data is stored in an XML file. Here are a few highlights. ## Class based -This module requires at least PowerShell version 5.0 since is uses a class definition for the task object. While you could use the object's properties and methods directly, you should use the appropriate module command. +This module uses a class definition for the task object and is designed to work on both Windows PowerShell and PowerShell Core. + +```powershell +Class MyTask { + + <# + A class to define a task or to-do item + #> + + #Properties + # ID and OverDue values are calculated at run time. + + [int]$ID + [string]$Name + [string]$Description + [datetime]$DueDate + [bool]$Overdue + [String]$Category + [ValidateRange(0, 100)][int]$Progress + hidden[bool]$Completed + hidden[datetime]$TaskCreated = (Get-Date) + hidden[datetime]$TaskModified + hidden[guid]$TaskID = (New-Guid) + + #Methods + + #set task as completed + [void]CompleteTask([datetime]$CompletedDate) { + Write-Verbose "[CLASS ] Completing task: $($this.name)" + $this.Completed = $True + $this.Progress = 100 + $this.Overdue = $False + $this.TaskModified = $CompletedDate + } + + #check if task is overdue and update + hidden [void]Refresh() { + Write-Verbose "[CLASS ] Refreshing task $($this.name)" + #only mark as overdue if not completed and today is greater than the due date + Write-Verbose "[CLASS ] Comparing $($this.DueDate) due date to $(Get-Date)" + + if ($This.completed) { + $this.Overdue = $False + } + elseif ((Get-Date) -gt $this.DueDate) { + $this.Overdue = $True + } + else { + $this.Overdue = $False + } + + } #refresh + + #Constructors + MyTask([string]$Name) { + Write-Verbose "[CLASS ] Constructing with name: $name" + $this.Name = $Name + $this.DueDate = (Get-Date).AddDays(7) + $this.TaskModified = (Get-Date) + $this.Refresh() + } + #used for importing from XML + MyTask([string]$Name, [datetime]$DueDate, [string]$Description, [string]$Category, [boolean]$Completed) { + Write-Verbose "[CLASS ] Constructing with due date, description and category" + $this.Name = $Name + $this.DueDate = $DueDate + $this.Description = $Description + $this.Category = $Category + $this.TaskModified = $this.TaskCreated + $this.Completed = $completed + $this.Refresh() + } + +} #end class definition +``` + +While you could use the object's properties and methods directly, you should use the appropriate module command. ## XML Data -All of the task information is stored in an XML file. The commands in this module will read in, update, and remove items as needed using PowerShell commands such as `Select-XML`. By default these files are stored in your Documents folder (on Windows systems) or in Home (on Linux). You can change the default location by using the [Set-myTaskPath](./docs/Set-MyTaskPath.md) command. This is helpful if you are sharing task information between laptops via a service like Dropbox. +All of the task information is stored in an XML file. The commands in this module will read in, update, and remove items as needed using PowerShell commands such as `Select-XML`. By default these files are stored in your Documents folder (on Windows systems) or in Home (on Linux). You can change the default location by using the [Set-myTaskHome](./docs/Set-MyTaskHome.md) command. This is helpful if you are sharing task information between laptops via a service like Dropbox. ```powershell -Set-MyTaskPath Drop:\mytasks\ +Set-MyTaskHome Drop:\mytasks\ ``` If you use this feature, you'll need to make sure you run this command before doing anything. It is recommended to put this command in a PowerShell profile script. +You shouldn't have to manage the module related variables directly. Use `Get-MyTaskHome` to view your current settings. + ## Categories The Task object includes a Category property. The module will define a default set of categories ("Work","Personal","Customer","Other"), but users can create their own by using the MyTaskCategory commands: @@ -100,7 +178,7 @@ Use the `Get-myTaskArchive` to view archived tasks. ## Email Reminders -If you are running this module on a Windows platform that includes the PSScheduledJob module, you can create a scheduled PowerShell job that will send you a daily email with tasks that are due in 3 days or less. The default is a plain text message but you can also send it as HTML. Use the [Enable-EmailReminder](./docs/Enable-EmailReminder.md) command to set up the job. +If you are running this module on Windows PowerShell that includes the PSScheduledJob module, you can create a scheduled PowerShell job that will send you a daily email with tasks that are due in 3 days or less. The default is a plain text message but you can also send it as HTML. Use the [Enable-EmailReminder](./docs/Enable-EmailReminder.md) command to set up the job. You should read full help and examples for all commands as well as the [about_MyTasks](./docs/about_MyTasks.md) help file. @@ -118,12 +196,12 @@ You should read full help and examples for all commands as well as the [about_My + [Enable-EmailReminder](docs/Enable-EmailReminder.md) + [Disable-EmailReminder](docs/Disable-EmailReminder.md) + [Get-EmailReminder](docs/Get-EmailReminder.md) -+ [Set-MyTaskPath](docs/Set-MyTaskPath.md) -+ [Get-MyTaskPath](docs/Get-MyTaskPath.md) ++ [Set-MyTaskHome](docs/Set-MyTaskHome.md) ++ [Get-MyTaskHome](docs/Get-MyTaskHome.md) + [Get-MyTaskArchive](docs/Get-MyTaskArchive.md) ## Limitations Please post any issues, questions or feature requests in the [Issues](https://github.com/jdhitsolutions/MyTasks/issues) section. -*last updated 20 February 2019* +*last updated 21 February 2019* diff --git a/Tests/MyTasks.module.tests.ps1 b/Tests/MyTasks.module.tests.ps1 index 7aa6d58..5a3b76d 100644 --- a/Tests/MyTasks.module.tests.ps1 +++ b/Tests/MyTasks.module.tests.ps1 @@ -4,6 +4,7 @@ if (Get-Module -Name MyTasks) { Import-Module -Name "$PSScriptRoot\..\Mytasks.psd1" -Force +Write-Host "These tests are designed for Windows PowerShell" -ForegroundColor yellow Describe 'MyTasks' { $Module = Get-Module -Name MyTasks @@ -11,8 +12,8 @@ Describe 'MyTasks' { $Module.ExportedFunctions.count | Should -Be 17 } - It 'should have 8 aliases command' { - $Module.ExportedAliases.Count | Should -Be 8 + It 'should have 10 aliases command' { + $Module.ExportedAliases.Count | Should -Be 10 } It 'should not export any variables' { @@ -60,9 +61,9 @@ Describe "Functions" { @{Name = 'Get-MyTaskCategory'} @{Name = 'Remove-MyTaskCategory'} @{Name = 'Backup-MyTaskFile'} - @{Name = 'Set-MyTaskPath'} + @{Name = 'Set-MyTaskHome'} @{Name = 'Get-myTaskArchive'} - @{Name = 'Get-MyTaskPath'} + @{Name = 'Get-MyTaskHome'} ) It " has external help defined with at least one example" -TestCases $cmds { @@ -171,8 +172,8 @@ Describe "Functions" { } } - Context 'Set-MyTaskPath' { - $cmd = Get-Command -Name Set-MyTaskPath + Context 'Set-MyTaskHome' { + $cmd = Get-Command -Name Set-MyTaskHome $params = "PATH" Foreach ($item in $params) { It "should have a mandatory $item parameter" { @@ -185,8 +186,8 @@ Describe "Functions" { } - Context 'Get-MyTaskPath' { - + Context 'Get-MyTaskHome' { + } } #describe functions \ No newline at end of file diff --git a/Tests/MyTasks.tests.ps1 b/Tests/MyTasks.tests.ps1 index 9612de5..190313f 100644 --- a/Tests/MyTasks.tests.ps1 +++ b/Tests/MyTasks.tests.ps1 @@ -5,11 +5,16 @@ if (Get-Module -Name MyTasks) { Import-Module -Name "$PSScriptRoot\..\Mytasks.psd1" -Force +Write-Host "These tests are designed for Windows PowerShell" -ForegroundColor yellow +$current = Get-Module myTasks +write-Host "Testing $($current.name) version $($current.Version)" -ForegroundColor yellow + + InModuleScope MyTasks { Describe 'Categories' { BeforeAll { - Set-MyTaskPath 'TestDrive:' + Set-MyTaskHome 'TestDrive:' } It 'has default categories "Work", "Personal", "Other", and "Customer"' { @@ -19,11 +24,11 @@ InModuleScope MyTasks { $script:myTaskDefaultCategories -join "-"| Should -Match "Other" $script:myTaskDefaultCategories -join "-"| Should -Match "Customer" } - + It 'keeps the default categories when a new one is added' { Add-MyTaskCategory -Category ToDo $Categories = Get-Content -Path $myTaskCategory -Raw - + $Categories | Should -Match 'Work' $Categories | Should -Match 'Personal' $Categories | Should -Match 'Other' @@ -34,7 +39,7 @@ InModuleScope MyTasks { It 'can add a Testing category to $myTaskCategory' { Add-MyTaskCategory -Category Testing $Categories = Get-Content -Path $myTaskCategory -Raw - + $myTaskCategory | Should -Exist $Categories | Should -Match 'Testing' } @@ -52,7 +57,7 @@ InModuleScope MyTasks { Remove-MyTaskCategory -Category Demo (Get-MyTaskCategory).Count| Should -Be 7 } - + } #describe my categories Describe 'Tasks' { @@ -62,8 +67,8 @@ InModuleScope MyTasks { #> $Due = (Get-Date).AddDays(30).Date - - Set-MyTaskPath -path 'TestDrive:' + + Set-MyTaskHome -path 'TestDrive:' Add-MyTaskCategory -Category Work, Personal, Other, Training, Testing @@ -81,8 +86,8 @@ InModuleScope MyTasks { } It 'should get tasks by name' { - $Task = Get-MyTask -Name Test1 - + $Task = Get-MyTask -Name Test1 + $Task.ID | Should -Be 2 $Task.Name | Should -Be "Test1" $Task.Category | Should -Be 'Testing' @@ -119,7 +124,7 @@ InModuleScope MyTasks { } It 'should modify a task via the pipeline' { - Get-MyTask -Name "Test1" | Set-MyTask -Progress 80 + Get-MyTask -Name "Test1" | Set-MyTask -Progress 80 $Task = Get-MyTask -Name Test1 $Task.Progress | Should -Be 80 } @@ -138,14 +143,14 @@ InModuleScope MyTasks { } Context 'Archive' { - + It 'should complete and archive a task' { {Complete-Mytask -Name Test2 -Archive -ErrorAction Stop} | Should -Not -Throw (Get-MyTask -All | Where-Object {-not $_.Completed}).Count | Should -Be 3 } It "should archive or save a task" { - Get-MyTask -Completed | Save-MyTask + Get-MyTask -Completed | Save-MyTask $myTaskArchivePath | Should -Exist Get-MyTask -Name Test1 -WarningAction SilentlyContinue | Should -BeNull (Get-MyTask -All).Count | Should -Be 3 @@ -156,15 +161,15 @@ InModuleScope MyTasks { $Alias.Name | Should -Be "Archive-MyTask" $Alias.Definition | Should -Be "Save-MyTask" } - } - + } + Context 'Backup' { It 'Should remove a task and backup the task file' { {Remove-MyTask -Name Alice } | Should -Not -Throw {Get-MyTask -Name Bob | Remove-MyTask } | Should -Not -Throw (Get-MyTask -All).Count | Should -Be 1 } - + It 'should backup the task file' { {Backup-MyTaskFile -ErrorAction Stop} | Should -Not -Throw 'TestDrive:\MyTasks_Backup_*.xml' | Should -Exist @@ -172,58 +177,58 @@ InModuleScope MyTasks { } } #describe my tasks - Describe 'Set-MyTaskPath' -Tag variables { + Describe 'Set-MyTaskHome' -Tag variables { BeforeAll { $NewFolder = New-Item -path $TestDrive -name MyTasks -ItemType Directory - Set-MyTaskPath -Path $NewFolder.Fullname + Set-MyTaskHome -Path $NewFolder.Fullname $target = $NewFolder.FullName.Replace("\", "\\") } - + $VariableTests = @( @{ Variable = 'myTaskArchivePath' } @{ Variable = 'myTaskCategory' } @{ Variable = 'mytaskhome' } @{ Variable = 'mytaskPath' } ) - + It "should update " -TestCases $VariableTests { param($Variable) Get-Variable $Variable -ValueOnly | Should -Match "^$target" } } #describe task variables - + Describe EmailSettings { <# not mocking New-JobTrigger or New-ScheduledJobOption Also assuming Pester test is being run on a platform where this will be true - if ((Get-Module PSScheduledJob) -And (($PSVersionTable.Platform -eq 'Win32NT') -OR ($PSVersionTable.PSEdition -eq 'Desktop'))) + if ((Get-Module PSScheduledJob) -And (($PSVersionTable.Platform -eq 'Win32NT') -OR ($PSVersionTable.PSEdition -eq 'Desktop'))) #> Mock Register-ScheduledJob { 1 } -Verifiable Mock Unregister-ScheduledJob {} -Verifiable Mock Get-ScheduledJob { $False } -ParameterFilter {$Name -eq "myTasksEmail"} - + #create a credential $Password = ConvertTo-SecureString -String "Password" -AsPlainText -Force $Credential = [PSCredential]::new("localhost\me", $Password) - + It 'should require a standard email address' { {Enable-EmailReminder -To foo@company.com -TaskCredential $Credential } | Should -Not -Throw {Enable-EmailReminder -To foo -TaskCredential $Credential} | Should -Throw - } - + } + It 'should register a scheduled job' { - $Reminders = Enable-EmailReminder -To foo@company.com -TaskCredential $Credential + $Reminders = Enable-EmailReminder -To foo@company.com -TaskCredential $Credential $Reminders.Count | Should -Be 1 - + Assert-MockCalled Register-ScheduledJob - } + } It 'should fail if a job already exists' { Mock Get-ScheduledJob { $True } -ParameterFilter {$Name -eq "myTasksEmail"} $Reminders = Enable-EmailReminder -To foo@company.com -TaskCredential $Credential -WarningAction SilentlyContinue $reminders | out-string | write-host -ForegroundColor cyan $Reminders.Count | Should -Be 0 - } + } It 'should get a job result' { Mock Get-ScheduledJob { @@ -259,14 +264,14 @@ InModuleScope MyTasks { } -ParameterFilter {$Name -eq "myTasksEmail" -and $Newest -eq 1} -Verifiable $Reminder = Get-EmailReminder - + Assert-MockCalled Get-ScheduledJob Assert-MockCalled Get-Job - + $Reminder | Should -BeOfType PSCustomobject $Reminder.Task | Should -Be "myTasksEmail" $Reminder.LastState | Should -Be "Completed" - } + } It 'should remove the email job' { Mock Get-ScheduledJob { @@ -274,7 +279,8 @@ InModuleScope MyTasks { } -ParameterFilter {$Name -eq 'myTasksEmail'} {Disable-EmailReminder} | Should -Not -Throw Assert-MockCalled Unregister-ScheduledJob - } - } #describe email settings + } + } #describe email settings } #in module scope + diff --git a/changelog.md b/changelog.md index a87e76d..ca75535 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,14 @@ # Change Log for MyTasks +## v2.1.0 + ++ Renamed `Set-MyTaskPath` to `Set-MyTaskHome` and set original name as an alias. (Issue #38) ++ Renamed `Get-MyTaskPath` to `Get-MyTaskHome` and set original name as an alias. (Issue #38) ++ Restructured module to better accommodate Desktop vs Core PSEditions (Issue #37) ++ Manifest updates ++ documentation updates ++ updated pester tests + ## v2.0.0 + Updated manifest to require PowerShell 5.1 and support for both Desktop and Core PSEditions *Breaking Change* diff --git a/docs/Get-MyTaskPath.md b/docs/Get-MyTaskHome.md similarity index 93% rename from docs/Get-MyTaskPath.md rename to docs/Get-MyTaskHome.md index 9d0372f..769faa5 100644 --- a/docs/Get-MyTaskPath.md +++ b/docs/Get-MyTaskHome.md @@ -5,7 +5,7 @@ online version: schema: 2.0.0 --- -# Get-MyTaskPath +# Get-MyTaskHome ## SYNOPSIS @@ -14,7 +14,7 @@ Get current values of the myTask variables ## SYNTAX ```yaml -Get-MyTaskPath [] +Get-MyTaskHome [] ``` ## DESCRIPTION @@ -26,7 +26,7 @@ The myTasks module relies on a number of global variables to keep track of the n ### Example 1 ```powershell -PS C:\> get-mytaskpath +PS C:\> Get-MyTaskHome myTaskHome : C:\Users\Jeff\dropbox\mytasks @@ -59,4 +59,4 @@ http://jdhitsolutions.com/blog/essential-powershell-resources/ ## RELATED LINKS -[Set-MyTaskPath]() \ No newline at end of file +[Set-MyTaskHome]() \ No newline at end of file diff --git a/docs/Set-MyTaskPath.md b/docs/Set-MyTaskHome.md similarity index 91% rename from docs/Set-MyTaskPath.md rename to docs/Set-MyTaskHome.md index daaeb9a..5f534ca 100644 --- a/docs/Set-MyTaskPath.md +++ b/docs/Set-MyTaskHome.md @@ -5,7 +5,7 @@ online version: schema: 2.0.0 --- -# Set-MyTaskPath +# Set-MyTaskHome ## SYNOPSIS @@ -14,7 +14,7 @@ Update the myTask variables ## SYNTAX ```yaml -Set-MyTaskPath [-Path] [-Passthru] [-WhatIf] [-Confirm] [] +Set-MyTaskHome [-Path] [-Passthru] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -28,7 +28,7 @@ It is recommended that you modify your PowerShell profile to import this module ### Example 1 ```powershell -PS C:\> Set-MyTaskpath -path c:\users\pat\dropbox\tasks +PS C:\> Set-MyTaskHome -path c:\users\pat\dropbox\tasks ``` This will put all of the task files in the Dropbox folder and update the corresponding variables. @@ -53,7 +53,7 @@ Accept wildcard characters: False ### -Path -Enter the path to your new myTaskPath directory. +Enter the path to your new myTaskHome directory. ```yaml Type: String @@ -117,4 +117,6 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell ## RELATED LINKS -[Get-MyTask]() \ No newline at end of file +[Get-MyTask]() + +[Get-MyTaskHome]() \ No newline at end of file diff --git a/docs/about_MyTasks.md b/docs/about_MyTasks.md index 64770af..b5f8a81 100644 --- a/docs/about_MyTasks.md +++ b/docs/about_MyTasks.md @@ -56,7 +56,10 @@ referenced via the myTaskArchivePath variable. NOTE: Starting with version 2.0.0 of this module the home location is determined by using [Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments) -Use the `Get-MyTaskPath` command to view your current settings. +Use the `Get-MyTaskHome` command to view your current settings. Use the +`Set-MyTaskHome` to modify the home variable. All other variables will be set +from that. + As tasks are created, modified, completed and archived, these XML files are updated. `Select-XML` is used extensively to make this process as efficient as @@ -195,7 +198,7 @@ Use the `Get-MyTaskArchive` to retrieve archived tasks. ### Email Reminder - If you are running this module on a Windows platform with the PSScheduled +If you are running this module on Windows PowerShell with the PSScheduled jobs module you can create a scheduled PowerShell job to send a daily email message showing tasks that are due in the next 3 days or whatever you choose. The default behavior is to send a text message but you can send an HTML diff --git a/emailfunctions.ps1 b/emailfunctions.ps1 new file mode 100644 index 0000000..b062cef --- /dev/null +++ b/emailfunctions.ps1 @@ -0,0 +1,276 @@ +Function Enable-EmailReminder { + #this function requires the PSScheduledJob module + [cmdletbinding(SupportsShouldProcess)] + [OutputType("None")] + + Param( + [Parameter(Position = 0, HelpMessage = "What time do you want to send your daily email reminder?")] + [ValidateNotNullOrEmpty()] + [datetime]$Time = "8:00AM", + [Parameter(HelpMessage = "What is your email server name or address?")] + [ValidateNotNullOrEmpty()] + [string]$SMTPServer = $PSEmailServer, + [Parameter(Mandatory, HelpMessage = "Enter your email address")] + [ValidateNotNullOrEmpty()] + [ValidatePattern("\S+@*.\.\w{2,4}")] + [string]$To, + [Parameter(HelpMessage = "Enter the FROM email address. If you don't specify one, the TO address will be used.")] + [ValidatePattern("\S+@*.\.\w{2,4}")] + [string]$From, + [Parameter(HelpMessage = "Include if you need to use SSL?")] + [switch]$UseSSL, + [Parameter(HelpMessage = "Specify the port to use for your email server")] + [ValidateNotNullOrEmpty()] + [int32]$Port = 25, + [Parameter(HelpMessage = "Specify any credential you need to authenticate to your mail server.")] + [PSCredential]$MailCredential, + [Parameter(HelpMessage = "Send an HTML body email")] + [switch]$AsHtml, + [ValidateNotNullOrEmpty()] + [ValidateScript( {$_ -gt 0})] + [int]$Days = 3, + [Parameter(Mandatory, HelpMessage = "Re-enter your local user credentials for the scheduled job task")] + [ValidateNotNullOrEmpty()] + [PSCredential]$TaskCredential, + [ValidateNotNullOrEmpty()] + [string]$TaskPath = $mytaskHome + ) + Begin { + Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($myinvocation.mycommand)" + Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Using these mail parameters:" + + if (-Not $From) { + $From = $To + } + $hash = @{ + To = $To + From = $From + SMTPServer = $SMTPServer + Port = $Port + } + if ($MailCredential) { + $hash.Add("Credential", $MailCredential) + } + If ($UseSSL) { + $hash.add("UseSSL", $True) + } + + $hash | Out-String | Write-Verbose + #define the job scriptblock + $sb = { + Param([hashtable]$Hash, [int]$Days, [string]$myPath) + #uncomment Write-Host lines for troubleshooting + #$PSBoundParameters | out-string | write-host -ForegroundColor cyan + #get tasks for the next 3 days as the body + + Set-MyTaskPath -Path $myPath + #get-variable mytask* | out-string | Write-Host + write-host "[$((Get-Date).ToString())] Getting tasks for the next $days days." + $data = Get-MyTask -Days $Days + if ($data) { + if ($hash.BodyAsHTML) { + Write-Host "[$((Get-Date).ToString())] Sending as HTML" -ForegroundColor green + #css to be embedded in the html document + $head = @" +Upcoming Tasks + +
+

My Tasks

+"@ + [xml]$html = $data | ConvertTo-HTML -Fragment + + #parse html to add color attributes + for ($i = 1; $i -le $html.table.tr.count - 1; $i++) { + $class = $html.CreateAttribute("class") + #check the value of the percent free memory column and assign a class to the row + if ($html.table.tr[$i].td[4] -eq 'True') { + $class.value = "alert" + $html.table.tr[$i].Attributes.Append($class) | Out-Null + } + elseif ((($html.table.tr[$i].td[3] -as [DateTime]) - (Get-Date)).totalHours -le 24 ) { + $class.value = "warn" + $html.table.tr[$i].Attributes.Append($class) | Out-Null + } + } + + $Body = ConvertTo-HTML -body $html.InnerXml -Head $head | Out-String + + } + else { + Write-Host "[$((Get-Date).ToString())] Sending as TEXT" -ForegroundColor Green + $body = $data | Out-string + } + } + else { + Write-Warning "No tasks found due in the next $days days." + #bail out + return + } + $hash.Add("Body", $body) + $hash.Add("Subject", "Tasks Due in the Next $days Days") + $hash.Add("ErrorAction", "Stop") + Try { + Send-MailMessage @hash + #if you receive the job I wanted to display some sort of result + Write-Output "[$((Get-Date).ToString())] Message ($($hash.subject)) sent to $($hash.to) from $($hash.from)" + } + Catch { + throw $_ + } + } #define scriptblock + } #begin + + Process { + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Testing for an existing job" + Try { + $job = Get-ScheduledJob -Name myTasksEmail -ErrorAction stop + if ($job) { + Write-Warning "An existing mail job was found. Please remove it first with Disable-EmailReminder and try again." + #bail out + return + } + } + Catch { + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] No existing job found" + } + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Validating Requirements" + if ((Get-Module PSScheduledJob) -And (($PSVersionTable.Platform -eq 'Win32NT') -OR ($PSVersionTable.PSEdition -eq 'Desktop'))) { + + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Creating a Daily job trigger for $($Time.TimeofDay)" + $trigger = New-JobTrigger -Daily -At $Time + + $opt = New-ScheduledJobOption -RunElevated -RequireNetwork + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Registering the scheduled job" + if ($AsHtml) { + $hash.Add("BodyAsHTML", $True) + } + #hash table of parameters to splat Register-ScheduledJob + $regParams = @{ + ScriptBlock = $sb + Name = "myTasksEmail" + Trigger = $Trigger + ArgumentList = $hash, $Days, $TaskPath + MaxResultCount = 5 + ScheduledJobOption = $opt + Credential = $TaskCredential + } + $regParams | Out-String | Write-Verbose + Register-ScheduledJob @regParams + } + else { + Write-Warning "This command requires the PSScheduledJob module on a Windows platform." + } + } #process + + End { + Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($myinvocation.mycommand)" + } #end + +} #close Enable-MailReminder + +Function Disable-EmailReminder { + [cmdletbinding(SupportsShouldProcess)] + [OutputType("None")] + + Param() + Begin { + Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($myinvocation.mycommand)" + } #begin + + Process { + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Processing" + if ((Get-Module PSScheduledJob) -And (($PSVersionTable.Platform -eq 'Win32NT') -OR ($PSVersionTable.PSEdition -eq 'Desktop'))) { + Try { + if (Get-ScheduledJob -Name myTasksEmail -ErrorAction stop) { + #The cmdlet appears to ignore -WhatIf so I'll handle it myself + if ($PSCmdlet.ShouldProcess("myTasksEmail")) { + Unregister-ScheduledJob -Name myTasksEmail -ErrorAction stop + } #should process + } #if task found + } + Catch { + Write-Warning "Can't find any matching scheduled jobs with the name 'myTasksEmail'." + } + } + else { + Write-Warning "This command requires the PSScheduledJob module on a Windows platform." + } + } #process + + End { + Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($myinvocation.mycommand)" + } #end + +} #close Disable-EmailReminder + +Function Get-EmailReminder { + [cmdletbinding()] + Param () + + Begin { + Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($myinvocation.mycommand)" + + } #begin + + Process { + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting scheduled job myTasksEmail" + if ((Get-Module PSScheduledJob -ListAvailable) -And (($PSVersionTable.Platform -eq 'Win32NT') -OR ($PSVersionTable.PSEdition -eq 'Desktop'))) { + $t = Get-ScheduledJob myTasksEmail + + $hash = $t.InvocationInfo.Parameters[0].where( {$_.name -eq "argumentlist"}).value + + Try { + #get the last run + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting last job run" + $last = Get-Job -name $t.name -Newest 1 -ErrorAction stop + } + Catch { + $last = [PSCustomObject]@{ + PSEndTime = "11/30/1999" -as [datetime] + State = "The task has not yet run" + } + } + [pscustomobject]@{ + Task = $t.Name + Frequency = $t.JobTriggers.Frequency + At = $t.JobTriggers.at.TimeOfDay + To = $hash.To + From = $hash.From + MailServer = $hash.SMTPServer + Port = $hash.Port + UseSSL = $hash.UseSSL + AsHTML = $hash.BodyAsHTML + LastRun = $last.PSEndTime + LastState = $last.State + Started = $last.psBeginTime + Ended = $last.psEndTime + Result = $last.output + Enabled = $t.Enabled + Errors = $last.Errors + Warnings = $last.warnings + } + } + else { + Write-Warning "This command requires the PSScheduledJob module on a Windows platform." + } + } #process + + End { + Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($myinvocation.mycommand)" + + } #end + +} #close Get-EmailReminder \ No newline at end of file diff --git a/en-US/MyTasks-help.xml b/en-US/MyTasks-help.xml index 219166a..cd0903a 100644 --- a/en-US/MyTasks-help.xml +++ b/en-US/MyTasks-help.xml @@ -1780,9 +1780,9 @@ Customer - Get-MyTaskPath + Get-MyTaskHome Get - MyTaskPath + MyTaskHome Get current values of the myTask variables @@ -1792,7 +1792,7 @@ Customer - Get-MyTaskPath + Get-MyTaskHome @@ -1824,7 +1824,7 @@ Customer -------------------------- Example 1 -------------------------- - PS C:\> get-mytaskpath + PS C:\> Get-MyTaskHome myTaskHome : C:\Users\Jeff\dropbox\mytasks @@ -1838,7 +1838,7 @@ myTaskCategory : C:\Users\Jeff\dropbox\mytasks\myTaskCategory.txt - Set-MyTaskPath + Set-MyTaskHome @@ -3279,9 +3279,9 @@ ID Name Description DueDate OverDue Category - Set-MyTaskPath + Set-MyTaskHome Set - MyTaskPath + MyTaskHome Update the myTask variables @@ -3292,11 +3292,11 @@ ID Name Description DueDate OverDue Category - Set-MyTaskPath + Set-MyTaskHome Path - Enter the path to your new myTaskPath directory. + Enter the path to your new myTaskHome directory. String @@ -3356,7 +3356,7 @@ ID Name Description DueDate OverDue Category Path - Enter the path to your new myTaskPath directory. + Enter the path to your new myTaskHome directory. String @@ -3418,7 +3418,7 @@ ID Name Description DueDate OverDue Category -------------------------- Example 1 -------------------------- - PS C:\> Set-MyTaskpath -path c:\users\pat\dropbox\tasks + PS C:\> Set-MyTaskHome -path c:\users\pat\dropbox\tasks This will put all of the task files in the Dropbox folder and update the corresponding variables. @@ -3429,6 +3429,10 @@ ID Name Description DueDate OverDue Category Get-MyTask + + Get-MyTaskHome + + diff --git a/en-US/about_mytasks.help.txt b/en-US/about_mytasks.help.txt index 77aba7c..56823b6 100644 --- a/en-US/about_mytasks.help.txt +++ b/en-US/about_mytasks.help.txt @@ -51,7 +51,9 @@ LONG DESCRIPTION NOTE: Starting with version 2.0.0 of this module the home location is determined by using [Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments) - Use the `Get-MyTaskPath` command to view your current settings. + Use the `Get-MyTaskHome` command to view your current settings. Use the + Set-MyTaskHome to modify the home variable. All other variables will be set + from that. As tasks are created, modified, completed and archived, these XML files are updated. Select-XML is used extensively to make this process as efficient @@ -183,7 +185,7 @@ LONG DESCRIPTION Use the `Get-MyTaskArchive` to retrieve archived tasks. EMAIL REMINDER - If you are running this module on a Windows platform with the PSScheduled + If you are running this module on Windows PowerShell with the PSScheduled jobs module you can create a scheduled PowerShell job to send a daily email message showing tasks that are due in the next 3 days or whatever you choose. The default behavior is to send a text message but you can send an