functions/get-axenvironment.ps1
function Get-D365Environment { [CmdletBinding(DefaultParameterSetName = 'Default')] param ( [string[]] $ComputerName = @($env:computername), [Parameter(Mandatory = $false, ParameterSetName = 'Default', Position = 2 )] [switch] $All = [switch]::Present, [Parameter(Mandatory = $false, ParameterSetName = 'Specific', Position = 2 )] [switch] $Aos, [Parameter(Mandatory = $false, ParameterSetName = 'Specific', Position = 3 )] [switch] $FinancialReporter, [Parameter(Mandatory = $false, ParameterSetName = 'Specific', Position = 4 )] [switch] $DIXF ) if ($PSCmdlet.ParameterSetName -eq "Specific") { $All = ![switch]::Present } if (!$All -and !$Aos -and !$FinancialReporter -and !$DIXF) { Write-PSFMessage -Level Host -Message "You have to use at least one switch when running this cmdlet. Please run the cmdlet again." Stop-PSFFunction -Message "Stopping because of missing parameters" return } $Params = Get-DeepClone $PSBoundParameters if($Params.ContainsKey("ComputerName")){ $Params.Remove("ComputerName") } $Services = Get-ServiceList @Params $Results = foreach ($server in $ComputerName) { Get-Service -ComputerName $server -Name $Services -ErrorAction SilentlyContinue| Select-Object @{Name = "Server"; Expression = {$Server}}, Name, Status, DisplayName } $Results | Select-Object Server, DisplayName, Status, Name } |