使用userdata在EC2实例设置中为所有用户访问Windows FileShare

问题描述 投票:0回答:1

我们有一个带有文件共享的EC2实例。直到现在,我们仍可以像\\files.server.com这样通过UNC访问它。

现在,我们开始使用packer和Ansible在部署中设置服务器。在sysprep之后,所有凭据都将被删除,我们需要使用UserData脚本再次创建访问权限。

还有另一件事,我们需要授予所有用户此访问权限,因为我们有Windows服务的特殊用户。

[New-PSDriveNET USEMapNetworkDrive,CredentialsManager等,我尝试了很多事情,但仍然没有运气。

我希望在此方面有所帮助。

windows amazon-web-services amazon-ec2 packer user-data
1个回答
0
投票

我做了类似的事情,但是我在CloudFormation中使用了commands:configSet部分:

  commands:

    10-Create-Local-Fileshare-Directory:
      command: >-
        powershell.exe -Command New-Item "D:\Shared" -type directory
      waitAfterCompletion: '0'
    11-Create-Fileshare:
      command: >-
        powershell.exe -Command New-SmbShare -Name my-fileshare -Path "D:\Shared"
      waitAfterCompletion: '0'
    12-Grant-Fileshare-Permissions:
      command: >-
        powershell.exe -Command Grant-SmbShareAccess -Name my-fileshare -AccountName Everyone -AccessRight Change -Force
      waitAfterCompletion: '0'      

如果您使用CloudFormation,或者只是拉出所需的Powershell命令,也可以执行相同的操作。

© www.soinside.com 2019 - 2024. All rights reserved.