Mask Property name from FL *

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of  Anonymous 1 year, 8 months ago.

  • Author
    Posts
  • #22134
    Profile photo of
    Anonymous

    How to mask a parameter by another name? (not sure what to say here insted of mask; it may be incorrect) to an example? please look at the 1st attached screenshot of exchange command which explains my requirement; the marked parameter is displayed like “Member Server” but if we detail it, then its actually named like “Servers” (See the second image). I just wonder how to do this?

    If this can be achived by ps1xml file then provide me one little example if possible..

  • #22137
    Profile photo of GJ
    GJ
    Participant

    It is known as calculated property. See the below posts fro more information on naming a property

    in your example, the output object is defined with a default display property set hence you are seeing the limited output when you run the cmdlet normally and when you use select * for fl* you see all the properties just like most of the native powershell cmdlets do. Below post may help understand it better.

  • #23960
    Profile photo of
    Anonymous

    ignore this one pls. i was trying to question for another reply

    Function WhoRanIt
    {
    	#Set-PSDebug -Strict # To catch typo variable names which is equivalent to OptionEplicit in VB
    	$Global:WhoRanIt = $Null #Global Variable to catch who ran the script
    	$WhoRanIt=$($ENV:UserName).ToUpper()
    	Write-Verbose $("'"+$WhoRanIt+"'"+" Ran the script")
    	Return $WhoRanIt
    }
    Function DAG_Validation([String]$DAG_User_Input)
    {
    	Try
    	{
    		Get-DatabaseAvailabilityGroup $DAG_User_Input -ErrorAction 'Stop' -ErrorVariable DAG_Validation_Error
    	}
    	Catch
    	{
    		Write-Error $("Cannot find any DatabaseAvailabilityGroup by the name"+": "+$DAG_User_Input+". Please enter a valid DatabaseAvailabilityGroup name.")
    	}
    }
    Function Node_ExcludeNode_Validation([String]$Exception_User_Input)
    {
    	$Error.Clear()
    	Try
    	{
    		If(($Version=((Get-ExchangeServer $Exception_User_Input -ErrorAction Stop).AdminDisplayVersion) -like "*14.3*"))
    		{
    			If(!($(($Error[0]).FullyQualifiedErrorId) -eq "A9B09CBA,Microsoft.Exchange.Management.SystemConfigurationTasks.GetExchangeServer"))
    			{
    				Try
    				{
    					Test-Connection $Exception_User_Input -ErrorAction 'Stop'
    					Get-WmiObject -Class Win32_PerfFormattedData_PerfOS_System -ComputerName $Exception_User_Input -ErrorAction 'Stop' |Select-Object @{Name = 'SystemUpTime'; Expression = {New-TimeSpan -Seconds $_.SystemUpTime}}
    				}
    				Catch
    				{
    					Write-Error $("The node '"+$Exception_User_Input+"' is not pingable. Please check the host.")
    				}
    			}
    		}
    		Else
    		{
    			Write-Error $("'"+$Exception_User_Input+"' Is not Exchange Server 2010.")
    		}
    	}
    	Catch
    	{
    		Write-Error $("The input given for the parameter "+"'ExcludeNode = "+$Exception_User_Input+"'"+" is not an Exchange Server. Please check the input.")
    	}
    }
    Function AllToHosts
    {
    	
    }
    Function Do-PreRebootCheck
    {
    	[CMDLetBinding()]
    	param(
    			[parameter(MAndatory=$False,ValueFromPipeline=$False,Position=0)][String[]]$DAG,
    			[parameter(MAndatory=$False,ValueFromPipeline=$False,Position=1)][String[]]$ExcludeNode,
    			[parameter(MAndatory=$False,ValueFromPipeline=$False,Position=2)][String[]]$Node		
    	)
    	Begin
    	{
    		$Error.Clear()
    		[bool]$DAG_Manual=$False
    		[bool]$ExcludeNode_Manual=$False
    		[bool]$Node_Manual=$False
    		$DAG_Validation_Error=@()
    		Try
    		{
    			Get-Variable $DAG[0] -ErrorAction SilentlyContinue
    		}
    		Catch
    		{
    			$DAG=@()
    			$DAG_Manual=$True
    		}
    		Try
    		{
    			Get-Variable $ExcludeNode[0] -ErrorAction SilentlyContinue
    		}
    		Catch
    		{
    			$ExcludeNode=@()
    			$ExcludeNode_Manual=$True
    		}
    		Try
    		{
    			Get-Variable $Node[0] -ErrorAction SilentlyContinue
    		}
    		Catch
    		{
    			$Node=@()
    			$Node_Manual=$True
    		}
    	}
    	Process
    	{
    		If($DAG[0] -ne $Null)
    		{
    			If($Node_Manual)
    			{	
    				If($Node[0] -eq $Null)	
    				{
    					ForEach($D in $DAG)
    					{
    						DAG_Validation -DAG_User_Input $D
    					}
    				}
    			}
    			Else
    			{
    				Write-Warning $("You cannot have the 'Node' when you are using the parameters 'DAG' or combination of DAG & 'ExcludeNode'")
    			}
    		}
    		If($ExcludeNode[0] -ne $Null)
    		{
    			If($ExcludeNode[0] -ne $Null -And $DAG[0] -ne $Null)
    			{
    				If($Node_Manual)
    				{
    					If($ExcludeNode[0] -ne $Null -And $Node[0] -eq $Null)
    					{
    						ForEach($E in $ExcludeNode)
    						{
    							Node_ExcludeNode_Validation -Exception_User_Input $E
    						}
    					}
    				}
    				Else
    				{
    					Write-Warning $("You cannot have the 'Node' when you are using the parameters 'DAG' or combination of 'DAG' with'ExcludeNode'")
    				}
    			}
    			Else
    			{
    				Write-Warning $("You cannot have the 'ExcludeNode' without using the parameter 'DAG'. If you want to execute against a single or selected hosts, then you can use the parameter 'Node'")
    			}
    		}
    		If($Node[0] -ne $Null)
    		{
    			If($DAG[0] -eq $Null)
    			{
    				If($ExcludeNode[0] -eq $Null)
    				{
    					ForEach($E in $Node)
    					{
    						Node_ExcludeNode_Validation -Exception_User_Input $E
    					}
    				}
    				Else
    				{
    					Write-Warning $("You cannot have the 'ExcludeNode' when using the parameter 'Node'")
    				}
    			}
    			Else
    			{
    				Write-Warning $("You cannot have the 'DAG' when using the parameter 'Node'")
    			}
    		}
    	}
    }
    

    dsf

    function Set-WindowMaximized
    {
      Process
      {
    	$temp_PSCal1=$Host.UI.RawUI.MaxPhysicalWindowSize
    	$temp_PSCal1.Width-=3
    	$temp_PSCal1.Height=9999
    	$Host.UI.RawUI.BufferSize=$temp_PSCal1
    	$temp_PSCal2=$Host.UI.RawUI.WindowSize
    	$temp_PSCal2.Width=$temp_PSCal1.Width-=3
    	$Host.UI.RawUI.WindowSize=$temp_PSCal2
     $memberDefinition = @'
        [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
        [DllImport("user32.dll", SetLastError = true)] public static extern bool SetForegroundWindow(IntPtr hWnd);
    '@
        Add-Type -MemberDefinition $memberDefinition -Name Api -Namespace User32
        [int]$hwnd = Get-Process -Id $PID | Select-Object -ExpandProperty MainWindowHandle
        If ($hwnd)
        {
          $onTop = New-Object -TypeName System.IntPtr -ArgumentList (0)
          $null=[User32.Api]::SetForegroundWindow($hwnd)
          $null=[User32.Api]::ShowWindow($hwnd, 3)
        }
      }
    	END
    	{
    	}
    }
    

You must be logged in to reply to this topic.