【发布时间】:2014-10-29 02:46:33
【问题描述】:
我需要通过 Powershell 4 脚本设置远程共享的共享权限。我查看了this page,特别是命令Grant-SmbShareAccess,但是该cmdlet 设置了本地共享的权限,我很想看到-ComputerName 参数,但是,唉,没有。
我想做类似的事情:Grant-SmbShareAccess -ComputerName MYREMOTESERVER -Name <share_name> -AccountName <domain_account> -AccessRight Full
关于如何做到这一点的任何想法?我的远程服务器可以是 Windows Server 或 NetApp vFiler。
编辑
我在 cmets 中针对 NetApp vFiler 尝试了 Matt 对 Invoke-Command 的建议并得到了这个错误:
Connecting to remote server MYREMOTESERVER failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig".
在 Windows 资源管理器中更改共享的安全性可以正常工作。
【问题讨论】:
-
也许
Invoke-Command是您正在寻找的。更多信息here -
@Matt 如果我只处理远程 Windows 服务器,我会查看它,但如果远程共享托管在 NetApp vFiler 上,我认为它不会起作用,因为它取决于远程处理。
-
您是否尝试将服务器名称与共享名称一起传递?比如:
Grant-SmbShareAccess -Name \\MYREMOTESERVER\SHARENAME -AccountName USERACCOUNT -AccessRight Full -
@CitizenRon 感谢您的建议,但这也不起作用,因为该命令正在寻找本地共享。反正我试过了:
Grant-SmbShareAccess : No MSFT_SMBShare objects found with property 'Name' equal to '\\MYREMOTESERVER\SHARENAME'. Verify the value of the property and retry.
标签: powershell windows-server windows-server-2012-r2 powershell-4.0