Comments (4)
I'm not sure if this will help, but I had a similar request where they wanted the path to self correct in the event that a user changed path. I added a block in the script after the comment line 117. It checks to see if the drive letter and path match. If not, it deletes the mapping and the rest of the script continues to create the intended letter\path. Just make sure to update the intended path(s) in the script below. I hope this helps.
if (-not (Test-RunningAsSystem)) {
$driveMappings = Get-WmiObject -Class Win32_mappedLogicalDisk | select name,providername
$Sdrive = "S:"
$Mdrive = "M:"
foreach ($driveMapping in $driveMappings){
if ($driveMapping.name -match $Sdrive){
if ($driveMapping.ProviderName -ne '<intended path>') {
net use S: /delete
}
}
if ($driveMapping.name -match $Mdrive){
if ($driveMapping.ProviderName -ne '<intended path>') {
net use M: /delete
}
}
}
Start-Sleep -Seconds 10
from intunedrivemapping.
I'm not sure if this will help, but I had a similar request where they wanted the path to self correct in the event that a user changed path. I added a block in the script after the comment line 117. It checks to see if the drive letter and path match. If not, it deletes the mapping and the rest of the script continues to create the intended letter\path. Just make sure to update the intended path(s) in the script below. I hope this helps.
if (-not (Test-RunningAsSystem)) {
$driveMappings = Get-WmiObject -Class Win32_mappedLogicalDisk | select name,providername $Sdrive = "S:" $Mdrive = "M:" foreach ($driveMapping in $driveMappings){ if ($driveMapping.name -match $Sdrive){ if ($driveMapping.ProviderName -ne '<intended path>') { net use S: /delete } } if ($driveMapping.name -match $Mdrive){ if ($driveMapping.ProviderName -ne '<intended path>') { net use M: /delete } } }
Start-Sleep -Seconds 10
Hey @DaBXRoMeO
Did you add this after commented section #Mapping network drives# ?
from intunedrivemapping.
I'm not sure if this will help, but I had a similar request where they wanted the path to self correct in the event that a user changed path. I added a block in the script after the comment line 117. It checks to see if the drive letter and path match. If not, it deletes the mapping and the rest of the script continues to create the intended letter\path. Just make sure to update the intended path(s) in the script below. I hope this helps.
if (-not (Test-RunningAsSystem)) {$driveMappings = Get-WmiObject -Class Win32_mappedLogicalDisk | select name,providername $Sdrive = "S:" $Mdrive = "M:" foreach ($driveMapping in $driveMappings){ if ($driveMapping.name -match $Sdrive){ if ($driveMapping.ProviderName -ne '<intended path>') { net use S: /delete } } if ($driveMapping.name -match $Mdrive){ if ($driveMapping.ProviderName -ne '<intended path>') { net use M: /delete } } }
Start-Sleep -Seconds 10
Hey @DaBXRoMeO Did you add this after commented section #Mapping network drives# ?
Correct, after the comment section that starts "#Mapping network drive#"
from intunedrivemapping.
Thanks @DaBXRoMeO
I've found that with the added code of yours it still will continue to remove and replace the UNC path regardless of it being correct on the client end or not...
from intunedrivemapping.
Related Issues (20)
- Mapping issues! HOT 3
- Multiple security groups HOT 4
- Use system variables as drive label? HOT 4
- Allow updating script in editor HOT 2
- MapNetworkDrive connect using different credentials HOT 2
- The (member:1.2.840.113556.1.4.1941:=) search filter is invalid. HOT 3
- Question: Old script renamed to DriveMappping.ps1 HOT 3
- Script not detecting that it is running as system HOT 3
- Multiple Security Group HOT 4
- Hidden Drive Support
- Drive Label not Expand correctly
- Drives will be unmapped if Membership could not retrieved
- Support for Azure storage accounts?
- Username/Password
- Performance issues with DriveMapping Script
- Remove script from task scheduler HOT 1
- Script does not have logic to re-map a network drive when a UNC path is changed HOT 3
- Drives map when task run manually but not when triggered
- How to add to the script removing all mapped drives before mapping them HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intunedrivemapping.