Redirection is treated as PSPossibleIncorrectUsageOfRedirectionOperator
See original GitHub issueBefore submitting a bug report:
- Make sure you are able to repro it on the latest released version
- Perform a quick search for existing issues to check if this bug has already been reported
Steps to reproduce
Line that triggers this message:
if (Get-ScheduledTask -TaskName $name 2>$null)
Expected behavior
No errors
Actual behavior
PSPossibleIncorrectUsageOfRedirecti Warning Tasks.ps1 64 Did you mean to use the redirection operator '>'? The
onOperator comparison operators in PowerShell are '-gt' (greater than)
or '-ge' (greater or equal).
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.2364
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.2364
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.21.0
Issue Analytics
- State:
- Created 9 months ago
- Comments:5
Top Results From Across the Web
Redirects and Google Search
Redirecting URLs is the practice of resolving an existing URL to a different one, effectively telling your visitors and Google Search that a...
Read more >Redirects: How To Use, SEO Impact & Types (301 vs 302)
Redirection is the process of forwarding one URL to a different URL. What is a redirect? A redirect is a way to send...
Read more >301 Redirects Explained: How They Impact SEO
301 redirects are pretty simple. They're used to redirect one webpage to another. But understanding how they relate to SEO is more complicated....
Read more >URL Redirects For SEO: A Technical Guide
A URL redirect involves code implemented to a specific URL, or a group of URLs so that the user (or search engine) is...
Read more >How to Get More Traffic from 301 Redirects
He has always said that redirects to the homepage or non-relevant pages can be treated as soft 404s. That means Google will essentially...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Why do you expect no errors? The whole point of the rule is to warn around possible unintentional usage of redirect operator (often the user meant to use
-gt
operator) in an if statement. Therefore if you know that this is what you want, then you are meant to suppress it, this way you can also document the rev of the warn in code. The only thing we could try and see if we can do is whether we can detect that a specific stream redirection is happening like in this case because it’s more about in that case that the user did it deliberately.I’ve discovered a better way to handle error messages (
-ErrorAction SilentlyContinue
), so I’m closing this.