Page 1 of 1

LanmanServer Shares

Posted: Wed Sep 30, 2020 6:44 am
by sekou2331
I am trying to change only the path for LanmanServer Shares in the registry. I am using the below but I am finding that is is not working. Am thinking that it is because path is a Deserialized.System.String[] and I am just creating a string. So it is not being read right. I am using the code below. The funny thing is if I manually add it like this

CATimeout=0
CSCFlags=0
MaxUses=4294967295
Path=D:\Program Files\foldername
Permissions=0
Remark=
ShareName=foldername
Type=0

It will work.
  1. Invoke-Command -ComputerName 'Computername' { Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares -Name 'foldername ' -Value 'CATimeout=0 CSCFlags=0 MaxUses=4294967295 Path=D:\Program Files\foldername Permissions=0 Remark= ShareName=foldername Type=0'  }

Re: LanmanServer Shares

Posted: Wed Sep 30, 2020 9:23 am
by jvierra
Why would you want to do this in the registry. There are CmdLets that can create or change shares using th ecorrect system APIs.

The entries are arrays of strings and you are trying to use a simple sting to create them. You need to use a MULTISZ to assign this kind of registry value.

Re: LanmanServer Shares

Posted: Wed Sep 30, 2020 9:57 am
by sekou2331
I want to keep the security settings for the share. I jsut need to change the path of the share. Also want to do this across remote servers. I dont want to create I want to modify. So am assuming I can use Set-SmbShare with invoke-command??

Re: LanmanServer Shares

Posted: Sun Oct 04, 2020 10:41 am
by sekou2331
an anyone help with which direction to go with this issue I am having.

Re: LanmanServer Shares

Posted: Sun Oct 04, 2020 12:21 pm
by jvierra
It won't work without a reboot. YOu also need to not use the registry. Just use "New-SmbShare"

help New-SmbShare -online

Re: LanmanServer Shares

Posted: Sun Oct 04, 2020 12:37 pm
by sekou2331
It will work without a reboot just have to restart server service. Also I am not trying to make a new share but just adjust a share path. It looks like New-SMbshare makes a new share. Is not possible to just change the path of the share?

Re: LanmanServer Shares

Posted: Sun Oct 04, 2020 12:59 pm
by jvierra
Why? Just remove and recreate the share. You are rewriting everything for an exisiting share wh9ich doesn't just change the share. What youy are trying to do cannot be done with the registry directly.

You can also use "Set-SmbShare" to alter a share. To change the path you must remove and recreate the share.

You can use Get-SmbShare to copy and alter the share path then apply it to the new share.

Yes, restarting the server service will do the same thing as a system restart. It will also be as destructive as a system restart.