Why does set-property fail here??

by tommls at 2013-01-29 15:40:15

Set-ItemProperty -path “\x8\C$\Users$UserID\AppData\Roaming\Microsoft\Internet Explorer\UserData” -name Hidden -value $true

fails with these errors, why??
I’ve checked the code/syntax against several discussions of this command.
It has to use an UNC path, $UserID is a parameter.
The desired goal is to create a hidden folder, UserData, within the Internet Explorer folder.

Set-ItemProperty : Property System.Boolean Hidden=True does not exist.
At C:\GP_Directory.ps1:12 char:17
+ Set-ItemProperty <<<< -path “\x8\C$\Users$UserID\AppData\Roaming\Microsoft\Internet Explorer\UserData” -name Hidden -value $true
+ CategoryInfo : ReadError: (System.Boolean Hidden=True:PSNoteProperty) [Set-ItemProper
ty], IOException
+ FullyQualifiedErrorId : SetPropertyError,Microsoft.PowerShell.Commands.SetItemPropertyCommand

Using Powershell 2.0.

Thank you, Tom
by tommls at 2013-01-29 15:58:50
I also tried this kind of syntax: $(MkDir “Martin Zugec”).Attributes = ‘Hidden’ and it also failed.
Thank you, Tom
by DonJ at 2013-01-29 17:40:07
The latter syntax won’t work; MkDir doesn’t return a valid reference to the folder.

Set-ItemProperty doesn’t work because a directory doesn’t have a “Hidden” property (Dir | GM to verify). There’s an Attributes property; you don’t set it to “Hidden,” though. It’s a bitmask, and has to use the values in the System.IO.FileAttributes enumeration (again, Dir | GM to see this). http://msdn.microsoft.com/en-us/library … butes.aspx. So, [System.IO.FileAttributes]::Hidden, I’m guessing.
by tommls at 2013-01-30 05:57:11
I got this working…
I copied and used the wrong command from this blog:
http://martinzugec.blogspot.com/2009/08 … butes.html
Actual code ends up being this:

Set-Location "\x5\C$\Users$UserID\AppData\Roaming\Microsoft"
Mkdir “Internet Explorer”
Set-Location "\x5\C$\Users$UserID\AppData\Roaming\Microsoft\Internet Explorer"
Mkdir “UserData”
$(Get-Item “\x5\C$\Users$UserID\AppData\Roaming\Microsoft\Internet Explorer\UserData”).Attributes = ‘Hidden’

This is so people can open reports etc. in Great Plains 2010…

Thank you, Tom