modules/NetworkController/public/Get-SdnServiceFabricPartition.ps1
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. function Get-SdnServiceFabricPartition { <# .SYNOPSIS Gets information about the partitions of a specified Service Fabric partition or service from Network Controller. .PARAMETER ApplicationName A service fabric application name that exists on the provided ring, such as fabric:/NetworkController. .PARAMETER ServiceName A service fabric service name that is under the provided ApplicationName on the provided ring, such as fabric:/NetworkController/ApiService. .PARAMETER ServiceTypeName A service fabric service TypeName, such as VSwitchService. .PARAMETER NetworkController Specifies the name of the network controller node on which this cmdlet operates. .PARAMETER Credential Specifies a user account that has permission to perform this action. The default is the current user. .EXAMPLE PS> Get-SdnServiceFabricPartition -PartitionId 1a7a780e-dbfe-46d3-92fb-76908a95ce54 .EXAMPLE PS> Get-SdnServiceFabricPartition -NetworkController 'Prefix-NC01' -Credential (Get-Credential) -ServiceTypeName 'ApiService' .EXAMPLE PS> Get-SdnServiceFabricPartition -NetworkController 'Prefix-NC01' -Credential (Get-Credential) -ServiceName 'fabric:/NetworkController/ApiService' #> [CmdletBinding(DefaultParameterSetName = 'NamedService')] param( [Parameter(Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = 'NamedService')] [Parameter(Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = 'NamedServiceTypeName')] [System.String]$ApplicationName = 'fabric:/NetworkController', [Parameter(Mandatory = $true, ValueFromPipeline = $false, ParameterSetName = 'NamedService')] [System.String]$ServiceName, [Parameter(Mandatory = $true, ValueFromPipeline = $false, ParameterSetName = 'NamedServiceTypeName')] [System.String]$ServiceTypeName, [Parameter(Mandatory = $true, ValueFromPipeline = $false, ParameterSetName = 'PartitionID')] [System.Guid]$PartitionId, [Parameter(Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = 'NamedService')] [Parameter(Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = 'NamedServiceTypeName')] [Parameter(Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = 'PartitionID')] [System.String[]]$NetworkController = $global:SdnDiagnostics.EnvironmentInfo.NetworkController, [Parameter(Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = 'NamedService')] [Parameter(Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = 'NamedServiceTypeName')] [Parameter(Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = 'PartitionID')] [System.Management.Automation.PSCredential] [System.Management.Automation.Credential()] $Credential = [System.Management.Automation.PSCredential]::Empty ) try { switch ($PSCmdlet.ParameterSetName) { 'NamedService' { $sb = { Get-ServiceFabricApplication -ApplicationName $using:ApplicationName | Get-ServiceFabricService -ServiceName $using:ServiceName | Get-ServiceFabricPartition } } 'NamedServiceTypeName' { $sb = { Get-ServiceFabricApplication -ApplicationName $using:ApplicationName | Get-ServiceFabricService -ServiceTypeName $using:ServiceTypeName | Get-ServiceFabricPartition } } 'PartitionID' { $sb = { Get-ServiceFabricPartition -PartitionId $using:PartitionId } } default { # no default } } if ($NetworkController) { return (Invoke-SdnServiceFabricCommand -NetworkController $NetworkController -ScriptBlock $sb -Credential $Credential) } else { return (Invoke-SdnServiceFabricCommand -ScriptBlock $sb -Credential $Credential) } } catch { "{0}`n{1}" -f $_.Exception, $_.ScriptStackTrace | Trace-Output -Level:Error } } |