Modules/Core/ARITestPS.psm1
<#
.Synopsis Test Powershell environment .DESCRIPTION This module is use to test and validate the Powershell environment. .Link https://github.com/microsoft/ARI/Core/Test-PS.psm1 .COMPONENT This powershell Module is part of Azure Resource Inventory (ARI) .NOTES Version: 4.0.1 First Release Date: 15th Oct, 2024 Authors: Claudio Merola #> function Test-ARIPS { Param($AzureEnvironment,$TenantID,$SubscriptionID,$DeviceLogin) Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Starting Test-PS function') $CShell = try{Get-CloudShellTip}catch{$null} if ($CShell) { Write-Output 'Azure CloudShell Identified.' $Subscriptions = az account list --output json --only-show-errors | ConvertFrom-Json if ($SubscriptionID) { if($SubscriptionID.count -gt 1) { $Subscriptions = $Subscriptions | Where-Object { $_.ID -in $SubscriptionID } } else { $Subscriptions = $Subscriptions | Where-Object { $_.ID -eq $SubscriptionID } } } $tmp = [PSCustomObject]@{ PlatOS = 'Azure CloudShell' Subscriptions = $Subscriptions } return $tmp } else { if ($PSVersionTable.Platform -eq 'Unix') { Write-Output "PowerShell Unix Identified." $Subscriptions = Connect-ARILoginSession -AzureEnvironment $AzureEnvironment -TenantID $TenantID -SubscriptionID $SubscriptionID -DeviceLogin $DeviceLogin $tmp = [PSCustomObject]@{ PlatOS = 'PowerShell Unix' Subscriptions = $Subscriptions } return $tmp } else { Write-Output "PowerShell Desktop Identified." $Subscriptions = Connect-LoginSession -AzureEnvironment $AzureEnvironment -TenantID $TenantID -SubscriptionID $SubscriptionID -DeviceLogin $DeviceLogin $tmp = [PSCustomObject]@{ PlatOS = 'PowerShell Desktop' Subscriptions = $Subscriptions } return $tmp } } } |