Giter Club home page Giter Club logo

Comments (4)

DaBXRoMeO avatar DaBXRoMeO commented on May 27, 2024 1

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.

lms93 avatar lms93 commented on May 27, 2024

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.

DaBXRoMeO avatar DaBXRoMeO commented on May 27, 2024

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.

lms93 avatar lms93 commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.