#************************************************************************************************************
# This script returns a collection of web tests for the group by location input.
#
# Parameters:
#
# Collection of IDO with the ID of the GroupByLocation instances. The output location is set to the
# DisplayName of these groups (which should also be given as input on the same IDO).
#
#************************************************************************************************************
###############Help Functions###########################
#
#
function Get-Type (
$type = $(throw "needs to speficy a type")
)
#-------------------------------------------------------
# Helper to get the right generic type created.
#
# Arguments:
# type - the string with the type name.
# args - array of arguments or argumens list
#
# Returns:
# The matching array of types.
#-------------------------------------------------------
{
trap [System.Management.Automation.RuntimeException] { throw ($_.Exception.Message) }
function New-GenericObject(
$type = $(throw "needs to speficy a type"),
[object[]] $typeParameters = $null,
[object[]] $constructorParameters = @()
)
#-------------------------------------------------------
# Helper to instantiate a generic type.
#
# Arguments:
# type - the type (closed one, or a string to be closed).
# typeParameters - generic types to create generic, if not spefified or null then closed type assumed in input.
# constructors - parameters for constructor if not using the default one
#
# Returns:
# The matching array of types.
#-------------------------------------------------------
{
$closedType = (Get-Type $type $typeParameters)
,[Activator]::CreateInstance($closedType, $constructorParameters)
}
function Get-ParametersTypes
#-------------------------------------------------------
# Helper to generate an array of parameter types
# from the actual parameters. Note that it won' work
# if passed argument is null or contain a null value
# in its content.
#
# Arguments:
# params - array of arguments.
#
# Returns:
# The matching array of types.
#-------------------------------------------------------
{
param (
[object[]]$params = $null
)
function Invoke-GenericMethod-WithTypes
#-------------------------------------------------------
# Makes a generic and call it returning whatever it
# returns
#
# Arguments:
# myType - Type containing the generic method.
# myMethod - Method name
# myMethodArgumentTypes - Argument types for the method (support overload)
# genericTypes - Generic passing in types
# object - Object to call the generic on
# params - Parameters for the call
#
# Returns:
# The matching array of types.
#-------------------------------------------------------
{
param (
[type]$myType,
[string]$myMethod,
[type[]]$myMethodArgumentTypes,
$genericTypes,
$object,
[object[]]$params = $null
)
function Invoke-GenericMethod
#-------------------------------------------------------
# Makes a generic and call it returning whatever it
# returns
#
# Arguments:
# myType - Type containing the generic method.
# myMethod - Method name
# genericTypes - Generic passing in types
# object - Object to call the generic on
# params - Parameters for the call
#
# Returns:
# The matching array of types.
#-------------------------------------------------------
{
param (
[type]$myType,
[string]$myMethod,
$genericTypes,
$object,
[object[]]$params = $null
)
function Initialize-Script
#-------------------------------------------------------
# Initialization for testing.
#-------------------------------------------------------
{
if ($global:scriptContext -eq $null)
{
Write-Error "Missing the proper context argumet.";
exit;
}
}
function Initialize-SDK
#-------------------------------------------------------
# Initialize any objects we need from the SDK
#-------------------------------------------------------
{
# The mg
$script:mg = $global:scriptContext.ManagementGroup;
function Fetch-Grouper
#-------------------------------------------------------
# Creates the initial fetch of grouper.
#-------------------------------------------------------
{
$grouper = $null;
function Main
#-------------------------------------------------------
# Main entry point.
#-------------------------------------------------------
{
if ($TargetEntityId -eq $null)
{
Write-Error "The parameter TargetEntityId is null.";
exit;
}
if ($PublicKeyToken -eq $null)
{
Write-Error "The parameter PublicKeyToken is null.";
exit;
}