Найти компьютеры по шаблону и вывести имя, активность, путь в AD и последний вход
Import-Module ActiveDirectory
$list="20","24","27","33","44","-vip3"
$AdComputerList=Get-ADComputer -Filter {Name -like "HP*"} -Properties LastLogon
$ResultTable=@()
foreach ($l in $list) {
$FindPcName="HP"+$l
foreach ($pc in $AdComputerList) {
if ($pc.Name -eq $FindPcName) {
$ResultTable+=$pc | select Name,Enabled,DistinguishedName,@{name='lastLogon'; expression={[datetime]::fromFileTime($_.lastLogon)}}}
}
}
$ResultTable | ft
Import-Module ActiveDirectory
$list="20","24","27","33","44","-vip3"
$AdComputerList=Get-ADComputer -Filter {Name -like "HP*"} -Properties LastLogon
$ResultTable=@()
foreach ($l in $list) {
$FindPcName="HP"+$l
foreach ($pc in $AdComputerList) {
if ($pc.Name -eq $FindPcName) {
$ResultTable+=$pc | select Name,Enabled,DistinguishedName,@{name='lastLogon'; expression={[datetime]::fromFileTime($_.lastLogon)}}}
}
}
$ResultTable | ft
Комментариев нет:
Отправить комментарий