-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-managementArea - Microsoft.PowerShell.Management moduleArea - Microsoft.PowerShell.Management moduleissue-doc-ideaIssue - request for new contentIssue - request for new content
Milestone
Description
Prerequisites
- Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
- Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Document new
Get-Foocmdlet" instead of "New cmdlet."
Summary
Including examples for -OlderThan/-NewerThan parameters when using Test-Path cmdlet. I've included fixes in linked pull request and realised we need some more documentation for usage using these two parameters since usage is currently undocumented and the linked PR included new functionality on how to use both parameters to test if path exists in date range.
Details
Examples
Check if file is older than one day
> Test-Path -Path $file -OlderThan (Get-Date).AddDays(-1)
TrueCheck if file is newer than one hour
> Test-Path -Path $file -NewerThan (Get-Date).AddHours(-1)
TrueCheck if file is newer than two days and older than today - date range
> Test-Path -Path $file -NewerThan (Get-Date).AddDays(-2) -OlderThan (Get-Date)
TrueCan also include similar examples for using these parameters with -PathType as that is also supported in PR changes. There was an existing restriction with dynamic parameters which only allowed -OlderThan/-NewerThan to be used with TestPathType.Any.
Check if file (Leaf) is older than on day
> Test-Path -Path $file -OlderThan (Get-Date).AddDays(-1) -PathType Leaf
TrueCheck if directory (Container) is older than on day
> Test-Path -Path $dir -OlderThan (Get-Date).AddDays(-1) -PathType Container
TrueArticles
- reference/7.4/Microsoft.PowerShell.Management/Test-Path.md
Related Source Pull Requests
Related Source Issues
Metadata
Metadata
Assignees
Labels
area-managementArea - Microsoft.PowerShell.Management moduleArea - Microsoft.PowerShell.Management moduleissue-doc-ideaIssue - request for new contentIssue - request for new content