# Why does set-property fail here??

**URL:** <https://forums.powershell.org/t/why-does-set-property-fail-here/540>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/why-does-set-property-fail-here/540 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/why-does-set-property-fail-here/540/1 "2011-12-31T18:30:00Z")

</div>

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](http://msdn.microsoft.com/en-us/library/system.io.fileattributes.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](http://martinzugec.blogspot.com/2009/08/get-or-set-filedirectory-attributes.html)  
> Actual code ends up being this:  
>   
> `[CmdletBinding()]param( [parameter(mandatory=$true)][string]$UserID)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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:03pm UTC](https://forums.powershell.org/t/why-does-set-property-fail-here/540/2 "2024-05-16T21:03:47Z")

</div>

Closed on May 16, 2024, 9:03pm UTC


