Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - Inconsistent behaviour when using set-location with different providers

Reply
 
Old 01-21-2007   #1 (permalink)
Andrew Watt [MVP]
Guest


 
 

Inconsistent behaviour when using set-location with different providers

Try the following commands. I would be interesed if you can confirm
the same inconsistencies in behaviour that I show below.

There are three issues that I see:

1. Why does providing the provider name (or not) in the command affect
what is displayed in the prompt?

2. Why is the behaviour of the FileSystem provider and Registry
provider different? Is the inconsistency a bug?

3. Why does set-location C: and set-location FileSystem::C: take you
to different folders? Bug?

PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
PS HKLM:\> set-location C:

So far so good. But when you provide the name of the provider it
appears in the prompt.

PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM

If you omit the colon with the FileSystem provider you can an error.

PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
FileSystem::C
Set-Location : Cannot find path 'C' because it does not exist.
At line:1 char:13
+ set-location <<<< FileSystem::C

But it works with the colon in place.

PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
FileSystem::C:

Providing the colon with the Registry provider produces an error (the
FileSystem equivalent worked).

PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
Registry::HKLM:
Set-Location : Cannot find path 'HKLM:' because it does not exist.
At line:1 char:13
+ set-location <<<< Registry::HKLM:

For convenience here are the commands with no interpolated comment:

PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
PS HKLM:\> set-location C:
PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM
PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
FileSystem::C
Set-Location : Cannot find path 'C' because it does not exist.
At line:1 char:13
+ set-location <<<< FileSystem::C
PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
FileSystem::C:
PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
Registry::HKLM:
Set-Location : Cannot find path 'HKLM:' because it does not exist.
At line:1 char:13
+ set-location <<<< Registry::HKLM:
PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
functionrompt).definition
'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
'> '
PS Microsoft.PowerShell.Core\FileSystem::C:\>

For information here also is my prompt() function. It's the default.

PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
functionrompt).definition
'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
'> '
PS Microsoft.PowerShell.Core\FileSystem::C:\>

Can others confirm the behaviour? Do you see the differences as
desirable?

Andrew Watt MVP

My System SpecsSystem Spec
Old 01-21-2007   #2 (permalink)
RichS
Guest


 
 

RE: Inconsistent behaviour when using set-location with different prov

Andrew
I've tried them and got the same results. I think it should be consistent.
As more providers are added to PowerShell inconsistencies like this will
become more of an irritant and will put people off.
--
Richard Siddaway

Please note that all scripts are supplied "as is" and with no warranty


"Andrew Watt [MVP]" wrote:

> Try the following commands. I would be interesed if you can confirm
> the same inconsistencies in behaviour that I show below.
>
> There are three issues that I see:
>
> 1. Why does providing the provider name (or not) in the command affect
> what is displayed in the prompt?
>
> 2. Why is the behaviour of the FileSystem provider and Registry
> provider different? Is the inconsistency a bug?
>
> 3. Why does set-location C: and set-location FileSystem::C: take you
> to different folders? Bug?
>
> PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
> PS HKLM:\> set-location C:
>
> So far so good. But when you provide the name of the provider it
> appears in the prompt.
>
> PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM
>
> If you omit the colon with the FileSystem provider you can an error.
>
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C
> Set-Location : Cannot find path 'C' because it does not exist.
> At line:1 char:13
> + set-location <<<< FileSystem::C
>
> But it works with the colon in place.
>
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C:
>
> Providing the colon with the Registry provider produces an error (the
> FileSystem equivalent worked).
>
> PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
> Registry::HKLM:
> Set-Location : Cannot find path 'HKLM:' because it does not exist.
> At line:1 char:13
> + set-location <<<< Registry::HKLM:
>
> For convenience here are the commands with no interpolated comment:
>
> PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
> PS HKLM:\> set-location C:
> PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C
> Set-Location : Cannot find path 'C' because it does not exist.
> At line:1 char:13
> + set-location <<<< FileSystem::C
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C:
> PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
> Registry::HKLM:
> Set-Location : Cannot find path 'HKLM:' because it does not exist.
> At line:1 char:13
> + set-location <<<< Registry::HKLM:
> PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
> functionrompt).definition
> 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
> '> '
> PS Microsoft.PowerShell.Core\FileSystem::C:\>
>
> For information here also is my prompt() function. It's the default.
>
> PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
> functionrompt).definition
> 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
> '> '
> PS Microsoft.PowerShell.Core\FileSystem::C:\>
>
> Can others confirm the behaviour? Do you see the differences as
> desirable?
>
> Andrew Watt MVP
>

My System SpecsSystem Spec
Old 01-22-2007   #3 (permalink)
Oisin Grehan
Guest


 
 

Re: Inconsistent behaviour when using set-location with different providers

The answer is quite simple -- "c:" and "filesystem::c:" are two
different paths. The first is the *name* of a PSDrive (e.g. "C") which
happens to look the same as a windows filesystem root drive , the
second is a provider direct path, which specifies the provider and the
root for said provider. The second is _equivalent_ to the first, but is
not the same powershell path.

- Oisin



