Here’s another post with scripts from my sessions at SharePoint Conference 2014 – this time from the Mastering Office Web Apps 2013 Operations and Deployments session (SPC383). To get a more in-depth explanation of all the details, please watch the recording at Channel 9.

Let’s start…but first! OWA = Outlook Web App and WAC = Office Web Apps (Web Application Companion).

Preparing the machine before installing Office Web Apps

Before you install the Office Web Apps bits on the machine you need to install a set of Windows Features. The following script is the one you should use (not the one on TechNet) and it works for Windows Server 2012 and Windows Server 2012 R2.

# WAC 2013 preparation for Windows Server 2012 (R2)
Import-Module ServerManager

# Required Features
Add-WindowsFeature NET-Framework-45-Core,NET-Framework-45-ASPNET,`
    Web-Mgmt-Console,Web-Common-Http,Web-Default-Doc,Web-Static-Content,`
    Web-Filtering,Web-Windows-Auth,Web-Net-Ext45,Web-Asp-Net45,Web-ISAPI-Ext,`
    Web-ISAPI-Filter,Web-Includes,InkAndHandwritingServices,NET-WCF-HTTP-Activation45

# Recommended Features
Add-WindowsFeature Web-Stat-Compression,Web-Dyn-Compression

# NLB
Add-WindowsFeature NLB, RSAT-NLB

Note, that I also add the NLB features here – it is not required if you use another load balancer.

Starting a sysprepped WAC machine

The following script is used when booting up a sysprepped machine that has all the Office Web App binaries installed (including patches and language packs), but no WAC configuration whatsoever. It will simply configure a NIC on the box and then join the machine to a domain and rename the machine. A very simple script that can be automated. Most of the scripts, just as this one, contains a set of variables in the beginning of the script. This makes it much more easier to modify and work with the scripts.

$domain = "corp.local"
$newName = "WACSPC2"
$ou = "ou=WAC,dc=corp,dc=local"

$ethernet = "Ethernet1"
$ip = "172.17.100.96" 
$prefix = 24
$dns = "172.17.100.1"

# Set IP
Write-Host -ForegroundColor Green "Configuring NIC..."
New-NetIPAddress -InterfaceAlias $ethernet -IPAddress $ip -AddressFamily IPv4 -PrefixLength $prefix 
Set-DnsClientServerAddress -InterfaceAlias $ethernet -ServerAddresses $dns

# Verify 
ping 172.17.100.1

# Get creds
$credentials = Get-Credential -Message "Enter credentials with add computer to domain privilegies"

# Join domain
Write-Host -ForegroundColor Green "Joining domain..."
Add-Computer -Credential $credentials -DN $domain -OUPath $ou 

# rename
Write-Host -ForegroundColor Green "Renaming machine..."
Rename-Computer -NewName $newName

# Reboot
Write-Host -ForegroundColor Green "Restarting..."
Restart-Computer

Once this script is executed the machine should reboot and be joined to a domain.

Configure a new Office Web Apps Farm

Once the machine is joined to the domain it is time to configure Office Web Apps. If you want more information about the variables/parameters I use I recommend watching the session! These variables are solely for demo purposes and you should adapt them to your needs. Also this step requires that you have a valid certificate (pfx file) that conforms to the WAC certificate requirements.

# New WAC Farm
Import-Module OfficeWebApps

$farmou = "WAC"                           # Note the format!!
$internalurl = "https://wacspc.corp.local"
$externalurl = "https://wacspc.corp.com"
$cachelocation = "c:\WACCache\"           # %programdata%\Microsoft\OfficeWebApps\Working\d\
$loglocation = "c:\WACLog\"               # %programdata%\Microsoft\OfficeWebApps\Data\Logs\ULS\
$rendercache = "c:\WACRenderCache\"       # %programdata%\Microsoft\OfficeWebApps\Working\waccache
$size = 5                                 # Default 15GB
$docinfosize = 1000                       # Default 5000
$maxmem = 512                             # Default 1024
$cert = "wacspc.corp.local.pfx"              # File name
$certname = "wacspc.corp.local"              # Friendly name


$certificate = Import-PfxCertificate -FilePath (Resolve-Path $cert) -CertStoreLocation  Cert:\LocalMachine\My -ea SilentlyContinue 
$certificate.DnsNameList | ft Unicode


New-OfficeWebAppsFarm -FarmOU $farmou `
    -InternalURL $internalurl `
    -ExternalURL $externalurl `
    -OpenFromUrlEnabled `
    -OpenFromUncEnabled `
    -ClipartEnabled `
    -CacheLocation $cachelocation `
    -LogLocation $loglocation `
    -RenderingLocalCacheLocation $rendercache `
    -CacheSizeInGB $size `
    -DocumentInfoCacheSize $docinfosize `
    -MaxMemoryCacheSizeInMB $maxmem `
    -CertificateName $certname `
    -EditingEnabled `
    -Confirm:$false
    
    
(Invoke-WebRequest https://wacspc1.corp.local/m/met/participant.svc/jsonAnonymous/BroadcastPing).Headers["X-OfficeVersion"]

As a last step I do a verification of the local machine and retrieve the current Office Web Apps version.

Create the NLB cluster

In my session I used NLB for load balancing. The following scripts creates the cluster and adds the machine as the first node to that cluster. The script will also install the DNS RSAT feature and add two DNS A records for the internal and external names for the Office Web Apps Server. That step is not required and might/should be managed by your DNS operations team.

# Create NLB Cluster
$ip = "172.17.100.97"
$interface = "Ethernet1"

# New NLB Cluster
New-NlbCluster -ClusterPrimaryIP $ip -InterfaceName $interface -ClusterName "SPCWACCluster" -OperationMode Unicast -Verbose

# DNS Bonus
Add-WindowsFeature  RSAT-DNS-Server  
Import-Module DnsServer
Add-DnsServerResourceRecordA -Name "wacspc" -ZoneName "corp.local" -IPv4Address $ip -ComputerName ( Get-DnsClientServerAddress $interface  -AddressFamily IPv4).ServerAddresses[0]
ping wacspc.corp.local
Add-DnsServerResourceRecordA -Name "wacspc" -ZoneName "corp.com" -IPv4Address $ip -ComputerName ( Get-DnsClientServerAddress $interface  -AddressFamily IPv4).ServerAddresses[0]
ping wacspc.corp.com

Adding additional machines to the WAC farm

Adding additional machines to the WAC farm is easy, just make sure you have the certificate (pfx file) and use the following scripts on the additional machines:

Import-Module OfficeWebApps

$server = "wacspc1.corp.local"
$cert = "wacspc.corp.local.pfx"  

Import-PfxCertificate -FilePath (Resolve-Path $cert) -CertStoreLocation  Cert:\LocalMachine\My -ea SilentlyContinue 

New-OfficeWebAppsMachine -MachineToJoin $server

# Verify
(Get-OfficeWebAppsFarm).Machines

Configuring NLB on the additional WAC machines

And of course you need to configure NLB and add the new WAC machines into your NLB cluster:

$hostname = "WACSPC1"
$interface = "Ethernet1"

Get-NlbCluster -HostName $hostname | Add-NlbClusterNode -NewNodeName $env:COMPUTERNAME -NewNodeInterface $interface

That is all of the scripts I used in the session to set up my WAC farm. All that is left is to connect SharePoint to your Office Web Apps farm

Configure SharePoint 2013

In SharePoint 2013 you need to add WOPI bindings to the Office Web Apps farm. The following script will add all the WOPI bindings and also start a full crawl (required for the search previews):

The first part (commented out in this script) should only be used if your SharePoint farm is running over HTTP (which it shouldn’t of course!).

asnp microsoft.sharepoint.powershell -ea 0

# SharePoint using HTTPS?
#(Get-SPSecurityTokenServiceConfig).AllowOAuthOverHttp
#$config = Get-SPSecurityTokenServiceConfig
#$config.AllowOAuthOverHttp = $true
#$config.Update()
#(Get-SPSecurityTokenServiceConfig).AllowOAuthOverHttp

# Create New Binding
New-SPWOPIBinding -ServerName wacspc.corp.local
Get-SPWOPIBinding | Out-GridView

# Check the WOPI Zone
Get-SPWOPIZone

# Start full crawl
$scope = Get-SPEnterpriseSearchServiceApplication | 
    Get-SPEnterpriseSearchCrawlContentSource | 
    ?{$_.Name -eq "Local SharePoint Sites"}

$scope.StartFullCrawl()

# Wait for the crawl to finish...
while($scope.CrawlStatus -ne [Microsoft.Office.Server.Search.Administration.CrawlStatus]::Idle) {
    Write-Host -ForegroundColor Yellow "." -NoNewline
    Sleep 5
}
Write-Host -ForegroundColor Yellow "."

Connect Exchange 2013 to Office Web Apps

In the session I also demoed how to connect Office Web Apps and Exchange 2013. The important things here to remember is that you need to specify the full URL to the discovery end-point and that you need to restart the OWA web application pools.

# WAC Discovery Endpoint
Set-OrganizationalConfig -WACDiscoveryEndpoint https://wacspc.corp.local/hosting/discovery

# Recycle OWA App Pool
Restart-WebAppPool -Name MSExchangeOWAAppPool

# (Opt) Security settings
Set-OwaVirtualDirectory "owa (Default Web Site)" -WacViewingOnPublicComputersEnabled $true -WacViewingOnPrivateComputersEnabled $true

Summary

I know I kept all the instructions in this blog post short. You really should watch the recording to get the full picture. Good luck!