LanmanServer Shares

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Post Reply
User avatar
sekou2331
Posts: 286
Joined: Wed Aug 15, 2012 6:07 am

LanmanServer Shares

Post 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'  }

jvierra
Posts: 14579
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Re: LanmanServer Shares

Post 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.

User avatar
sekou2331
Posts: 286
Joined: Wed Aug 15, 2012 6:07 am

Re: LanmanServer Shares

Post 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??

User avatar
sekou2331
Posts: 286
Joined: Wed Aug 15, 2012 6:07 am

Re: LanmanServer Shares

Post by sekou2331 »

an anyone help with which direction to go with this issue I am having.

jvierra
Posts: 14579
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Re: LanmanServer Shares

Post 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

User avatar
sekou2331
Posts: 286
Joined: Wed Aug 15, 2012 6:07 am

Re: LanmanServer Shares

Post 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?

jvierra
Posts: 14579
Joined: Tue May 22, 2007 9:57 am
Answers: 1
Been upvoted: 1 time
Contact:

Re: LanmanServer Shares

Post 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.

Post Reply