Andrew Watt [MVP] wrote:
> Try the following commands. I would be interesed if you can confirm
> the same inconsistencies in behaviour that I show below.
>
> There are three issues that I see:
>
> 1. Why does providing the provider name (or not) in the command affect
> what is displayed in the prompt?
>
> 2. Why is the behaviour of the FileSystem provider and Registry
> provider different? Is the inconsistency a bug?
>
> 3. Why does set-location C: and set-location FileSystem::C: take you
> to different folders? Bug?
>
> PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
> PS HKLM:\> set-location C:
>
> So far so good. But when you provide the name of the provider it
> appears in the prompt.
>
> PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM
>
> If you omit the colon with the FileSystem provider you can an error.
>
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C
> Set-Location : Cannot find path 'C' because it does not exist.
> At line:1 char:13
> + set-location <<<< FileSystem::C
>
> But it works with the colon in place.
>
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C:
>
> Providing the colon with the Registry provider produces an error (the
> FileSystem equivalent worked).
>
> PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
> Registry::HKLM:
> Set-Location : Cannot find path 'HKLM:' because it does not exist.
> At line:1 char:13
> + set-location <<<< Registry::HKLM:
>
> For convenience here are the commands with no interpolated comment:
>
> PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
> PS HKLM:\> set-location C:
> PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C
> Set-Location : Cannot find path 'C' because it does not exist.
> At line:1 char:13
> + set-location <<<< FileSystem::C
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C:
> PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
> Registry::HKLM:
> Set-Location : Cannot find path 'HKLM:' because it does not exist.
> At line:1 char:13
> + set-location <<<< Registry::HKLM:
> PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
> functionrompt).definition
> 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
> '> '
> PS Microsoft.PowerShell.Core\FileSystem::C:\>
>
> For information here also is my prompt() function. It's the default.
>
> PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
> functionrompt).definition
> 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
> '> '
> PS Microsoft.PowerShell.Core\FileSystem::C:\>
>
> Can others confirm the behaviour? Do you see the differences as
> desirable?
>
> Andrew Watt MVP


My System SpecsSystem Spec
Old 01-22-2007   #4 (permalink)
Oisin Grehan
Guest


 
 

Re: Inconsistent behaviour when using set-location with different providers

And to duplicate your confusion using the registry provider as an
example:

PS > new-psdrive HKEY_LOCAL_MACHINE Registry HKEY_LOCAL_MACHINE
....
PS > cd HKEY_LOCAL_MACHINE:
PS HKEY_LOCAL_MACHINE:\>
PS > cd Registry::HKEY_LOCAL_MACHINE
PS Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE>

And bingo, it looks "inconsistent" again.

- Oisin

Oisin Grehan wrote:
> The answer is quite simple -- "c:" and "filesystem::c:" are two
> different paths. The first is the *name* of a PSDrive (e.g. "C") which
> happens to look the same as a windows filesystem root drive , the
> second is a provider direct path, which specifies the provider and the
> root for said provider. The second is _equivalent_ to the first, but is
> not the same powershell path.
>
> - Oisin
>
>
>
> Andrew Watt [MVP] wrote:
> > Try the following commands. I would be interesed if you can confirm
> > the same inconsistencies in behaviour that I show below.
> >
> > There are three issues that I see:
> >
> > 1. Why does providing the provider name (or not) in the command affect
> > what is displayed in the prompt?
> >
> > 2. Why is the behaviour of the FileSystem provider and Registry
> > provider different? Is the inconsistency a bug?
> >
> > 3. Why does set-location C: and set-location FileSystem::C: take you
> > to different folders? Bug?
> >
> > PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
> > PS HKLM:\> set-location C:
> >
> > So far so good. But when you provide the name of the provider it
> > appears in the prompt.
> >
> > PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM
> >
> > If you omit the colon with the FileSystem provider you can an error.
> >
> > PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> > FileSystem::C
> > Set-Location : Cannot find path 'C' because it does not exist.
> > At line:1 char:13
> > + set-location <<<< FileSystem::C
> >
> > But it works with the colon in place.
> >
> > PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> > FileSystem::C:
> >
> > Providing the colon with the Registry provider produces an error (the
> > FileSystem equivalent worked).
> >
> > PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
> > Registry::HKLM:
> > Set-Location : Cannot find path 'HKLM:' because it does not exist.
> > At line:1 char:13
> > + set-location <<<< Registry::HKLM:
> >
> > For convenience here are the commands with no interpolated comment:
> >
> > PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
> > PS HKLM:\> set-location C:
> > PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM
> > PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> > FileSystem::C
> > Set-Location : Cannot find path 'C' because it does not exist.
> > At line:1 char:13
> > + set-location <<<< FileSystem::C
> > PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> > FileSystem::C:
> > PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
> > Registry::HKLM:
> > Set-Location : Cannot find path 'HKLM:' because it does not exist.
> > At line:1 char:13
> > + set-location <<<< Registry::HKLM:
> > PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
> > functionrompt).definition
> > 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
> > '> '
> > PS Microsoft.PowerShell.Core\FileSystem::C:\>
> >
> > For information here also is my prompt() function. It's the default.
> >
> > PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
> > functionrompt).definition
> > 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
> > '> '
> > PS Microsoft.PowerShell.Core\FileSystem::C:\>
> >
> > Can others confirm the behaviour? Do you see the differences as
> > desirable?
> >
> > Andrew Watt MVP


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Inconsistent window behaviour Live Mail
WLM 9 Beta: Inconsistent Behaviour in number of contacts in catego Live Messenger
Access 2003 database inconsistent behaviour between Vista and XP Vista General
Inconsistent Usenet quoting behaviour Vista mail
Seemingly inconsistent behaviour PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46