共用方式為


Configuring Skype for Business Websites IIS Log Directory on a range of Front End Servers

Hi All

I often help out customers performing builds of a number of Skype Servers and so I often find myself trying to configure things for a bunch of servers with Powershell. One of my recent activities was to try and automate the configuration of the IIS Log Directory for the two Skype IIS Websites. It's pretty easy to do on the Front End itself but I wasn't too sure how to do it remotely against a bunch of Front Ends.

One of the nice things about my lab environment is that all of my Skype Front Ends have in their name "-SF", and this is important as I am using an Active Directory query to find all servers matching that string. You of course need to be careful here as you might have other servers matching the string your Skype Servers are named with. If that is the case, that's fine just use the Get-Content cmdlet and put all your Front Ends in a .txt file you can import instead of running the Get-ADComputer cmdlet. Either way, the result is still the same, configuring IIS Log Folders for a bunch of servers.

Why move? The main reason I tend to move the IIS Log folder off the C: drive is that these days I often see Skype Servers deployed in a virtual machines with a skinny C: drive and an additional 50-100GB secondary drive for data. As Skype is a pretty IIS heavy application, meaning the Skype/Lync client will generate a lot of web requests in IIS, it can mean that you have quite a lot of IIS Log Files (GBs). So in order to protect the C: drive from being impacted I often recommend reconfiguring the two Skype IIS Websites to have their Log Files outputted to the secondary data drive.

So the good news is with the Invoke-Command cmdlet it is reasonably easy to execute a bunch of commands and initiate them against the remote machine. It's a lot like using Sysinternals PSExec to run commands against a remote machine, the main difference with invoke-command is that I am running Powershell commands.

Below are the commands I used to reconfigure IIS Log files to the D: drive for all of my 6 *-SF* Skype for Business 2015 Front End Servers (make sure you have a D: before you run this :) ).

#Skype Front End IIS

$strScriptBlock= {  

If (!(Test-Path "d:\Logs\Skype\IIS\External")){Md d:\Logs\Skype\IIS\External}
If (!(Test-Path "d:\Logs\Skype\IIS\Internal")){Md d:\Logs\Skype\IIS\Internal}  

import-module WebAdministration 

Set-ItemProperty 'IIS:\Sites\Skype for Business Server External Web Site' -name logFile.directory -value 'd:\Logs\Skype\IIS\External'
Set-ItemProperty 'IIS:\Sites\Skype for Business Server Internal Web Site' -name logFile.directory -value 'd:\Logs\Skype\IIS\Internal'

}

#Find all the *-SF* servers in Active Directory and then loop through each of them to configure IIS Logs. Use Get-Content serversfile.txt if you're Skype Servers aren't named with a unique string you can search for!

cls;write-host "Skype IIS Log Files";Get-ADComputer -filter {name -like "*-SF*"} |sort-property dnshostname | %{

$strServer=$_.dnshostname;

Write-host "Configuring IIS Log Files for $strServer!"

#Check to see if the server is up by hitting the C$ share....
If (Test-Path \\$strServer\c$) { 

Invoke-Command -ComputerName $strServer -ScriptBlock $strScriptBlock

} Else {

Write-host"$strServer is not online!"

}

}

Now as you are interested in Skype deployments, no doubt you are interested in Office Web App 2013 (OWA) as well. OWA is an IIS application as well so you can also move the IIS Log Files for these servers as well. The same approach applies. (In this example all my Office Web App Servers were named with the unique string -OW).

#Office Web App IIS

$strScriptBlock= {  

If (!(Test-Path "d:\Logs\IIS\OWA")){Md d:\Logs\IIS\OWA}

import-module WebAdministration 

Set-ItemProperty 'IIS:\Sites\HTTP809' -name logFile.directory -value 'd:\Logs\IIS\OWA\HTTP809';
Set-ItemProperty 'IIS:\Sites\HTTP80' -name logFile.directory -value 'd:\Logs\IIS\OWA\HTTP80';

}

cls;write-host "OWA IIS Log Files";Get-ADComputer -filter {name -like "*-OW*"} |sort-property dnshostname | %{

$strServer=$_.dnshostname;

Write-host "Configuring IIS Log Files for $strServer!"

#Check to see if the server is up by hitting the C$ share....
If (Test-Path \\$strServer\c$) { 

Invoke-Command -ComputerName $strServer -ScriptBlock $strScriptBlock

} Else {

Write-host"$strServer is not online!"

}

}

Now as usual, please feel free to use these commands in your environment but please test, test and test in a dev/test environment before running in Production. While the commands are relatively harmless, it is still important to test and ensure they work for your environment.

 

Happy Skypeíng

 

Steve