misc/powershell/retrymappeddrives.ps1
adam 2d132e2fbf other old stuff for archiving.
yes I remembered to strip my sublime text license key out of the w10 boilerplate :P
2023-03-07 10:59:06 -05:00

18 lines
577 B
PowerShell

$i=3
while($True){
$error.clear()
$MappedDrives = Get-SmbMapping |where -property Status -Value Unavailable -EQ | select 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
}