none
Map Network Drive

    Frage

  • Can MDT map an additional network drive other than the deployment root using credentials entered at the beggining of the deployment? I have scripts located on a different server that should not be copied over and it is unable to access them because it hasn't initiated a connection to that server.

    Montag, 11. Juni 2012 20:53

Antworten

  • Just threw this together using the ZTIUtility functions, you could improve it with more logging and whatever.

    Call it with

    cscript %scriptroot%\ZTIMapDrive.wsf /DriveToMap:"\\server\path"

    <job id="ZTIMapDrive">
        <script language="VBScript" src="ZTIUtility.vbs"/>
        <script language="VBScript">

    ' // ***************************************************************************
    ' //
    ' // Andrew Paterson 02/06/2012
    ' //
    ' // Microsoft Deployment Toolkit Solution Accelerator
    ' //
    ' // File:      
    ' //
    ' // Version:   1
    ' //
    ' // Purpose:   
    ' //
    ' // Usage:     
    ' //         
    ' //
    ' // ***************************************************************************

    Option Explicit
    RunNewInstance


    '//----------------------------------------------------------------------------
    '//  Global Constants
    '//----------------------------------------------------------------------------

    ' No global constants needed


    '//----------------------------------------------------------------------------
    '//  Main Class
    '//----------------------------------------------------------------------------

    Class ZTIMapDrive

        '//----------------------------------------------------------------------------
        '//  Class instance variable declarations
        '//----------------------------------------------------------------------------

        Dim iRetVal


        '//----------------------------------------------------------------------------
        '//  Constructor to initialize needed global objects
        '//----------------------------------------------------------------------------

        Private Sub Class_Initialize

        End Sub


        '//----------------------------------------------------------------------------
        '//  Main routine
        '//----------------------------------------------------------------------------

        Function Main

    oUtility.ValidateConnectionEx oEnvironment.Item("DriveToMap"), True




        End Function

    End Class

        </script>
    </job>

            
    • Als Antwort markiert Hans Lima Freitag, 15. Juni 2012 19:02
    Montag, 11. Juni 2012 22:32

Alle Antworten

  • Just threw this together using the ZTIUtility functions, you could improve it with more logging and whatever.

    Call it with

    cscript %scriptroot%\ZTIMapDrive.wsf /DriveToMap:"\\server\path"

    <job id="ZTIMapDrive">
        <script language="VBScript" src="ZTIUtility.vbs"/>
        <script language="VBScript">

    ' // ***************************************************************************
    ' //
    ' // Andrew Paterson 02/06/2012
    ' //
    ' // Microsoft Deployment Toolkit Solution Accelerator
    ' //
    ' // File:      
    ' //
    ' // Version:   1
    ' //
    ' // Purpose:   
    ' //
    ' // Usage:     
    ' //         
    ' //
    ' // ***************************************************************************

    Option Explicit
    RunNewInstance


    '//----------------------------------------------------------------------------
    '//  Global Constants
    '//----------------------------------------------------------------------------

    ' No global constants needed


    '//----------------------------------------------------------------------------
    '//  Main Class
    '//----------------------------------------------------------------------------

    Class ZTIMapDrive

        '//----------------------------------------------------------------------------
        '//  Class instance variable declarations
        '//----------------------------------------------------------------------------

        Dim iRetVal


        '//----------------------------------------------------------------------------
        '//  Constructor to initialize needed global objects
        '//----------------------------------------------------------------------------

        Private Sub Class_Initialize

        End Sub


        '//----------------------------------------------------------------------------
        '//  Main routine
        '//----------------------------------------------------------------------------

        Function Main

    oUtility.ValidateConnectionEx oEnvironment.Item("DriveToMap"), True




        End Function

    End Class

        </script>
    </job>

            
    • Als Antwort markiert Hans Lima Freitag, 15. Juni 2012 19:02
    Montag, 11. Juni 2012 22:32
  • Hi Andrew. So your script does exactly what I am looking for but am having a bit of a problem. I created ZTIMapDrive.wsf and added it to the scripts folder and am calling it with what you provided but it is not mapping. I did open CMD once the computer booted to Windows and Lite Touch started and entered command cscript %scriptroot%\ZTIMapDrive.wsf /DriveToMap:"\\server\path" but didn't work so I entered Z:\scripts\ZTIMapDrive.wsf /DriveToMap:"\\server\path" with my path and it did map. I'm going to add ZTIMapDrive.wsf to LTICopyScripts.wsf under ScriptsToCopy in case that is needed and try again. Any other suggestions?

    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.

    Mittwoch, 13. Juni 2012 14:00
  • If you pressed F8 and typed in "cscript %scriptroot%" at the start then it shouldn't work. The command prompt is external to the MDT process, and %ScriptRoot% is an MDT variable only so CMD cant translate it to Z: in your case.

    If you run it as a "Run Command Line" action within your task sequence then it *should* work, it did when I tested it anyway. If you still have issues then I'll have another look.

    Mittwoch, 13. Juni 2012 14:26
  • I had a feeling about that. Thank you for clarifying. I am still getting an error when it tries to run that script and it does not map. I think I should have mentioned that I am on MDT 2012. I'm unsure if that makes a difference. Here is a screenshot of the summary report and how I have it setup.

    Type: Run Command Line

    Name: Map Additional Share

    Command Line: cscript %scriptroot%\ZTIMapDrive.wsf /DriveToMap:\\172.21.20.96\tsg


    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.



    • Bearbeitet Hans Lima Mittwoch, 13. Juni 2012 19:50
    Mittwoch, 13. Juni 2012 19:47
  • I am utterly perplexed by this one. I can't imagine what file it's looking for and can't find. To test, I've tried renaming files, folders, changed the contents on the script and nothing I do can make it break with the error you're getting (I'm also using 2012).

     

    I'm really curious now though so will keep looking.

    In the mean time, you don't need to add it to your LTICopyScripts.wsf script so I'd suggest replacing that with the original file.

    Mittwoch, 13. Juni 2012 20:39
  • Me too! Good to know that we are on the same version. Thank you for looking into this. I'll replace LTICopyScripts.wsf with the original file.

    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.

    Mittwoch, 13. Juni 2012 20:43
  • Would you mind uploading your smsts.log file from a failed deployment?

    Also, for testing this you could create a 1 line task sequence with just this 1 action in it and run litetouch.wsf within Windows 7/XP rather than rebuilding every time.

    Mittwoch, 13. Juni 2012 21:11
  • I was going to ask about how to go about testing just that one command lind. It works as a 1 liner but I don't know why it won't work through a full deployment. I disabled Apply Local GPO Package in case that was affecting it. I also moved it to a different position in the sequence with no luck. I am working on a full build to get you the smsts.log.


    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.

    Donnerstag, 14. Juni 2012 19:19
  • I got it to work! So here is the strange fix. I removed the task I created and recreated it using the same exact info and now it is working like a charm. Thank you for providing exactly what I was looking for and for the time spent on this. Really appreciate it!

    Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.

    Freitag, 15. Juni 2012 19:03
  • Heh, how strange :)

    Thats scripting for you though eh. Glad it's all working now anyway.

    Freitag, 15. Juni 2012 19:45
  • Do you have a way to unmap a drive once finished?

    Thanks

    Donnerstag, 24. Oktober 2013 17:10