蘇州規(guī)劃建設(shè)局網(wǎng)站搜索引擎優(yōu)化的報(bào)告
前言企業(yè)微信機(jī)器人
在ARMS告警管理中創(chuàng)建企業(yè)微信機(jī)器人后,您可以在通知策略中指定對(duì)應(yīng)的企業(yè)微信群用于接收告警。當(dāng)通知策略的匹配規(guī)則被觸發(fā)時(shí),系統(tǒng)會(huì)自動(dòng)向您指定的企業(yè)微信群發(fā)送告警通知。企業(yè)微信群收到通知后,您可以在企業(yè)微信群中對(duì)告警進(jìn)行管理。
通過(guò)接口實(shí)現(xiàn)在群里發(fā)送告警或提醒類的消息通知。
?一鍵實(shí)現(xiàn)企業(yè)微信機(jī)器人推送消息
- 實(shí)現(xiàn)獲取系統(tǒng)信息,實(shí)際需要可行參考以下進(jìn)行更改滿足。
- Invoke-RestMethod #將 HTTP 或 HTTPS 請(qǐng)求發(fā)送到 RESTful Web 服務(wù),參考
- Write-Output #將指定的 對(duì)象寫(xiě)入管道。 如果?
Write-Output
?是管道中的最后一個(gè)命令,則對(duì)象將顯示在控制臺(tái)中。參考 - Get-WmiObject 獲取系統(tǒng)的信息,以下獲取部分系統(tǒng)信息參數(shù),所詳細(xì)的可參考
Win32_Processor // CPU 處理器
Win32_PhysicalMemory // 物理內(nèi)存
Win32_Keyboard // 鍵盤(pán)
Win32_PointingDevice // 點(diǎn)輸入設(shè)備,如鼠標(biāo)
Win32_DiskDrive // 硬盤(pán)驅(qū)動(dòng)器
Win32_CDROMDrive // 光盤(pán)驅(qū)動(dòng)器
Win32_BaseBoard // 主板
Win32_BIOS // BIOS 芯片
Win32_ParallelPort // 并口
Win32_SerialPort // 串口
Win32_SoundDevice // 多媒體設(shè)置
Win32_USBController // USB 控制器
Win32_NetworkAdapter // 網(wǎng)絡(luò)適配器
Win32_NetworkAdapterConfiguration // 網(wǎng)絡(luò)適配器設(shè)置
Win32_Printer // 打印機(jī)
Win32_PrinterConfiguration // 打印機(jī)設(shè)置
Win32_PrintJob // 打印機(jī)任務(wù)
Win32_TCPIPPrinterPort // 打印機(jī)端口
Win32_POTSModem // MODEM
Win32_POTSModemToSerialPort // MODEM 端口
Win32_DesktopMonitor // 顯示器
Win32_VideoController // 顯卡細(xì)節(jié)。
Win32_VideoSettings // 顯卡支持的顯示模式。
Win32_TimeZone // 時(shí)區(qū)
Win32_SystemDriver // 驅(qū)動(dòng)程序
Win32_DiskPartition // 磁盤(pán)分區(qū)
Win32_LogicalDisk // 邏輯磁盤(pán)
Win32_LogicalMemoryConfiguration // 邏輯內(nèi)存配置
Win32_PageFile // 系統(tǒng)頁(yè)文件信息
Win32_PageFileSetting // 頁(yè)文件設(shè)置
Win32_BootConfiguration // 系統(tǒng)啟動(dòng)配置
Win32_OperatingSystem // 操作系統(tǒng)信息
Win32_StartupCommand // 系統(tǒng)自動(dòng)啟動(dòng)程序
Win32_Service // 系統(tǒng)安裝的服務(wù)
Win32_Group // 系統(tǒng)管理組
Win32_GroupUser // 系統(tǒng)組帳號(hào)
Win32_UserAccount // 用戶帳號(hào)
Win32_Process // 系統(tǒng)進(jìn)程
Win32_Thread // 系統(tǒng)線程
Win32_Share // 共享
Win32_NetworkClient // 已安裝的網(wǎng)絡(luò)客戶端
Win32_NetworkProtocol // 已安裝的網(wǎng)絡(luò)協(xié)議 ######>
- $webhook 輸入主機(jī)的企業(yè)機(jī)器人地址
- $content = Write-Output ""Win_version: $Win_version_Names" `n #格式注意,`n換行的意思,$Win_version_Names獲取變量的值
- $body 實(shí)現(xiàn)格式如文本模式text,Markdown格式?企業(yè)微信機(jī)器人創(chuàng)建
powershell-install-Windwos-Enterprise-wechat-module.ps1
<# Powershell Install Windwos version
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+ _____ _____ _ _ _ +
+ | __ \ / ____| | | | |+
+ | |__) |____ _____ _ _| (___ | |__ ___| | |+
+ | ___/ _ \ \ /\ / / _ \ '__\___ \| '_ \ / _ \ | |+
+ | | | (_) \ V V / __/ | ____) | | | | __/ | |+
+ |_| \___/ \_/\_/ \___|_| |_____/|_| |_|\___|_|_|+
+ +++++++++++++++++++++++++++++++++++++++++++++++++++# Powershell Install Windwos version
# .\powershell-install-Windwos-Enterprise-wechat-module.ps1Get-WmiObject Manage system hardware and feature information
https://learn.microsoft.com/zh-cn/powershell/module/microsoft.powershell.management/get-wmiobject?view=powershell-5.1
Get-WmiObject -List #Lists the WMI classes
#> #Enterprise wechat robot address
$webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXX_YOU_企業(yè)微信機(jī)器人地址"#Obtain the Windows host system version
$Win_version = Get-WmiObject -Class Win32_OperatingSystem | Select-Object -ExpandProperty Caption
$Win_version_Names = echo $Win_version#Get all IP addresses of the local host
$Win_ip = foreach($ipv4 in (ipconfig) -like '*IPv4*') { ($ipv4 -split ' : ')[-1]}#Get the host name
$Win_hostname = Get-WMIObject Win32_ComputerSystem | Select-Object -ExpandProperty Name#Gets the native memory size in Gb, keeping two decimal places
$mem = "{0:N2}GB" -f (((Get-WmiObject -Class Win32_PhysicalMemory).capacity | Measure-Object -Sum).sum /1gb)#Gets the number of local memory modules
$slot_mem = ((Get-WmiObject -Class Win32_PhysicalMemory).capacity | Measure-Object -Sum).count#Gets the native memory manufacturer
$Manufacturer_mem = (Get-WmiObject -Class Win32_PhysicalMemory).Manufacturer#Get the local free memory, in Gb, keep two decimal places
$freemem_men = "{0:N2}GB" -f ((Get-WmiObject -Class Win32_OperatingSystem).FreePhysicalMemory /1mb)#Gets the current host time
$Win_time = Get-Counter '\Processor(_Total)\% Processor Time' | Select-Object -ExpandProperty Timestamp#Output gets the information, noting that $Win_version_Names gets the value of the variable using Write-Output `n, which means a newline
$content = Write-Output ""Win_version: $Win_version_Names" `n "Mem_siza: $mem" `n "Win_host_ip: $Win_ip" `n "Win_hostname: $Win_hostname" `n "slot_mem: $slot_mem" `n "Manufacturer_mem: $Manufacturer_mem" `n "freemem_men: $freemem_men" `n "Win_time: $Win_time ""$body = "{`"msgtype`":`"text`",`"text`":{`"content`":`"$content`",`"mentioned_list`":[`"jason`"]}
}"Write-Host "The variable value obtained is transferred to the enterprise wechat robot" -ForegroundColor Green
Invoke-RestMethod $webhook -ContentType "application/json;charset=utf-8" -Method Post -Body $body
執(zhí)行
.\powershell-install-Windwos-Enterprise-wechat-module.ps1