Я хотел бы спросить вас, как я могу запустить свой сценарий PowerShell для всех компьютеров в AD. Я попытался установить имена всех компьютеров в переменную, а затем запустить скрипт foreach, но не могу определить имя компьютера из переменной в моем скрипте.
Спасибо за вашу помощь
$HostName = @{n="Hostname";e={[System.Net.Dns]::GetHostName()}}
# IP
$IP = @{n="IP";e={gwmi Win32_NetworkAdapterConfiguration -filter 'IPEnabled=True'|select -expandproperty IPAddress|Where {$_ -notmatch ':'}}}
#MAC
$MAC = @{n="MAC";e={get-wmiobject -class "Win32_NetworkAdapterConfiguration" |Where{$_.IpEnabled -Match "True"} |select MACAddress}}
#OS
$OS = @{n="OS";e={(Get-WMIObject win32_operatingsystem).name}}
#UserLogin
$UserProperty = @{n="user";e={(New-Object System.Security.Principal.SecurityIdentifier $_.ReplacementStrings[1]).Translate([System.Security.Principal.NTAccount])}}
#Log ON / Log OFF
$TypeProperty = @{n="Action";e={if($_.EventID -eq 7001) {"Logon"} else {"Logoff"}}}
#TIME
$TimeProeprty = @{n="Time";e={$_.TimeGenerated}}
#SELECT
Get-EventLog System -Source Microsoft-Windows-Winlogon| Where { $_.TimeGenerated -GT (Get-Date).AddDays(-30) } | select $UserProperty,$TypeProperty,$TimeProeprty,$HostName,$IP,$MAC,$OS ```