Skip to content

Update mapped-network-drive-fail-reconnect.md #1849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ while($True){
foreach( $MappedDrive in $MappedDrives)
{
try {
New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True
New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True -ErrorAction Stop
} catch {
Write-Host "There was an error mapping $MappedDrive.RemotePath to $MappedDrive.LocalPath"
Write-Host "There was an error mapping $($MappedDrive.RemotePath) to $($MappedDrive.LocalPath)"
}
}
$i = $i - 1
Expand Down Expand Up @@ -97,3 +97,22 @@ All workarounds should be executed in standard user security context. Executing
9. In the **Start in (optional)** field, type the location (_%SystemDrive%\\Scripts\\_) of the script file.
10. On the **Conditions** tab, select the **Start only if the following network connection is available** option, select **Any connection**, and then select **OK**.
11. Log off, and then log back on to the device to run the scheduled task.

#### Workaround 3: Create a scheduled task for Microsoft VPN Client EventID 20225(VPN Connection Successfully established)

1. Copy the script file MapDrives.ps1 to the following location:
%SystemDrive%\\Scripts\\
2. In **Task Scheduler**, select **Action** > **Create Task**.
3. On the **General** tab in the **Create Task** dialog box, type a name (such as *Map Network Drives*) and description for the task.
4. Select **Change User or Group**, select a local user or group (such as **LocalComputer\\Users**) and then select **OK**.
5. On the **Triggers** tab, select **New**, and then select **On an event** for the **Begin the task** field.
6. On the **Triggers** tab, select **Log**, and then select **Application** from the **Log** dropdown list.
7. On the **Triggers** tab, Type **RasClient** for the **Source** field.
8. On the **Triggers** tab, Type **20225** for the **Event ID** field and then select **OK**.
9. On the **Actions** tab, select **New**, and then select **Start a program** for the **Action** field.
10. Type *Powershell.exe* for the **Program/script** field.
11. In the **Add arguments (optional)** field, type the following:
*-windowsstyle hidden -command .\\MapDrives.ps1 >> %TEMP%\\StartupLog.txt 2>&1*
12. In the **Start in (optional)** field, type the location (*%SystemDrive%\\Scripts\\*) of the script file.
13. On the **Conditions** tab, select the **Start only if the following network connection is available** option, select **Any connection**, and then select **OK**.
14. Log off, and then log back on to the device to run the scheduled task.