I run this command to find execution policy of each computer. I'm looking for output of computer name and their respective execution policy.
**$Results =
Get-ExecutionPolicy | Select-Object @{l='ComputerName';e={$env:computername}}
$Results | out-file -FilePath c:\temp\Process3.csv**
I only see computer name and not the execution policy. What am I missing ?
ps: Invoke-command doesn't in my environment due to some issues WinRM. So that's not an option for me
CodePudding user response:
You're disregarding the output when you use a calculated property to implement only the ComputerName column. You need to also select the value that was output by Get-ExecutionPolicy
:
Get-ExecutionPolicy |
Select-Object @{
Name = 'ComputerName';
Expression = { $env:computername }
}, @{
Name = "Policy";
Expression = { $_ }
}