Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure-Command cmdlet Hides Variable Use #1644

Closed
Jlcsk8r opened this issue Mar 1, 2021 · 1 comment
Closed

Measure-Command cmdlet Hides Variable Use #1644

Jlcsk8r opened this issue Mar 1, 2021 · 1 comment

Comments

@Jlcsk8r
Copy link

Jlcsk8r commented Mar 1, 2021

Before 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

#You do not need to run the code, just enter it into the Visual Studio Code console.

$TimeToGetUsers = Measure-Command {$TargetUsers = get-aduser -server some.domain.com -SearchScope OneLevel}
$TotalUsers     = $TargetUsers.Count
$TargetUsers
Write-Host ('Found ' + $TotalUsers + ' Users in ' + $TimeToGetUsers.TotalSeconds + ' seconds.') -ForegroundColor Green

Expected behavior

No error on variable assignment or use.

Actual behavior

The variable 'TargetUsers' is assigned but never used.

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.17763.1490
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.1490
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

and 

Name                           Value
----                           -----
PSVersion                      7.1.2
PSEdition                      Core
GitCommitId                    7.1.2
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }

1.19.0
@ghost ghost added the Needs: Triage 🔍 label Mar 1, 2021
@rjmholt
Copy link
Contributor

rjmholt commented Mar 1, 2021

Duplicate of #1163.

See #1641.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants