tri_94 Posted July 5, 2021 Posted July 5, 2021 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
HPlum78 Posted July 5, 2021 Posted July 5, 2021 $results = invoke-command {your script block here} Then the results will be in the local var. 1
tri_94 Posted July 6, 2021 Author Posted July 6, 2021 Thanks for that it worked and I've managed to get what I need.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now