Advertisement
Guest User

MapDrives.ps1

a guest
Nov 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. $i=3
  2. while($True){
  3. $error.clear()
  4. $MappedDrives = Get-SmbMapping |where -property Status -Value Unavailable -EQ | select LocalPath,RemotePath
  5. foreach( $MappedDrive in $MappedDrives)
  6. {
  7. try {
  8. New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True
  9. } catch {
  10. Write-Host "There was an error mapping $MappedDrive.RemotePath to $MappedDrive.LocalPath"
  11. }
  12. }
  13. $i = $i - 1
  14. if($error.Count -eq 0 -Or $i -eq 0) {break}
  15.  
  16. Start-Sleep -Seconds 30
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement