Get the App
SLTechnology News&Howtos  ›  Servers  › 

Temporary and persistent network drive mapping

Shulou Source: shulou.com Published: 2022-06-02 15:14:22 09月30日 Update

Create a temporary network drive map:

(New-Object -ComObject WScript.Network).MapNetworkDrive("Z:", "\\TEST-PC\USERS")

Create a persistent network drive map:

# New-PSDrive plus the-Persist parameter makes the drive visible outside PowerShell.

#To actually create a permanent network drive, make sure you add-Scope Global./

#If New-PSDrive runs outside of global scope (for example, in a script), the drive will only appear in the File Manager while the script is running.

New-PSDrive -Name Z -PSProvider FileSystem -Root \\TEST-PC\USERS -Persist -Scope GlobalPS C:\> $C = Get-CredentialPS C:\> New-PSDrive -Name V -PSProvider FileSystem -Root \\10.190.10.240\jhis -Persist -Scope Global -Credential $C

Solution:

1. network test

> ping 10.190.10.240> Test-NetConncetion 10.190.10.240 -Port 445> [Environment]::GetLogicalDrives()

2. Create persistent V-disk mappings

> New-PSDrive -Name V -PSProvider FileSystem -Root \\10.190.10.240\jhis -Persist -Scope Global

3. Create temporary V-disk mappings

Click on "this computer", right click on "this computer" on the left, select "map network drive", establish map to V drive.

Notes:

When an ordinary user logs in, the disk map created is only seen by the user; if the user has administrator privileges, the disk map created by opening the PS command prompt by the administrator can not be seen by the ordinary user after creation, and can only be seen and accessed by opening the PS command prompt by the administrator.

If the command script for invoking disk mapping is executed in the task plan, if the mapping disk is mapped by ordinary user, run it as ordinary user; if the mapping disk is mapped by administrator permission, check Run with highest permission when running. And select the operating system version of the script running as the current version in the same interface.

Tags: Disk run drive drive network user administration general administrator script command permissions prompt version computer prompt selection maximum operating system event Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia Huawei Apple OPPO Reno