Powershell Get-Services im Invoke Command
Aloa,
Nicht mehr lang.
So richtig mag das noch nicht.
Der "-Name" ist das Property und das Ergebnis soll in das Value vom Property, bisher bekomm ich das nicht gefüllt.
VG
Nicht mehr lang.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$HtServices = @{
RS= $null
RT= $null
RR= $null
}
$CustomObjectServices = [pscustomobject]$HtServices
function get-data{
[CmdletBinding()]
[OutputType([System.Object])]
param(
[Parameter(Position=0, Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[System.String]
$ServerName,
[Parameter(Position=1, Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[System.Object]
$ObjectListServices
)
$result = Invoke-Command -ComputerName $Server -ScriptBlock {param($ObjectListServices)
$ObjectListServices | %{
$Ret = Get-Service -Name $_.Name -ErrorAction SilentlyContinue
if ( ! $Ret ) { $_.Value = "NA" } else { $_.Value = $Ret.Status }
}
Return $ObjectListServices
} -ArgumentList $ObjectListServices
return $result
}
get-data -ServerName $Server -ObjectListServices $CustomObjectServices
So richtig mag das noch nicht.
Der "-Name" ist das Property und das Ergebnis soll in das Value vom Property, bisher bekomm ich das nicht gefüllt.
VG
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 359491
Url: https://administrator.de/forum/powershell-get-services-im-invoke-command-359491.html
Ausgedruckt am: 25.04.2025 um 22:04 Uhr
2 Kommentare
Neuester Kommentar

Du hast aus deiner Hashtable ein CustomObject gemacht und da gibt es kein $_.Name oder $_.Value mehr, nur noch deine Eigenschaften RS,RT, und RR
Schon am bisl spät was
. Schluck Kaffee dann geht's wieder 
Gruß @135051
Schon am bisl spät was
Gruß @135051