October 3, 2014 at 7:22 am #19321
I have PS v4 and am working in Windows 8.1. I have been working in PS ISE as an administrator.
I was doing the chapter 5 lab exercise in "Learning Windows Powershell 3 in a month of lunches" (resetting the property value of Dontprettypath using '>set-itemproperty -path advanced -PSPropert Enabledontprettypath -value 1'). For some reason, it was not working.
While checking for what I might have done wrong, I think that I reset the value for HKCU. I was prompted for a value and I typed in 'cls'.
When I run 'get-psdrive', I see hkcu listed.
However, I checking the location gives the following message:
>set-location -path hkcu
set-location : Cannot find path 'C:hkcu' because it does not exist.
At line:1, char :1
+set-location -path hkcu
+ CategoryInfo : ObjectNotFound: (C:\hkcu:String) [Set-Location], ItemNotFoundException
+FullyQualifiedErrorId : PathNotFound,MicrosoftPowerShell.Commands.SetLocationCommand
I would appreciate any help you can give.
October 3, 2014 at 7:31 am #19322
Drive names are followed by a colon.
October 4, 2014 at 3:14 am #19347
as a longer explanation for folks who may come across this...
The reason drive names must always be followed by a colon, when the drive name is being used as part of a path, is so that the shell can tell the difference between a drive and a folder.
Would try to change to a [i]folder[/i] named "drive."
Changes to a [i]drive[/i] named "drive." The colon is what lets the shell figure out what you're trying to do.
October 6, 2014 at 7:07 am #19425
Thanks. That worked.
Is 'set-location -path HKCU' not a valid method of moving to HKCU?
October 6, 2014 at 7:39 am #19427
No Achievements Yet!
Set-Location is a valid method but you need add a colon to change into the drive.
PS C:\> Set-Location -Path HKCU: PS HKCU:\>
"cd" is just an alias for Set-Location. Every time you use "cd" the PowerShell engine will invoke Set-Location with the Path parameter.
PS C:\> Get-Alias -Name cd CommandType Name Alias cd -> Set-Location
Aliases are great for the interactive usage of the PowerShell console because it means less typing. It is very important to get know the aliases because once you get into creating scripts than other PowerShell users except not to see any aliases in your scripts.
October 7, 2014 at 1:24 pm #19491
You must be logged in to reply to this topic.