Open lms93 opened 1 year ago
@nicolonsky Any ideas mate?
Hey @nicolonsky
Your help would be appreciated mate, surely there would be many others with this issue?
Cheers
Also have questions regarding this, did you figure something out?
Shouldn't line:
if ($null -ne $exists -and $($exists.Path -eq $drive.Path -and $exists.DriveLetter -eq $drive.DriveLetter )) {
do the trick?
The line:
Get-PSDrive | Where-Object { $_.DisplayRoot -eq $drive.Path -or $_.Name -eq $drive.DriveLetter } | Remove-PSDrive -EA SilentlyContinue
should remove inconsistent drive mappings when the script is updated. However Remove-PSDrive does not remove the mapping fully and you cannot add another mapping on the same drive letter in the same script.
I did a quick fix in my code by commenting out that line and adding a good old net use command.
$netUseDrive = $drive.DriveLetter + ":"
Write-Output "Deleting drive with with command: net use $netUseDrive /delete /y"
net use $netUseDrive /delete /y
How do I ensure that the script can handle updates to UNC paths? Would I need to look at removing and disconnecting existing drives if the script needs to be rerun? Thank you