Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Старожил


Сообщения: 211
Благодарности: 2

Профиль | Отправить PM | Цитировать


нашел в дискуссии инсайдеров скрипты для ps
первый
Function Get-MonitorInfo
{
[CmdletBinding()]
Param
(
[Parameter(
Position=0,
ValueFromPipeLine=$true,
ValueFromPipeLineByPropertyName=$true)]
[string]$name = '.'
)

Process
{

$ActiveMonitors = Get-WmiObject -Namespace root\wmi -Class wmiMonitorID -ComputerName $name
$monitorInfo = @()

foreach ($monitor in $ActiveMonitors)
{
$mon = New-Object PSObject
$manufacturer = $null
$product = $null
$serial = $null
$name = $null
$week = $null
$year = $null

$monitor.ManufacturerName | foreach {$manufacturer += [char]$_}
$monitor.ProductCodeID | foreach {$product += [char]$_}
$monitor.SerialNumberID | foreach {$serial += [char]$_}
$monitor.UserFriendlyName | foreach {$name += [char]$_}

$mon | Add-Member NoteProperty Manufacturer $manufacturer
$mon | Add-Member NoteProperty ProductCode $product
$mon | Add-Member NoteProperty SerialNumber $serial
$mon | Add-Member NoteProperty Name $name
$mon | Add-Member NoteProperty Week $monitor.WeekOfManufacture
$mon | Add-Member NoteProperty Year $monitor.YearOfManufacture

$monitorInfo += $mon
}
$monitorInfo |
}
}

второй
Function Get-MonitorInfo
{
[CmdletBinding()]
Param
(
[Parameter(
Position=0,
ValueFromPipeLine=$true,
ValueFromPipeLineByPropertyName=$true)]
[alias("CN","MachineName","Name","Computer")]
[string[]]$ComputerName = $ENV:ComputerName
)

Begin {
$pipelineInput = -not $PSBoundParameters.ContainsKey('ComputerName')
}

Process
{
Function DoWork([string]$ComputerName) {
$ActiveMonitors = Get-WmiObject -Namespace root\wmi -Class wmiMonitorID -ComputerName $ComputerName
$monitorInfo = @()

foreach ($monitor in $ActiveMonitors)
{
$mon = $null

$mon = New-Object PSObject -Property @{
ManufacturerName=($monitor.ManufacturerName | % {[char]$_}) -join ''
ProductCodeID=($monitor.ProductCodeID | % {[char]$_}) -join ''
SerialNumberID=($monitor.SerialNumberID | % {[char]$_}) -join ''
UserFriendlyName=($monitor.UserFriendlyName | % {[char]$_}) -join ''
ComputerName=$ComputerName
WeekOfManufacture=$monitor.WeekOfManufacture
YearOfManufacture=$monitor.YearOfManufacture}

$monitorInfo += $mon
}
Write-Output $monitorInfo
}

if ($pipelineInput) {
DoWork($ComputerName)
} else {
foreach ($item in $ComputerName) {
DoWork($item)
}
}
}
}

Оба обрабатывают без ошибок, но и результат не выводят. просто запустил и ничего не происходит.

Отправлено: 13:50, 17-04-2020 | #6