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.
$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
Please also mark the comments that contributed to the solution of the article
Content-Key: 359491
Url: https://administrator.de/contentid/359491
Printed on: April 27, 2024 at 05:04 o'clock
2 Comments
Latest comment
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 . Schluck Kaffee dann geht's wieder
Gruß @135051