transforming simple function into advanced function

hey guys, please find the script in this git link .. 

https://gist.github.com/VScriptsSIS/1fe7db1a4dd2655609c6

i want to transform the function into advanced function therefore i can use the same script with fully automated style
by providing the $getproject in advance and pipeline it to the function

thanks in advance.

July 10th, 2015 3:41am

Hi Vagharsh,

I've taken the liberty to rewrite some of your function.

Noteable Changes:

  • Removed the Project query. Instead, create a dedicated Get-Project function.
  • Renamed all function calls to conform with PowerShell naming convention
  • Added a husk for function help. Fill it with content, users can then use Get-Help on the function to ...  get help :)

Further, please note that your parameter names should better denote what they are used for (File, File1 and File2 are hard to distinguish).

function Select-Project
{
	<#
		.SYNOPSIS
			A brief description of the Select-Project function.
		
		.DESCRIPTION
			A detailed description of the Select-Project function.
		
		.PARAMETER File
			A description of the File parameter.
		
		.PARAMETER File1
			A description of the File1 parameter.
		
		.PARAMETER File2
			A description of the File2 parameter.
		
		.PARAMETER Project
			A description of the Project parameter.
		
		.EXAMPLE
			PS C:\> Select-Project -File $value1 -File1 $value2
		
		.NOTES
			Add some notes
		
		.LINK
			Link to online help.
	#>
	[CmdletBinding()]
	Param (
		[Parameter(Position = 0)]
		$File,
		
		[Parameter(Position = 1)]
		$File1,
		
		[Parameter(Position = 2)]
		$File2,
		
		[Parameter(ValueFromPipeline = $true)]
		$Project
	)
	
	Process
	{
		foreach ($proj in $Project)
		{
			if (-not (Validate-Project $proj))
			{
				throw "Invalid project!"
			}
			
			Process-Project $proj
			
			$something = Import-Clixml $File
			
			$something | % {
				Select-ProjectDirectory $_ 'src'
				Select-ProjectDirectory $_ 'dst'
			}
			
			Prepare-AppNames $File1 'src'
			Prepare-AppNames $File2 'dst'
		}
	}
}

Cheers,
Fred

Free Windows Admin Tool Kit Click here and download it now
July 10th, 2015 4:38am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics