简体   繁体   English

powershell 在 gpo 上创建映射驱动器

[英]powershell to create mapped drive on gpo

I am trying to automate a process using powershell and as part of that process I want to create a new drive map on a group policy object我正在尝试使用 powershell 自动化一个过程,作为该过程的一部分,我想在组策略对象上创建一个新的驱动器映射

The image shows how it is done manually with the group policy management editor manual method该图显示了如何使用组策略管理编辑器手动方法手动完成

I have tried using我试过使用

New-PSDrive and New-SmbMapping eg
New-GPO -Name "$gpn"  | New-GPLink -Target $target
New-PSDrive –Name “T” –PSProvider FileSystem –Root “\\arc\tms shared\$directory” –Persist

and

New-SmbMapping -LocalPath 'T:' -RemotePath '\\arc\tms shared\$directory' -Persistent:$true

but with no luck但没有运气

thanks谢谢

But, uhmmmm that screen is not a GPO, which is done at the domain level.但是,嗯,那个屏幕不是 GPO,它是在域级别完成的。

You are showing GPP at the client level.您正在客户端级别显示 GPP。 Why are you doing per client via script vs at the domain so as machines are added to the domain, and user login, it's automatic?为什么您通过脚本与域中的每个客户端进行操作,以便将机器添加到域中,并且用户登录是自动的? GPP of course in the way to go. GPP当然是要走的路。

You cannot use New-Gpo for a local GPP setting.您不能将 New-Gpo 用于本地 GPP 设置。 The PowerShell docs for that cmdlet specifically states...该 cmdlet 的 PowerShell 文档特别指出...

New-GPO 新GPO

Description The New-GPO cmdlet creates a GPO with a specified name.说明 New-GPO cmdlet 创建具有指定名称的 GPO。 By default, the newly created GPO is not linked to a site, domain, or organizational unit (OU).默认情况下,新创建的 GPO 未链接到站点、域或组织单位 (OU)。

# get function / cmdlet details
Get-Command -Name New-Gpo -Syntax
(Get-Command -Name New-Gpo).Parameters.Keys
Get-help -Name New-Gpo -Full
Get-help -Name New-Gpo -Online
Get-help -Name New-Gpo -Examples

In linking the GPO, you have to fully qualify the target and permissions.在链接 GPO 时,您必须完全限定目标和权限。 Again the above doc shows the following example...上面的文档再次显示了以下示例...

new-gpo -name TestGPO | 
new-gplink -target "ou=marketing,dc=contoso,dc=com" | 
set-gppermissions -permissionlevel gpoedit -targetname "Marketing Admins" -targettype group 

There is a tool you can get to assist here and they provide a sample scrip to do GPO drive mapping.您可以在这里获得一个工具来提供帮助,他们提供了一个示例脚本来进行 GPO 驱动器映射。 See this...看到这个...

Automating Group Policy Preferences Drive Mapping with PowerShell [VIDEO] They sell a tool for this use case called... 使用 PowerShell 自动执行组策略首选项驱动器映射 [视频]他们为这个用例出售了一个名为...

'Group Policy Automation Engine (GPAE)' '组策略自动化引擎 (GPAE)'

SDM Software's Group Policy Automation Engine (GPAE) provides the industry's only PowerShell interface for automating the reads and writes of Group Policy settings. SDM Software 的组策略自动化引擎 (GPAE) 提供业界唯一的 PowerShell 接口,用于自动读取和写入组策略设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM