Skip to content

New-Item ignore's Path param if Name param is specified #5228

@affieuk

Description

@affieuk

Steps to reproduce

Set-Location ~
New-Item -Path C:\ -Name Test -ItemType Directory -Verbose

Expected behavior

Test folder created in Root C:\

Actual behavior

Folder created in current path
PS C:\Users\Aftab> New-Item -Path C:\ -Name Test -ItemType Directory -Verbose
VERBOSE: Performing the operation "Create Directory" on target "Destination: C:\Users\Aftab\Test".


    Directory: C:\Users\Aftab


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       25/10/2017     13:51                Test


PS C:\Users\Aftab> Get-Item C:\Test
Get-Item : Cannot find path 'C:\Test' because it does not exist.
At line:1 char:1
+ Get-Item C:\Test
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Test:String) [Get-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

PS C:\Users\Aftab> Get-Item ~\Test


    Directory: C:\Users\Aftab


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       25/10/2017     13:51                Test

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.0.0-beta.8
PSEdition                      Core
GitCommitId                    v6.0.0-beta.8
OS                             Microsoft Windows 10.0.15063
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions