none
Managing MDT 2013 Update 1 Role Applications using Powershell RRS feed

  • Question

  • I am looking to import a list of applications from csv into MDT database under MDTROLEAPPLICATIONS.  I have been unable to do so using custom commandlets available on the net.  Does any have any useful scripts or now how to script this action? I don't expect anyone to write a custom script from scratch. 

    Wednesday, December 28, 2016 6:05 PM

Answers

  • My college and I were able to create a script.  We are not master scripters by any means but we are able to modify and write scripts to help with everyday repeatable tasks. This scrip provides the following:

    -Creating new roles from csv

    -Adding applications to roles via csv

    First part script - Creates New Roles in MDT

    Import-Module "D:\APPLICD\Scripts\MDTApplicationstoRoles\MDTDB.psm1"
    Connect-MDTDatabase -sqlServer YourServerName -database MDT_TEST

    $roles = Get-Content "Path to MJRoles.csv"
    New-MDTRole -name $role -settings OSInstall=Yes

       }


       New-MDTRole -name "Test" -settings OSINSTALL=YES

    Get-MDTRole


    Get-MDTRole | Select -Property Role

    Second part of the script - Populates Newly created Roles with application from csv

    Import-Module "D:\APPLICD\Scripts\MDTApplicationstoRoles\MDTDB.psm1"
    Connect-MDTDatabase -sqlServer (YourDatabaseName) -database DatabaseName

    $apps = Import-Csv "path to RoleApps.csv"

       $Role = $app.role
       $AppName1 = $app.appname1
       $AppName2 = $app.appname2
       $AppName3 = $app.appname3
       $AppName4 = $app.appname4
       $AppName5 = $app.appname5
       $AppName6 = $app.appname6
       $AppName7 = $app.appname7
       $AppName8 = $app.appname8
       $AppName9 = $app.appname9
       $AppName10 = $app.appname10
       $AppName11 = $app.appname11
       $AppName12 = $app.appname12
       $AppName13 = $app.appname13
       $AppName14 = $app.appname14
       $AppName15 = $app.appname15
       $AppName16 = $app.appname16
       $AppName17 = $app.appname17
       $AppName18 = $app.appname18
       $AppName19 = $app.appname19
       $AppName20 = $app.appname20
       $AppName21 = $app.appname21
       $AppName22 = $app.appname22

       Get-MDTRole -name $Role | Set-MDTRoleApplication -applications @($AppName1,$AppName2,$AppName3,$AppName4,$AppName5,$AppName6,$AppName7,$AppName8,$AppName9,$AppName10,$AppName11,$AppName12,$AppName13,$Appname14,$appname15,$Appname16,$Appname17,$Appname18,$Appname19,$Appname20,$Appname21,$Appname22)



    • Marked as answer by NS2012 Wednesday, December 28, 2016 10:12 PM
    • Edited by NS2012 Wednesday, December 28, 2016 10:13 PM
    Wednesday, December 28, 2016 10:12 PM

All replies

  • You can find some prewritten scripts in the Microsoft Technet Script Gallery

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    Wednesday, December 28, 2016 6:27 PM
  • Thanks,

    Not any relate to managing MDT Roles or importing Applications via Powershell.  I've been testing out custom commandlets with no luck. 

    https://blogs.technet.microsoft.com/mniehaus/2009/05/14/manipulating-the-microsoft-deployment-toolkit-database-using-powershell/

    Wednesday, December 28, 2016 6:39 PM
  • I think you should read the article more carefully:

    import-module .\MDTDB.psm1    
    connect-mdtdatabase -sqlserver MNiehaus-T61P-7 -instance SQLEXPRESS -database MDTDatabase     
    New-MDTPackageMapping -ARPName ‘Zune’ -package ‘XXX00003:Install’


    \_(ツ)_/

    Wednesday, December 28, 2016 6:59 PM
  • Yes this is a great example JRV.  However I'm looking to import applications not packages from a csv.  We are trying to use New-MDTRoleApplication which gives us the capabilities to specify existing applications in SCCM.  We would be adding multiple applications into each role.  I wonder if the syntax is similar to your example.  I dont seem to find information on application mapping.  

    Thanks


    • Edited by NS2012 Wednesday, December 28, 2016 7:18 PM adding picture
    Wednesday, December 28, 2016 7:14 PM
  • My college and I were able to create a script.  We are not master scripters by any means but we are able to modify and write scripts to help with everyday repeatable tasks. This scrip provides the following:

    -Creating new roles from csv

    -Adding applications to roles via csv

    First part script - Creates New Roles in MDT

    Import-Module "D:\APPLICD\Scripts\MDTApplicationstoRoles\MDTDB.psm1"
    Connect-MDTDatabase -sqlServer YourServerName -database MDT_TEST

    $roles = Get-Content "Path to MJRoles.csv"
    New-MDTRole -name $role -settings OSInstall=Yes

       }


       New-MDTRole -name "Test" -settings OSINSTALL=YES

    Get-MDTRole


    Get-MDTRole | Select -Property Role

    Second part of the script - Populates Newly created Roles with application from csv

    Import-Module "D:\APPLICD\Scripts\MDTApplicationstoRoles\MDTDB.psm1"
    Connect-MDTDatabase -sqlServer (YourDatabaseName) -database DatabaseName

    $apps = Import-Csv "path to RoleApps.csv"

       $Role = $app.role
       $AppName1 = $app.appname1
       $AppName2 = $app.appname2
       $AppName3 = $app.appname3
       $AppName4 = $app.appname4
       $AppName5 = $app.appname5
       $AppName6 = $app.appname6
       $AppName7 = $app.appname7
       $AppName8 = $app.appname8
       $AppName9 = $app.appname9
       $AppName10 = $app.appname10
       $AppName11 = $app.appname11
       $AppName12 = $app.appname12
       $AppName13 = $app.appname13
       $AppName14 = $app.appname14
       $AppName15 = $app.appname15
       $AppName16 = $app.appname16
       $AppName17 = $app.appname17
       $AppName18 = $app.appname18
       $AppName19 = $app.appname19
       $AppName20 = $app.appname20
       $AppName21 = $app.appname21
       $AppName22 = $app.appname22

       Get-MDTRole -name $Role | Set-MDTRoleApplication -applications @($AppName1,$AppName2,$AppName3,$AppName4,$AppName5,$AppName6,$AppName7,$AppName8,$AppName9,$AppName10,$AppName11,$AppName12,$AppName13,$Appname14,$appname15,$Appname16,$Appname17,$Appname18,$Appname19,$Appname20,$Appname21,$Appname22)



    • Marked as answer by NS2012 Wednesday, December 28, 2016 10:12 PM
    • Edited by NS2012 Wednesday, December 28, 2016 10:13 PM
    Wednesday, December 28, 2016 10:12 PM