Lab Setup Script – Part 6 – Advanced Features 3

In Part 6 of my Lab Setup Script series, I will cover these topics:

  • Mobile Device Policy Configuration
  • OWA Policies – all options
  • OWA Virtual Directory
  • OWA Virtual Directory Permissions
  • Custom apps

This one took a bit more to write as I did not realize the amount of coding it would take to put in place the OWA URL changes and provide some sort of feedback for each change to be made. Starting in alphabetical order I started with the ‘ADFS Authentication’ setting. What we need to remember with this setting any other authentication is that the OWA directly is attached to the hip with the RCP virtual directory. So when authentication changes are made to one, the other needs to be pulled along with. When you review the code for these sections, note the checks and rechecks that are put in place to make sure the pair is changed in the correct order.

Mobile Device Policy Configuration

This feature was developed as an external script because of the size and ‘complexity’ of the script. See this blog post that explains how it works.

OWA Mailbox Policy Configuration

This feature was developed as an external script because of the size and ‘complexity’ of the script. See this blog post that explains how it works.

OWA Virtual Directory Configuration

This feature was developed as an external script because of the size and ‘complexity’ of the script. See this blog post that explains how it works.

OWA Virtual Directory Permissions

This feature was developed as an external script because of the size and ‘complexity’ of the script. See this blog post that explains how it works.

Custom apps

For this section of code I added login that will ask for a custom XML manifest file in order to install the new App.

Source Code

# Configuring apps forExchange 2013
function configure-Apps {
    $option = read-host "Do you want to configure Apps (1) or add new Apps (2)"

    # Prep Random mailboxes (version 1)
    $mbxcount = (get-mailbox | where {$_.RecipientTypeDetails -ne "DiscoveryMailbox"}).count
    $range =  get-random -minimum 0 -maximum $mbxcount
    $mailbox = (get-mailbox | where {$_.RecipientTypeDetails -ne "DiscoveryMailbox"}).alias

    # Create Random User List
    $counter = 0
    $userlist = @()
    while ($counter -lt $range) {
                $alias = $mailbox[$counter]
                $userlist += @($alias)
                $counter++
    }

    if ($option -eq "1") {
        write-host "Currently there are these apps installed in your Exchange Server 2013 environment"
        get-app -OrganizationApp |ft displayname,providedto,userlist -auto
        $app = (get-app -OrganizationApp).appid
        $choice = read-host "Do you want to limit the apps to random users or allow them for all users [r or a]"
        $mailboxes = (get-mailbox | where {$_.RecipientTypeDetails -ne "DiscoveryMailbox"}).alias
        if ($choice -eq "a") {
            $name = (get-mailbox $alias).displayname
            foreach ($line in $mailboxes) {
                foreach ($line in $app) {
                    set-app $line -OrganizationApp $true -enabled $true
                }
            }
            write-host "Apps have been configured for all users." -foregroundcolor green    
        } else {            
            foreach ($line in $app) {
                Set-App $line -organizationapp -ProvidedTo SpecificUsers -UserList $userlist
            }
        }
    } else {
        $choice2 = read-host "Install apps from this script (1) or choose your own apps (2) "
        write-host " "
        $choice = read-host "Do you want to limit the apps to random users or allow them for all users [r or a]"
        if ($choice2 -eq 1) {
            write-host " "
            write-host "For your custom app, you need an XML Manifest file in order to install it." -ForegroundColor Green
            write-host " "
            # $xml = read-host "Enter a local path to the XML file for the App "
            $Data = get-content -Encoding byte -Path "c:\scripts\manifest.xml" -ReadCount 0
        } else {
        $xml = read-host "What is the full path and file name for your XML file? [i.e. \scripts\manifest.xml] "
        $Data = get-content -Encoding byte -Path $xml -ReadCount 0
        }
        if ($choice -eq "a") {
            new-app -DefaultStateForUser Enabled -filedata $data -OrganizationApp
        } else {
            new-app -DefaultStateForUser Enabled -filedata $data -OrganizationApp -ProvidedTo SpecificUsers -UserList $userlist
        }
    }
} # end of the configure-Apps function

Custom Apps in Action

For installing a custom app, we need the location of the manifest.xml file and any related files that may be needed. To install simply follow the menu selections as seen in this screenshot:

CustomApp

I used the script to install the InfoApp which can be found here. He provides a download link at the bottom. There us also a bit more information here as well. Once installed you will see something like this:

InfoApp

Script Download – Version 1.5
Current version all corrected to add the new features, including custom apps. You will need to download all scripts from the past few articles in order to use menu features 24-27.

LabSetup-1.5

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s