Extended version for creating site structure

Jun 16, 2011 at 9:43 AM

Hey!

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

http://blog.falchionconsulting.com/index.php/2009/12/creating-a-sharepoint-2010-site-structure-using-powershell/

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

	try
	{
		Write-Host " - Setting IIS log location on `"$IISName`" to `"$LogPath`""
		$nothing = Set-ItemProperty "IIS:\Sites\$IISName" -name logFile.directory -value $LogPath | Out-Null
	}
	catch
	{ 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..."
		try 
		{
		$ligegyldigt = New-Item $thepath -ItemType directory | Out-Null
		}
		catch { Write-Host -ForegroundColor Yellow "ERR: $($_.Exception.Message)"}
	}
	else
	{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.
Cheers
Jesper
Jun 17, 2011 at 6: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 ;-))

Cheers
/Jesper

Jun 19, 2011 at 5:58 AM

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

Coordinator
Jun 23, 2011 at 2:22 AM

This looks good, Jesper. If you'd like you can upload a Patch from the Source Code tab: http://autospinstaller.codeplex.com/SourceControl/list/patches/upload

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

Cheers
Brian

May 30, 2012 at 10:46 AM

Hi,

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.

Thanks,

Vishnu

Coordinator
May 30, 2012 at 1: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.

Brian

May 31, 2012 at 4:02 AM

I will follow the second approach.

Thanks for the info.


Vishnu