none
Assign Apps based on server hostname wildcard

    Question

  • Is there a way of assigning apps/tasks to server hostname wildcards?

    If an admin inputs anyone of the following server hostnames into the MDT Wizard:

    1. APPSERVER01
    2. APPSERVER02
    3. WEBSERVER01
    4. WEBSERVER02
    5. K1000
    6. K1001

    Can certain apps be automatically assigned to hostnames APPSERVER%% and other apps assigned to WEBSERVER%% etc etc ?

    Tuesday, May 15, 2018 11:22 PM

All replies

  • Just to confirm, you want to assign a selection of applications based on the hostname prefix (i.e. the name you assign in the MDT wizard)?

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Wednesday, May 16, 2018 6:21 AM
  • Thats correct, but rather than listing all possible hostnames in the MDT Database, I was hoping it could work using wildcards.

    Our servers have a hostname naming format and our desktops have their own.

    Wednesday, May 16, 2018 8:45 PM
  • Got it. Nothing built-in I can think of right now, but in this case, you can easily bypass this by using a small PowerShell script and - optionally - app bundles. 

    Here is the script that will set a customer property you can use to dynamically set execution conditions based on the first part of a hostname:

    <#
     
    ************************************************************************************************************************
     
    Created:    2018-05-16
    Version:    1.0
    
    Author:     Anton Romanyuk, Login Consultants Germany GmbH (C) 2018
    
    Purpose:    Used to set a TS property based on the hostname
    
    Changelog:
     
    ************************************************************************************************************************
     
    #>
    
    # Determine where to do the logging 
    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 
    $logPath = $tsenv.Value("LogPath")
    $logFile = "$logPath\$($myInvocation.MyCommand).log"
    
    # Create Logfile
    Write-Output "Create Logfile" > $logFile
     
    Function Logit($TextBlock1){
    	$TimeDate = Get-Date
    	$OutPut = "$ScriptName - $TextBlock1 - $TimeDate"
    	Write-Output $OutPut >> $logFile
    }
    
    # Start Main Code Here
    
    $ScriptName = $MyInvocation.MyCommand
    $RunningFromFolder = $MyInvocation.MyCommand.Path | Split-Path -Parent 
    . Logit “Running from $RunningFromFolder”
    
    If ($env:computername -like "WEBSERVER*") {
        . Logit "Identified the system as a web server."
        $TSenv.Value("SystemType") = "WEBSERVER"
    } 
    ElseIf ($env:computername -like "APPSERVER*") {
        . Logit "Identified the system as an application server."
        $TSenv.Value("SystemType") = "APPSERVER"
    } 
    Else {
        . Logit "Identified the system as a client."
        $TSenv.Value("SystemType") = "CLIENT"
    }
    

    Add the following property to your CS.ini = ComputerType

    You can then use this property and add execution conditions to your app bundles / TS folders containing app installations.

    Does this make sense?


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Wednesday, May 16, 2018 9:12 PM