FROM DELL
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell
Install PowerShell on Windows, Linux, and macOS - PowerShell
PS C:\Windows\system32> $pw = Read-Host -AsSecureString "Type a password for the new local share user (copy this into MAIN when prompted)"
>> New-LocalUser -Name "shareuser" -Password $pw -FullName "Share User" -Description "Temporary share user"
>> Add-LocalGroupMember -Group "Users" -Member "shareuser"$pw = Read-Host -AsSecureString "Type a password for the new local share user (copy this into MAIN when prompted)"
Type a password for the new local share user (copy this into MAIN when prompted): ********
Name Enabled Description
---- ------- -----------
shareuser True Temporary share user
Add-LocalGroupMember : A positional parameter cannot be found that accepts argument 'System.Security.SecureString'.
At line:3 char:1
+ Add-LocalGroupMember -Group "Users" -Member "shareuser"$pw = Read-Hos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument:
) [Add-LocalGroupMember], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.AddLocalGroupMemberCommand
PS C:\Windows\system32> New-LocalUser -Name "shareuser" -Password $pw -FullName "Share User" -Description "Temporary share user"
New-LocalUser : User shareuser already exists.
At line:1 char:1
+ New-LocalUser -Name "shareuser" -Password $pw -FullName "Share User" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (shareuser:LocalUser) [New-LocalUser], UserExistsException
+ FullyQualifiedErrorId : UserExists,Microsoft.PowerShell.Commands.NewLocalUserCommand
PS C:\Windows\system32> Add-LocalGroupMember -Group "Users" -Member "shareuser"
PS C:\Windows\system32> New-LocalUser -Name "shareuser" -Password $pw -FullName "Share User" -Description "Temporary share user"
>> Add-LocalGroupMember -Group "Users" -Member "shareuser"
New-LocalUser : User shareuser already exists.
At line:1 char:1
+ New-LocalUser -Name "shareuser" -Password $pw -FullName "Share User" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (shareuser:LocalUser) [New-LocalUser], UserExistsException
+ FullyQualifiedErrorId : UserExists,Microsoft.PowerShell.Commands.NewLocalUserCommand
Add-LocalGroupMember : DELL-LAPTOP\shareuser is already a member of group Users.
At line:2 char:1
+ Add-LocalGroupMember -Group "Users" -Member "shareuser"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (Users:String) [Add-LocalGroupMember], MemberExistsException
+ FullyQualifiedErrorId : MemberExists,Microsoft.PowerShell.Commands.AddLocalGroupMemberCommand
PS C:\Windows\system32> New-Item -Path 'C:\PublicShare' -ItemType Directory -Force | Out-Null
>> icacls 'C:\PublicShare' /grant 'shareuser
OI)(CI)F' /T | Out-Null
>> Grant-SmbShareAccess -Name "PublicShare" -AccountName "shareuser" -AccessRight Full -Force
Name ScopeName AccountName AccessControlType AccessRight
---- --------- ----------- ----------------- -----------
PublicShare * Everyone Allow Full
PublicShare * DELL-LAPTOP\shareuser Allow Full
PS C:\Windows\system32> Restart-Service -Name LanmanServer -Force
PS C:\Windows\system32> Write-Output "Created user 'shareuser' and granted access to C:\PublicShare. Now run the MAIN block on MAIN-PC."
Created user 'shareuser' and granted access to C:\PublicShare. Now run the MAIN block on MAIN-PC.
PS C:\Windows\system32>