Category: OWA

Set Outlook Web App (OWA) Logon Format with PowerShell script

I’ve been working with PowerShell recently as you can see from my recent blog posts on setting Exchange 2010 virtual directory settings and on redirecting the OWA URL from http to https.

Below is a script I put together to set the logon format for OWA. Basically it prompts the user about the various types of format available and then goes and builds the relevant commands to configure any Client Access servers in the environment. It should work against Exchange 2007 and 2010 although I’ve only tested Exchange 2010.

 

Write-host "This script will let you set the logon format for OWA virtual directories on Exchange 2010."
Write-host ""

#============================================
#Set Variables
[string]$ConfirmPrompt = "Set this Value? (Y/N)"
[string]$WarningForeground = "white"
[string]$WarningBackground = "red"

#Build Array of OWA virtual directories and then run through for the user

[array]$OWAVDir = Get-OwaVirtualDirectory

#============================================
#Prompt user about how they want login to occur and then get selection
Write-host "How do you want users to log into OWA?"

[string]$type = Read-host "You have three options, EmailAddress (UPN), Domain\username or username. Please enter one of (Email / Domain / Username)"

Write-host ""

#============================================
#Create function for calling later which will do the setting of properties

function ConfigureVirtualDirectory
{
#Get the current AD domain FQDN for use as the default domain if Username format is chosen.

$ADdomain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()

    if ($type -eq "Email")    {
        Write-host "You have opted to use the email address. Please make sure users UPN in active directory matches their email address" -foregroundcolor $WarningForeground -backgroundcolor $WarningBackground
        Foreach ($value in $OWAVDir) {
            Set-OwaVirtualDirectory -Identity $value -LogonFormat PrincipalName }
    }
    if ($type -eq "Domain")    {
        Foreach ($value in $OWAVDir) {
            Set-OwaVirtualDirectory -Identity $value -LogonFormat FullDomain }
    }
    if ($type -eq "Username")    {
        Foreach ($value in $OWAVDir) {
            Set-OwaVirtualDirectory -Identity $value -LogonFormat UserName -DefaultDomain $ADdomain }
    }
}

#===========================================
#Tell user what is about to happen for each server and then give choice to execute

Write-host “Looking at Server: ” $OWAVDir[0].server
    Write-host “Current Logon Format: ” $OWAVDir[0].logonformat
    Write-host “New Logon Format Type:     ” $Type
   [string]$set = Read-host $ConfirmPrompt
    Write-host “”

    if ($set -eq "Y")    {
         ConfigureVirtualDirectory  
    }    else    {
        Write-host "Nothing has been changed, script quit" -foregroundcolor $WarningForeground -backgroundcolor $WarningBackground
        exit
    }

iisreset

WordPress Themes

Get Adobe Flash player