Skip to content

AboutCmdletVerbs.Koans.ps1 - Forward slash in $Filename results in wrong string comparison at the end #453

@DEberhardt

Description

@DEberhardt

Describe "Koan Bug, Issue, or Help Request"

minor typo...

AboutCmdletVerbs.Koans.ps1
Line 25: $FilePath = "$env:TMP/YOUR_PATH.txt"

This works to find the path all the way until the last assertion

Context "The Problematic Assertions"

        $Message = "Cannot find path '$FilePath' because it does not exist."
        { Remove-Item -Path $FilePath -ErrorAction Stop } | Should -Throw -ExpectedMessage $Message

Context "Your Attempts"

    The answers you seek...

Expected an exception, with message 'Cannot find path
'C:\Users\David\AppData\Local\Temp**/**YOUR_PATH.txt' because it does not exist.' to be
thrown, but the message was 'Cannot find path
'C:\Users\David\AppData\Local\Temp**\**YOUR_PATH.txt' because it does not exist.'. from
C:\Users\David\PSKoans\Introduction\AboutCmdletVerbs.Koans.ps1:286 char:15
    +             { Remove-Item -Path $FilePath -ErrorAction Stop } | Shoul ...
    +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Context "Additional Information"

My local Environment:

PowerShell Module Paths
C:\Users\David\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

PowerShell Version Table

Name                           Value
----                           -----
PSVersion                      5.1.19041.1023
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1023
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PowerShell Host

Name             : ConsoleHost
Version          : 5.1.19041.1023
InstanceId       : 3d2266c5-f8cb-40e4-8275-45dd17603f04
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterfa
                   ce
CurrentCulture   : en-GB
CurrentUICulture : en-GB
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Installed NET Frameworks



PSChildName                      Version        Release
-----------                      -------        -------
v2.0.50727                       2.0.50727.4927
v3.0                             3.0.30729.4926
Windows Communication Foundation 3.0.4506.4926
Windows Presentation Foundation  3.0.6920.4902
v3.5                             3.5.30729.4926
Client                           4.8.04084      528372
Full                             4.8.04084      528372
Client                           4.0.0.0



Relevant Modules (installed)

❯ Get-Module Pester

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     4.10.1     Pester                              {Add-AssertionOperator, ...


❯ Get-Module Pester -ListAvailable


    Directory: C:\Users\David\Documents\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     5.2.2      Pester                              {Invoke-Pester, Describe...
Script     5.2.1      Pester                              {Invoke-Pester, Describe...
Script     5.1.1      Pester                              {Invoke-Pester, Describe...
Script     4.10.1     Pester                              {Describe, Context, It, ...


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     3.4.0      Pester                              {Describe, Context, It, ...

Changing Line 25 to $FilePath = "$env:TMP\YOUR_PATH.txt" works for me.
Is this intentional to highlight? I did not think so as it isn't described...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions