-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-EnvVar.ps1
More file actions
38 lines (31 loc) · 1.05 KB
/
Get-EnvVar.ps1
File metadata and controls
38 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function Get-EnvVar {
Param(
[Parameter(
Mandatory = $false,
ValueFromPipelineByPropertyName = $true,
ValueFromPipeline = $true
)]
[String[]]$ComputerName = $Env:ComputerName
)
$Query = @(
$Env:ComputerName,
$Env:UserDNSDomain,
$Env:LogonServer,
$Env:Path,
$Env:PSModulePath,
$PSEdition,
$PSVersionTable
)
Invoke-Command -ComputerName $ComputerName -ScriptBlock { $Query }
$EnvVars = [Ordered]@{
'Computer Name' = $Query[0]
'Domain' = $Query[1]
'Logon Server (DC)' = $Query[2]
'Path Variable Directories' = $Query[3] -Split ';' -join "`n"
'PowerShell Module Directories' = $Query[4] -Split ';' -join "`n"
'PowerShell Edition' = $Query[5]
'PowerShell Version' = $Query[6].PSVersion.Major
}
$Vars = New-Object -Type PSObject -Property $EnvVars
Write-Output $Vars
} # End function