Author Posts

July 3, 2017 at 5:28 am

Hi,

I wanted to remove DropBox icon with powershell.
I found registry that has to be changed from here:
https://www.dropboxforum.com/t5/Installation-and-desktop-app/How-does-one-remove-the-Dropbox-link-from-the-Navigation-Pane-om/td-p/93970

First part of changing the registry value is like that( this works ):
$registrypath = "HKLM:\SOFTWARE\Classes\CLSID\{E31EA727-12ED-4702-820C-4B6445F28E1A}"
$Name = "System.IsPinnedToNamespaceTree"
$value = 0

Set-ItemProperty -Path $registrypath -Name $Name -Value $value -Force

But second part (changing permissions) -fails
$acl = Get-Acl $registrypath
$person = [System.Security.Principal.NTAccount]"Administrators"
$access = [System.Security.AccessControl.RegistryRights]"FullControl"
$inheritance = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit,ObjectInherit"
$propagation = [System.Security.AccessControl.PropagationFlags]"None"
$type = [System.Security.AccessControl.AccessControlType]"Deny"
$rule = New-Object System.Security.AccessControl.RegistryAccessRule($person,$access,$inheritance,$propagation,$type)
$acl.AddAccessRule($rule) —— this is line 61 in my script !
$acl |Set-Acl

With an error:
You cannot call a method on a null-valued expression.
At line:61 char:1
+ $acl.AddAccessRule($rule)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Can anyone please help me ?

Best Regards,
Alar

July 3, 2017 at 11:55 am

Hi Alar,

Please make sure $acl object is not null. Most likely, something goes wrong at this line:

$acl = Get-Acl $registrypath

It cannot get ACL or whatever, please check

July 4, 2017 at 3:56 am

Hi, thank you for anwser. Don't know why, but after computer restart script works...