Hi,
I will create a function which contains a UDTable but the paramenter (in this case $Servername)
isn’t available in the UDTable / Endpoint script block. What am I doing wrong?
function New-FunctionServerInfo {
param($Servername)
New-UdTable -Id "4815" -Title "Server Informationen" -Headers @(" ", " ") -Endpoint {
$BootUpTime = Get-WMIObject -Class Win32_OperatingSystem -ComputerName $Servername
$EnabledAdapters = (Get-wmiObject Win32_networkAdapterConfiguration -ComputerName $Servername | ?{$_.IPEnabled})
$IPAddress = $EnabledAdapters.IPAddress | Where-Object { -not [String]::IsNullOrEmpty($_)}
$IPAddress = [String]::Join(', ', $IPAddress)
@{
'Computer Name' = $Servername
'Betriebssystem' = (Get-WmiObject Win32_OperatingSystem -ComputerName $Servername).Caption
'Gesamt Speicher System (C:)' = (Get-WmiObject Win32_LogicalDisk -ComputerName $Servername -Filter "DeviceID = 'C:'").Size / 1GB | ForEach-Object { "$([Math]::Round($_, 2)) GBs " }
'Freier Speicher System (C:)' = (Get-WmiObject Win32_LogicalDisk -ComputerName $Servername -Filter "DeviceID = 'C:'").FreeSpace / 1GB | ForEach-Object { "$([Math]::Round($_, 2)) GBs " }
'Letzter Start' = $($BootUpTime.ConvertToDateTime($BootUpTime.LastBootupTime))
'IP Adresse' = "$IPAddress"
}.GetEnumerator() | Sort-Object "Name" | Out-UDTableData -Property @("Name", "Value")
}
}
thanks for your help!!