Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

help to output array

$
0
0

first of all, sorry for my english…

hello all, thanks for all your help in advance, im trying to list speceifc services in specific servers.
this is part of a procedure where i try to check service status before shutdown these 3 servers.-

——————————————————————-
script
——————————————————————-
function Get-ServicesStatus{
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium')]
param(
$array = @(
(“ComputerName”,”ServiceName”),
(“server01″,”service01″),
(“server01″,”service02″),
(“server01″,”service03″),
(“server01″,”service04″),
(“server02″,”service05″),
(“server02″,”service06″),
(“server02″,”service07″),
(“server03″,”service08″)
)
)
Begin{}
Process
{
$out = @() #tried with or without it
for ($i = 1; $i -lt 9; $i++)
{ $out=Get-Service -ComputerName $array[$i][0] -Name $array[$i][1] |Format-Table -Property MachineName,Status,DisplayName -AutoSize
}
Write-Output “————op1″
$out
Write-Output “————op2″
$out[0]
$out[1]
$out[2]
$out[3]
$out[4]
$out[5]
$out[6]
$out[7]
$out[8]
Write-Output “————op3″
foreach ($element in $out) {$element}
}
End{}
}

——————————————————————-
output
——————————————————————-
————op1
MachineName Status DisplayName
———– —— ———–
server03 Running service08

————op2
MachineName Status DisplayName
———– —— ———–
server03 Running service08

————op3
MachineName Status DisplayName
———– —— ———–
server03 Running service08

——————————————————————-
i wish
——————————————————————-
MachineName Status DisplayName
———– —— ———–
server01 status service01
server01 status service02
server01 status service03
server01 status service04
server02 status service05
server02 status service06
server02 status service07
server03 status service08

could be possible???


Viewing all articles
Browse latest Browse all 13067

Trending Articles