Invoke-WebRequest-uri'https://github.com/microsoft/windows-container-tools/releases/download/v1.1/LogMonitor.exe'-OutFile'c:\Logmonitor.exe'Invoke-WebRequest-uri'https://github.com/prometheus-community/windows_exporter/releases/download/v0.25.1/windows_exporter-0.25.1-amd64.msi'-OutFile'c:\windows_exporter-0.25.1-amd64.msi'msiexec/i'c:\windows_exporter-0.25.1-amd64.msi'ENABLED_COLLECTORS=os,iis# default port 9182Invoke-WebRequest-URI'http://localhost:9182/metrics'-UseBasicParsing
# 导入 Active Directory 模块Import-ModuleActiveDirectory# 获取所有计算机对象$allComputers=Get-ADComputer-Filter*-PropertiesName,LastLogonDate,OperatingSystem# 设置一个时间阈值,例如 90 天$threshold=(Get-Date).AddDays(-90)# 筛选出最近登录的计算机$activeComputers=$allComputers|Where-Object{$_.LastLogonDate-gt$threshold}# 创建一个空数组来存储在线计算机$onlineComputers=@()# 遍历活跃计算机列表,检查是否在线foreach($computerin$activeComputers){if(Test-Connection-ComputerName$computer.Name-Count1-Quiet){$onlineComputers+=$computer}}# 输出结果到 CSV 文件$onlineComputers|Select-ObjectName,OperatingSystem,LastLogonDate|Export-Csv-Path"C:\ActiveComputers.csv"-NoTypeInformationWrite-Host"Active computers list has been exported to C:\ActiveComputers.csv"