This project has moved and is read-only. For the latest updates, please go here.

Extended version for creating site structure

Jun 16, 2011 at 10:43 AM


The site structure making functions in this script, haven't been enough for us, so we have been using this instead:

There are so many more configuration options in this script that we use, but it would be much nicer to just use one script for setting up our environment.
I would gladly implement it in AutoSPInstaller if you want to, but if you want to your self, that is also fine.

Also, we have requeryments for log placements, such as:

Setting SP log location:

Function Set-SPLogLocation([xml]$xmlinput)
	[string]$LogPath = $xmlinput.Configuration.Farm.SharepointLogs
	EnsureFolder $LogPath
	Write-Host " - Setting Sharepoint log location to: `"$LogPath`""
	$nothing = Set-SPDiagnosticConfig -LogLocation $LogPath | Out-Null

Setting IIS Log location

Function Set-IISLogLocation([string]$IISName,[string]$LogPath)
	if (!(Get-Module | where {$_.Name -like '*WebAdministration*'}))
	{Import-Module WebAdministration}
 	EnsureFolder $LogPath

		Write-Host " - Setting IIS log location on `"$IISName`" to `"$LogPath`""
		$nothing = Set-ItemProperty "IIS:\Sites\$IISName" -name -value $LogPath | Out-Null
	{ Write-Host -ForegroundColor Yellow " - Error setting IIS log location on `"$IISName`" to `"$LogPath`""}

And the EnsureFolder function:

Function EnsureFolder([String]$thepath)
	Write-Host " - Verifying path `"$thepath`"..." -NoNewline
	if (!(Test-Path $thepath))
		Write-Host "doesn't exist - Creating..."
		$ligegyldigt = New-Item $thepath -ItemType directory | Out-Null
		catch { Write-Host -ForegroundColor Yellow "ERR: $($_.Exception.Message)"}
	{Write-Host "exists!"}
Would it be possible for this to get incorporated into the script?

As I said, I can do the coding if you want to - no problemo - but if you rather do it your self, I can understand that.
Jun 17, 2011 at 7:29 PM

Well, I might just then humor my self, and get on with it!

Will report back when done (source code goes to Brian ;-))


Jun 19, 2011 at 6:58 AM

Thanks! This is why I think we need a post install script that gets sourced in like the custom functions script.

Jun 23, 2011 at 3:22 AM

This looks good, Jesper. If you'd like you can upload a Patch from the Source Code tab:

@Kosher, why not use the existing AutoSPInstallerFunctionsCustom.ps1?


May 30, 2012 at 11:46 AM


I found these implemented in ConfigureDiagnosticLogging method of AutoSPInstallerFunctions.ps1 in 2.5.7 version of product.

In case i want to add some more features to this function like setting the Trace Level, do i have to copy the entire function to AutoSPInstallerFunctionsCustom.ps1 and make changes?

If AutoSPInstallerFunctions.ps1 and AutoSPInstallerFunctionsCustom.ps1 have a function with the same name (say 'ConfigureDiagnosticLogging'), which will be called, on a function call in AutoSPInstallerMain.ps1.



May 30, 2012 at 2:02 PM

You can either copy the entire function to AutoSPInstallerFunctionsCustom.ps1 and make changes/additions from there if you like, or you can simply include your additional changes in a new function called (for example) ConfigureAdvancedDiagnosticLogging.

Since AutoSPInstallerFunctionsCustom.ps1 gets dot-sourced (included) after AutoSPInstallerFunctions.ps1, any functions with the same name will override functions that were called earlier (even one line earlier in the AutoSPInstallerMain.ps1). So you can safely use the same name for your functions in AutoSPInstallerFunctionsCustom.ps1 and they will get priority.


May 31, 2012 at 5:02 AM

I will follow the second approach.

Thanks for the info.