-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnetsharestarter.ps1
39 lines (33 loc) · 1.46 KB
/
netsharestarter.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<#
netsharestarter.ps1
.DESCRIPTION
- Script angeeinetem Ort speichern
- Geplante Task erstellen
- Benutzer oder Gruppe auswaehlen BSP LocalComputer\Users
- Neuer Trigger: Beim Anmelden
- Aktion: Programm starten
* Powershell.exe
* Argumente: -windowsstyle hidden -command .\netsharestarter.ps1
* Starten in: Speicherort des Scripts
* Nur starten wenn folgende Netzwerkverbindung verfuegbar ist: Beliebige NIC
Original:
https://support.microsoft.com/de-de/help/4471218/mapped-network-drive-may-fail-to-reconnect-in-windows-10-version-1809
https://github.com/thelamescriptkiddiemax/soest
#>
#--- Vorbereitung -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$i=3
while($True){
$error.clear()
$MappedDrives = Get-SmbMapping | Where-Object -property Status -Value Unavailable -EQ | Select-Object LocalPath,RemotePath
foreach( $MappedDrive in $MappedDrives)
{
try {
New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True
} catch {
Write-Host "There was an error mapping $MappedDrive.RemotePath to $MappedDrive.LocalPath"
}
}
$i = $i - 1
if($error.Count -eq 0 -Or $i -eq 0) {break}
Start-Sleep -Seconds 30
}