Hi Sebastian,
You can use the "Add-WFAWorkflowParameter" cmdlet to add the value of any attribute you'd like as a WFA return parameter.
Here is an example of a WFA command to create a LUN and return the LUN's Serial Number, NAA Number and Path.
Hope that helps
/Matt
Param(
[Parameter(Mandatory=$True, HelpMessage="The Cluster IP address or name")]
[String]$Cluster,
[Parameter(Mandatory=$True, HelpMessage="The vserver name")]
[String]$VserverName,
[Parameter(Mandatory=$True, HelpMessage="The volume name")]
[String]$VolumeName,
[Parameter(Mandatory=$False, HelpMessage="The Qtree name")]
[String]$QtreeName,
[Parameter(Mandatory=$True, HelpMessage="The LUN name")]
[String]$LunName,
[Parameter(Mandatory=$False, HelpMessage="The LUN Comment")]
[String]$LunComment,
[Parameter(Mandatory=$True, HelpMessage="The operating system type for the LUN")]
[ValidateSet("solaris", "windows", "hpux", "xen", "aix", "linux", "netware", "vmware", "openvms", "hyper_v", "image", "solaris_efi", "windows_2008", "windows_gpt")]
[String]$OSType,
[Parameter(Mandatory=$False, HelpMessage="The space reservation mode")]
[Bool]$SpaceReserved = $True,
[Parameter(Mandatory=$True, HelpMessage="The LUN size in MB")]
[Alias("LunSize_Capacity")]
[Int]$LunSize,
[Parameter(Mandatory=$False, HelpMessage="The size of the prefix stream in Bytes")]
[Alias("PrefixSize_Capacity")]
[Int]$PrefixSize = -1,
[Parameter(Mandatory=$False, HelpMessage="The name of the QoS policy group to be attached to the LUN. This parameter is valid for clusters with ONTAP version 8.2.0 onwards.")]
[String]$QoSPolicyGroupName
)
#'------------------------------------------------------------------------------
Function Get-AsciiToHex{
<#
.SYNOPSIS
This function converts an ASCII string to Hexadecimal string.
.DESCRIPTION
converts an ASCII string to Hexadecimal string.
.PARAMETER
AsciiValue Accepts an ASCII string containing the value to be converted to Hexadecimal
.EXAMPLE
Get-AsciiToHex -AsciiValue "W-XPe4ctkQhp"
#>
[CmdletBinding()]
Param(
[Parameter(Position=0,
Mandatory=$True,
ValueFromPipeLine=$True,
ValueFromPipeLineByPropertyName=$True)]
[String]$AsciiValue
)
[Array]$hexValues = @()
For($i = 1; $i -le $AsciiValue.Length; $i++){
[String]$stringValue = $AsciiValue.SubString(($i -1), 1)
[Array]$hexValues += "{0:X}" -f [Byte][Char]$stringValue
}
Return [String]::join("", $hexValues).ToLower();
}#End Function
#'------------------------------------------------------------------------------
#'Connect to the cluster and vserver.
#'------------------------------------------------------------------------------
Get-WFALogger -Info -Message "Connecting to cluster ""$cluster"""
Connect-WfaCluster $Cluster
#'------------------------------------------------------------------------------
#'Check the ONTAP version if a QoS Policy Group is provided.
#'------------------------------------------------------------------------------
If($QoSPolicyGroupName){
[String]$command = "Get-NcSystemVersionInfo -ErrorAction Stop"
Try{
$versionInfo = Invoke-Expression -Command $command -ErrorAction Stop
Get-WFALogger -Info -Message "Executed Command`: $command"
}Catch{
Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
Throw "Failed Executing Command`: $command"
}
$version = $versionInfo.VersionTuple.ToString()
$versionCompareValue = Compare-OntapVersions $version "8.2.0"
If($versionCompareValue -lt 0){
Throw "The QoS policy group can be set on LUNs only on clusters with ONTAP version 8.2.0 onwards."
}
}
#'------------------------------------------------------------------------------
#'Set the LUN Path.
#'------------------------------------------------------------------------------
If($QtreeName){
[String]$lunPath = "/vol/$VolumeName/$QtreeName/$LunName"
}Else{
[String]$lunPath = "/vol/$VolumeName/$LunName"
}
#'------------------------------------------------------------------------------
#'Set the command to create the LUN.
#'------------------------------------------------------------------------------
$size = [String]$LunSize + "m"
$command = "New-NcLun -Path $lunPath -Size $size -OsType $OSType -VserverContext $VserverName"
If($LunComment){
$command += " -Comment $LunComment"
}
If($PrefixSize -ge 0){
$command += " -PrefixSize $PrefixSize"
}
If(-Not($SpaceReserved)){
$command += " -Unreserved"
}
If($QoSPolicyGroupName){
$command += " -QosPolicyGroup $QoSPolicyGroupName"
}
[String]$command += " -ErrorAction Stop"
#'------------------------------------------------------------------------------
#'Create the LUN.
#'------------------------------------------------------------------------------
Try{
Invoke-Expression -Command $command -ErrorAction Stop
Get-WFALogger -Info -Message "Executed Command`: $command"
}Catch{
Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
Throw "Failed Executing Command`: $command"
}
#'------------------------------------------------------------------------------
#'Enumerate the LUN
#'------------------------------------------------------------------------------
[String]$command = "Get-NcLun -Path $lunPath -VserverContext $VserverName -ErrorAction Stop"
Try{
$lun = Invoke-Expression -Command $command -ErrorAction Stop
Get-WFALogger -Info -Message "Executed Command`: $command"
}Catch{
Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
Throw "Failed Executing Command`: $command"
}
[String]$lunSerial = $lun.SerialNumber
Get-WFALogger -Info -Message "The Serial Number for LUN ""$lunPath"" is ""$lunSerial"""
#'------------------------------------------------------------------------------
#'Enumerate the LUN Serial number.
#'------------------------------------------------------------------------------
If($lunSerial -eq ""){
Throw "Failed enumerating LUN Serial Number"
}
#'------------------------------------------------------------------------------
#'Enumerate the LUN NAA number.
#'------------------------------------------------------------------------------
[String]$identifier = "naa.600a0980"
[String]$LUNNaaNumber = $identifier + (Get-AsciiToHex -AsciiValue $lunSerial)
#'------------------------------------------------------------------------------
#'Set return parameters
#'------------------------------------------------------------------------------
Add-WfaWorkflowParameter -Name "LUNSerialNumber" -Value $lunSerial -AddAsReturnParameter $True
Add-WfaWorkflowParameter -Name "LUNNaaNumber" -Value $LUNNaaNumber -AddAsReturnParameter $True
Add-WfaWorkflowParameter -Name "LUNPath" -Value $lunPath -AddAsReturnParameter $True
#'------------------------------------------------------------------------------
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.