Jump to content

Powershell - recording details from invoke-command


Recommended Posts

Posted

Hi there

 

I'm trying to use an invoke command on remote pcs and i want to check the status of services and then record the status to variable and output to a csv file.

 

method looking at was to declare the variable outside the invoke command and then

 

$Obj = New-Object System.Object $Obj 
$obj | Add-Member -type NoteProperty -name "ComputerName" -value $Name
$obj | Add-Member -type NoteProperty -name "Service Status" -value $ser
$Obj | Add-Member -Type NoteProperty -name "Service Startup Mode" -value $keycheck.Start


$Output += $Obj

 

Then $Output | Export-CSV ...

 

but it doesn't seem to capture outside of the remote pc. within the invoke if I call $output within the invoke command the data is showing.

 

Thanks

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...