I’m trying to use these code to create a new SMB share locally:
New-SmbShare -Name 'MyShare' -Path 'C:Windows' -FullAccess 'MyDomainMyUser'
If I start Powershell with “Run as administrator” all works fine, but if dont, I’m getting these error:
New-SmbShare : Access is denied.
At line:1 char:1
+ New-SmbShare -Name 'Share' -Path 'C:Windows' -FullAccess 'MyDomainMyUser'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (MSFT_SMBShare:ROOT/Microsoft/Windows/SMB/MSFT_SMBShare) [New-SmbShare], CimException
+ FullyQualifiedErrorId : Windows System Error 5,New-SmbShare
My user is a domain user, he added to local administrators group. OS: Windows Server 2012 R2 Version 6.3.
In other machines (With Win10 or WinServer 2016 for example) all works fine. As I understand, i need to give some extra permissions for creating SMB shares for my user in these version of Windows. Workaroung with “Run as administrator” is not an option, i need to run powershell from my user’s name. Could someone help please?