
Select Organization Unit then select the OU you want to targetĬlick OK, Click OK again to close the new drive properties Select “Run in logged on users’s security context

Right Click Drive Mappings, Select New – > Mapped Drive Navigate to User Configuration -> Preferences -> Windows Settings -> Drive Mappingsģ. The new GPO is now created and linked, now it’s time to configure the settings.

I can later add additional drive mappings to this GPO. You can name the new GPO whatever you like, I’ve named mine “Users – Mapped Drives I have all of my users separated into an OU called ADPRO Users, I’ll create and link the GPO there. TIP: This will be a user based GPO so make sure you link the GPO to a location that will target the users. In the Group Policy Management Console, Right Click and Select “Create a GPO in this domain, and Link it here” Open the Group Policy Management ConsoleĢ. This will map to a network share that only the HR department has access to. You could also use a Security Group to target a specific group of users. I’ll use item level targeting so it only maps this drive for users in the HR organizational unit. In this example, I’m going to map a network drive for the HR department. Example 1: Map a Department Network Drive Using Group Policy Now let’s move on to some examples of mapping drives with group policy. With item level targeting you can target groups, users, OUs, operating systems and so on. It’s scalable, as big as your Active Directory will grow logon scripts will scale no problem.Checkboxes and drop down lists, no need to understand scripting Mapping Drives with Group Policy has the following advantages: Unless you have some crazy complex script that does something that Group Policy cannot do then there is no reason not to use it. Logon scripts can actually slow computers down. The ability to map a network drive with Group Policy was introduced in Server 2008. In addition, I will use item level targeting to map drives based on specific conditions like group membership, OU, operating system, etc. I’ll show you two examples, the first one is mapping a drive for a department, the second will map a drive for individual users. Mapping drives with group policy is very easy and requires no scripting experience.īonus: It can actually speed up the user logon process. If you’re still using login scripts then it’s time to switch to Group Policy.
#VPN NETWORK DRIVE WINDOWS 10 LOGON SCRIPT HOW TO#
If a batch is already in place, for example netlogon.bat, then execute netdrive.ps1 out from a batch file as follows: start /wait "" powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File netdrive.ps1Īfter a successful logon, is it possible to check the network mapping, for this the processes are logged in the file this guide, I’ll show you step by step instructions on how to map network drives with Group Policy. Windows PowerShell Credentials Run PowerShell Script from Batch Replace the placeholders domain\username with the appropriate domain and user, if there is no domain, then just leave it blank. Run the script in the PowerShell with change to directory in which you placed the netdrive.ps1 script file.\netdrive.ps1 If further network shares are to be mapped, in the if loop copy lines 6 – 10 for the next network share using the variables $sharePath1 and $mapDrive1. The corresponding Windows network share is defined in line 6 at $sharePath, and the drive is assigned in line 7 at $mapDrive, change the respective placeholder between the quotation marks.

New-PSDrive -Name $mapDrive -Root $sharePath -Persist -Scope Global -PSProvider "FileSystem" -Credential $Cred | Out-File $LogFile -AppendĪdd-Content $LogFile -Value "No credentials were given, network mapping canceled." Write-Host "`nMapping network share." -ForegroundColor WhiteĪdd-Content $LogFile -Value "Mapping drive $mapDrive $sharePath" $Cred = Get-Credential -Message "Please enter your credentials" -UserName "domain\username" Write-Host "`nEnter your network credentials to map network drives or cancel mapping" -ForegroundColor Yellow Get-Date -Format "MM/dd/yyyy HH:mm" | Out-File $LogFile -Force This PowerShell Script example netdrive.ps1, creates the Windows network mapping to drive Z: for a specific user, whereby you can log on as a different user than you are authenticated with on the client. Where batch processing is not the right choice, or where Group Policy is not possible, a PowerShell script can perform this task, for example, when running login scripts with remote clients via VPN, or clients that are not members of the AD domain. PowerShell scripts can be used to create network drives to Windows network shares on servers or NAS devices. ( 2) Mapping Windows Network Drive using PowerShell
