Network drive mapping from PowerShell Script

Mapping Windows Network Drive using PowerShell

PowerShell scripts can be used to create network drives to Windows network shares on servers or NAS devices. 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.

PS-Script for Network Drive Mapping

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.

The corresponding Windows network share is defined in line 7 at $sharePath, and the drive is assigned in line 8 at $mapDrive, adjusting the respective placeholder between the quotation marks. If further network shares are to be mapped, in the if loop copy lines 7 – 11 for the next network share using the variables $sharePath1 and $mapDrive1.

Windows PowerShell Credentials
Windows PowerShell Credentials

Run PowerShell Script from Batch

If a batch is already in place, for example netlogon.bat, then execute netdrive.ps1 out from a batch file as follows:

After a successful logon, is it possible to check the network mapping, for this the processes are logged in the file netdrive.log.

Network drive mapping from VBScript

Mapping Windows Network Drive using Visual Basic Script

VBScript can be used to connect network drives to Windows shares on servers or NAS devices. In situations where batch processing is not the right choice, or group policy is not the application you want, a Visual Basic Script can meet the requirement, for example, to apply login scripts to VPN Remote Clients who are not members of the AD domain.

Microsoft VBScript contains object classes, methods (functions / procedures) and value structures. Our MapNetworkDrive object is used as a method here. The method or verb in turn manipulates values.

Any object can be used, the object objNetwork is defined here, script developers like to stick to patterns and their variables. A prefix of str indicates a string value, while the obj prefix indicates an object. After WScript has created our objNetwork, it can be edited using the MapNetworkDrive method.

VBScript for Network drive Mapping

The following VBScript netdrive.vbs as an example, assign the network mapping to drive Z: for a specific user; the login can be performed as a different user than the one with whom you have authenticated yourself on the client.

The corresponding variable assigned line 6 – 9 in which the placeholder is defined between quotation marks.

Assign VBScript values to variables

  1. For strDriveLetter choose a desired network drive letter.
  2. For strRemotePath add the UNC path to the network share.
  3. For strUser add the user name. If this is a member of an AD domain, the domain prefix must be given, using like domain\user.
  4. For strPassword add the users password.

Run VBScript WSH from batch

If a batch is already used, for example netlogon.bat, then from the batch file the VBScript netdrive.vbs is executed as follows:

VBScript Network Drive Mapping

If you do not want to output Visual Basic Console Screen during execution, use option /B to start the application without opening a new window.

cscript msgbox map network drive

After successfully logging in, the network drive for the Windows network share is created and then opened in Explorer.

How to register vSphere license Key

Register Hypervisor ESXi and get the license key for ESXi Trial and Free

vSphere Hypervisor ESXi 7.0 is valid for 60 days after installation, if you want to continue using the hypervisor without enterprise features after 60 days, may for further evaluation in the lab, you can register a free license key, add it in vSphere, under Manage – Licensing – Assign license.

vSphere ESXi Hypervisor License Assign
vSphere ESXi Hypervisor

A new license key for unlimited use can be registered on VMware Communities here. To do this, it is necessary to register new account with a valid email using the Register with Sign up now link.

vmware customer connect sign-up

Sign up now opens the registration form.

  A new account was created here, due product registration was not possible with an existing account, if there is an previous account already exist that is in saved passwords, cookies and the browser cache may have to be delete, so you’r able to login with the new account.

VMware registration customerc connect, complete this registration form

After the registration form has been filled out and submitted by entering the captcha code, an e-mail will be sent, click the Activate Now button in the opened e-mail to confirm and complete the registration.

Email Activate Now your account

After clicking Activate Now, the page opens where you can now sign in to VMware with the new account.

VMware Registration Complete Activation

Now go to Products and Accounts and Trial and Free Solutions.

VMware Products and Accounts und Trial and Free Solutions

just navigate to Downloads and Free Products Trials & Demos – vSphere

VMware Downloads Free Products Trials & Demos - vSphere

On the Prudukt selection, the product must be again registered.

VMware vSphere Hypervisor Download Center licensing - registration

By clicking on the Register button, the form with the user license agreement opens.

user license agreement-accept

Filling in and signing in opens the VMware vSphere Hypervisor 7.0 Download Center page they include the license information.

VMware vSphere Hypervisor Download Center License Key

The VMware vSphere Product Key now you can see in the License Information section on Component in the LICENSE KEY column. Use the Manual Download button to download the ESXi ISO image.