Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

PowerShell Invoke-Command format and export output

$
0
0

I have a list of computers that I am checking if they are online.  If they are online I am storing them in the variable $onlinesystems that I use invoke command to check if a Registry Key is present ($RegKey) and if a File Path exists ($FilePath).

The code that I run displays the output that I want.  However, I would like to format a table and export the results as follows:

Field 1 Title = ComputerName, Field 2 Title = RegKey, Field 3 Title = RegKeyStatus, Field 4 Title = FilePath, Field 5 Title = FileStatus, Field 6 Title = Date

The values for each field are stored in the following variables:

$env:ComputerName

$RegKey

$RegStatus

$FilePath

$FileStatus

$Formatted

How do I format a Table and then export that table to a csv file with the following code:

$regkey = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Visual Basic"

$FilePath = "C:\Windows\Program Files"

$Results = Invoke-Command $OnlineSystems -ScriptBlock {param($RegPath, $FilePath) $RegResults = Test-Path -Path $RegPath; $FileResults = Test-Path -Path $FilePath; $FormattedDate = $(Get-Date -Format G); $env:COMPUTERNAME, $RegPath, $RegResults, $FilePath, $FileResults, $FormattedDate} -ArgumentList $RegPath, $FilePath

$Results


MAV


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>