update scripts
This commit is contained in:
parent
566cebdc96
commit
a5a3637b5c
14 changed files with 6289 additions and 5805 deletions
|
|
@ -10,4 +10,5 @@ function ConvertFrom-Html {
|
||||||
}
|
}
|
||||||
|
|
||||||
# $apache_status = "http://192.168.3.102/server-status"
|
# $apache_status = "http://192.168.3.102/server-status"
|
||||||
# $apache_status | ConvertFrom-Html
|
# $apache_status | ConvertFrom-Html
|
||||||
|
# irm http://192.168.3.102/server-status?auto
|
||||||
7
Scripts/Get-AltTab.ps1
Normal file
7
Scripts/Get-AltTab.ps1
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
function Get-AltTab {
|
||||||
|
$wshell = New-Object -ComObject wscript.shell
|
||||||
|
$wshell.SendKeys("%{Tab}")
|
||||||
|
sleep 120
|
||||||
|
Get-AltTab
|
||||||
|
}
|
||||||
|
Get-AltTab
|
||||||
15
Scripts/Get-NetUtilMon.ps1
Normal file
15
Scripts/Get-NetUtilMon.ps1
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
$WARNING = 25
|
||||||
|
$CRITICAL = 50
|
||||||
|
$Interface = $(Get-Counter).CounterSamples.Path[0]
|
||||||
|
$TransferRate = ((Get-Counter $Interface).countersamples | select -ExpandProperty CookedValue)*8
|
||||||
|
$NetworkUtilisation = [math]::round($TransferRate/1000000000*100,2)
|
||||||
|
if ($NetworkUtilisation -gt $CRITICAL){
|
||||||
|
Write-Output "CRITICAL: $($NetworkUtilisation) % Network utilisation, $($TransferRate.ToString('N0')) b/s"
|
||||||
|
# exit 2
|
||||||
|
}
|
||||||
|
if ($NetworkUtilisation -gt $WARNING){
|
||||||
|
Write-Output "WARNING: $($NetworkUtilisation) % Network utilisation, $($TransferRate.ToString('N0')) b/s"
|
||||||
|
# exit 1
|
||||||
|
}
|
||||||
|
Write-Output "OK: $($NetworkUtilisation) % Network utilisation, $($TransferRate.ToString('N0')) b/s"
|
||||||
|
# exit 0
|
||||||
170
Scripts/Get-ServiceManagment-PSMenu.ps1
Normal file
170
Scripts/Get-ServiceManagment-PSMenu.ps1
Normal file
|
|
@ -0,0 +1,170 @@
|
||||||
|
### Var
|
||||||
|
$ServiceName = "*sshd*" # formate wildcard (*)
|
||||||
|
$Server = "localhost" # default
|
||||||
|
|
||||||
|
$server_list = @(
|
||||||
|
"192.168.3.99",
|
||||||
|
"192.168.3.100"
|
||||||
|
)
|
||||||
|
|
||||||
|
### Console Size
|
||||||
|
# $size = $Host.UI.RawUI.WindowSize
|
||||||
|
# $size.Width = 30
|
||||||
|
# $size.Height = 25
|
||||||
|
# $Host.UI.RawUI.WindowSize = $size
|
||||||
|
# $title = $Host.UI.RawUI.WindowTitle
|
||||||
|
# $title = "Menu Service Start-Stop"
|
||||||
|
# $Host.UI.RawUI.WindowTitle = $title
|
||||||
|
|
||||||
|
### Module ps-menu
|
||||||
|
### Source: https://github.com/chrisseroka/ps-menu
|
||||||
|
function DrawMenu {
|
||||||
|
param ($menuItems, $menuPosition, $Multiselect, $selection)
|
||||||
|
$l = $menuItems.length
|
||||||
|
for ($i = 0; $i -le $l;$i++) {
|
||||||
|
if ($menuItems[$i] -ne $null){
|
||||||
|
$item = $menuItems[$i]
|
||||||
|
if ($Multiselect)
|
||||||
|
{
|
||||||
|
if ($selection -contains $i){
|
||||||
|
$item = '[x] ' + $item
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$item = '[ ] ' + $item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($i -eq $menuPosition) {
|
||||||
|
Write-Host "> $($item)" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host " $($item)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Toggle-Selection {
|
||||||
|
param ($pos, [array]$selection)
|
||||||
|
if ($selection -contains $pos){
|
||||||
|
$result = $selection | where {$_ -ne $pos}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$selection += $pos
|
||||||
|
$result = $selection
|
||||||
|
}
|
||||||
|
$result
|
||||||
|
}
|
||||||
|
|
||||||
|
function Menu {
|
||||||
|
param ([array]$menuItems, [switch]$ReturnIndex=$false, [switch]$Multiselect)
|
||||||
|
$vkeycode = 0
|
||||||
|
$pos = 0
|
||||||
|
$selection = @()
|
||||||
|
if ($menuItems.Length -gt 0)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
[console]::CursorVisible=$false #prevents cursor flickering
|
||||||
|
DrawMenu $menuItems $pos $Multiselect $selection
|
||||||
|
While ($vkeycode -ne 13 -and $vkeycode -ne 27) {
|
||||||
|
$press = $host.ui.rawui.readkey("NoEcho,IncludeKeyDown")
|
||||||
|
$vkeycode = $press.virtualkeycode
|
||||||
|
If ($vkeycode -eq 38 -or $press.Character -eq 'k') {$pos--}
|
||||||
|
If ($vkeycode -eq 40 -or $press.Character -eq 'j') {$pos++}
|
||||||
|
If ($vkeycode -eq 36) { $pos = 0 }
|
||||||
|
If ($vkeycode -eq 35) { $pos = $menuItems.length - 1 }
|
||||||
|
If ($press.Character -eq ' ') { $selection = Toggle-Selection $pos $selection }
|
||||||
|
if ($pos -lt 0) {$pos = 0}
|
||||||
|
If ($vkeycode -eq 27) {$pos = $null }
|
||||||
|
if ($pos -ge $menuItems.length) {$pos = $menuItems.length -1}
|
||||||
|
if ($vkeycode -ne 27)
|
||||||
|
{
|
||||||
|
$startPos = [System.Console]::CursorTop - $menuItems.Length
|
||||||
|
[System.Console]::SetCursorPosition(0, $startPos)
|
||||||
|
DrawMenu $menuItems $pos $Multiselect $selection
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
[System.Console]::SetCursorPosition(0, $startPos + $menuItems.Length)
|
||||||
|
[console]::CursorVisible = $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$pos = $null
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ReturnIndex -eq $false -and $pos -ne $null)
|
||||||
|
{
|
||||||
|
if ($Multiselect){
|
||||||
|
return $menuItems[$selection]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return $menuItems[$pos]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($Multiselect){
|
||||||
|
return $selection
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return $pos
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
### Get-Menu
|
||||||
|
function Get-Menu ($server) {
|
||||||
|
Write-Host
|
||||||
|
$sn = $ServiceName -replace "\*"
|
||||||
|
$menu = menu @("Get Services $sn", "Start Services $sn", "Stop Services $sn", "Restart Services $sn", "Select Server") -ReturnIndex
|
||||||
|
if ($menu -eq 0) {
|
||||||
|
Get-ServiceColor
|
||||||
|
Get-Menu -server $server
|
||||||
|
}
|
||||||
|
elseif ($menu -eq 1) {
|
||||||
|
Get-Service $ServiceName -ComputerName $server | Start-Service
|
||||||
|
Get-ServiceColor
|
||||||
|
Get-Menu -server $server
|
||||||
|
}
|
||||||
|
elseif ($menu -eq 2) {
|
||||||
|
Get-Service $ServiceName -ComputerName $server | Stop-Service -Force
|
||||||
|
Get-ServiceColor
|
||||||
|
Get-Menu -server $server
|
||||||
|
}
|
||||||
|
elseif ($menu -eq 3) {
|
||||||
|
Get-Service $ServiceName -ComputerName $server | Restart-Service -Force
|
||||||
|
Get-ServiceColor
|
||||||
|
Get-Menu -server $server
|
||||||
|
}
|
||||||
|
elseif ($menu -eq 4) {
|
||||||
|
Write-Host
|
||||||
|
$select_servers = menu $server_list
|
||||||
|
$server = $select_servers
|
||||||
|
clear
|
||||||
|
Get-Menu -server $server
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
### Get-Service
|
||||||
|
function Get-ServiceColor {
|
||||||
|
clear
|
||||||
|
$services = Get-Service $ServiceName -ComputerName $server
|
||||||
|
Write-Host
|
||||||
|
foreach ($s in $services) {
|
||||||
|
$name = $s.Name
|
||||||
|
$stat = $s.Status
|
||||||
|
if ($stat -eq "Running") {
|
||||||
|
Write-Host " $server " -NoNewline
|
||||||
|
Write-Host "$stat " -ForegroundColor Green -NoNewline
|
||||||
|
Write-Host "$Name"
|
||||||
|
}
|
||||||
|
elseif ($stat -eq "Stopped") {
|
||||||
|
Write-Host "$stat " -ForegroundColor Red -NoNewline
|
||||||
|
Write-Host "$Name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host
|
||||||
|
}
|
||||||
|
|
||||||
|
clear
|
||||||
|
Get-Menu -server $server
|
||||||
22
Scripts/Send-Message-PIV.ps1
Normal file
22
Scripts/Send-Message-PIV.ps1
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
$Username = "support@domain.local";
|
||||||
|
$Password = "password";
|
||||||
|
$SendTo = "admin@domain.ru";
|
||||||
|
$MailServer = "mail.domain.ru";
|
||||||
|
$HostName = $args[0];
|
||||||
|
$IPAddress = $args[1];
|
||||||
|
$PingStatus = $args[2];
|
||||||
|
$FailedOn = $args[3];
|
||||||
|
|
||||||
|
$message = new-object Net.Mail.MailMessage;
|
||||||
|
$message.From = $Username;
|
||||||
|
$message.To.Add($SendTo);
|
||||||
|
$message.Subject = "Ping Info View";
|
||||||
|
$message.Body = "Failed ping: `r`nHost Name: $HostName`r`nIP Address: $IPAddress`r`nPing Status: $PingStatus`r`nPing Time: $FailedOn";
|
||||||
|
|
||||||
|
$smtp = new-object Net.Mail.SmtpClient($MailServer, "25");
|
||||||
|
$smtp.EnableSSL = $true;
|
||||||
|
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
|
||||||
|
$smtp.send($message);
|
||||||
|
|
||||||
|
# F9 - Advanced Options - Execute the following command on failed ping:
|
||||||
|
# Powershell.exe -executionpolicy remotesigned -File С:\Send-Message-PIV.ps1 "%HostName%" "%IPAddress%" "%LastPingStatus%" "%LastFailedOn%"
|
||||||
24
Scripts/Send-SMTP.psm1
Normal file
24
Scripts/Send-SMTP.psm1
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
function Send-SMTP {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $True)]$mess
|
||||||
|
)
|
||||||
|
$srv_smtp = "smtp.yandex.ru"
|
||||||
|
$port = "587"
|
||||||
|
$from = "login1@yandex.ru"
|
||||||
|
$to = "login2@yandex.ru"
|
||||||
|
$user = "login1"
|
||||||
|
$pass = "password"
|
||||||
|
$subject = "Service status on Host: $hostname"
|
||||||
|
$Message = New-Object System.Net.Mail.MailMessage
|
||||||
|
$Message.From = $from
|
||||||
|
$Message.To.Add($to)
|
||||||
|
$Message.Subject = $subject
|
||||||
|
$Message.IsBodyHTML = $true
|
||||||
|
$Message.Body = "<h1> $mess </h1>"
|
||||||
|
$smtp = New-Object Net.Mail.SmtpClient($srv_smtp, $port)
|
||||||
|
$smtp.EnableSSL = $true
|
||||||
|
$smtp.Credentials = New-Object System.Net.NetworkCredential($user, $pass);
|
||||||
|
$smtp.Send($Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send-SMTP $(Get-Service)
|
||||||
16
Scripts/Send-Telegram.ps1
Normal file
16
Scripts/Send-Telegram.ps1
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
function Send-Telegram {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $True)]$Text
|
||||||
|
)$token_bot = "5517149522:AAFop4_darMpTT7VgLpY2hjkDkkV1dzmGNM"
|
||||||
|
$id_chat = "-609779646"
|
||||||
|
$payload = @{
|
||||||
|
"chat_id" = $id_chat
|
||||||
|
"text" = $Text
|
||||||
|
"parse_mode" = "html"
|
||||||
|
}
|
||||||
|
Invoke-RestMethod -Uri ("https://api.telegram.org/bot{0}/sendMessage" -f $token_bot) -Method Post -ContentType "application/json;charset=utf-8" -Body (
|
||||||
|
ConvertTo-Json -Compress -InputObject $payload
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Send-Telegram -Text Test
|
||||||
19
Scripts/Start-PingJob.psm1
Normal file
19
Scripts/Start-PingJob.psm1
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
function Start-PingJob ($Network) {
|
||||||
|
$RNetwork = $Network -replace "\.\d{1,3}$","."
|
||||||
|
foreach ($4 in 1..254) {
|
||||||
|
$ip = $RNetwork+$4
|
||||||
|
# создаем задания, забираем 3-ю строку вывода и добавляем к выводу ip-адрес:
|
||||||
|
(Start-Job {"$using:ip : "+(ping -n 1 -w 50 $using:ip)[2]}) | Out-Null
|
||||||
|
}
|
||||||
|
while ($True){
|
||||||
|
$status_job = (Get-Job).State[-1] # забираем статус последнего задания
|
||||||
|
if ($status_job -like "Completed"){ # проверяем на выполнение (задания выполняются по очереди сверху вниз)
|
||||||
|
$ping_out = Get-Job | Receive-Job # если выполнен, забираем вывод всех заданий
|
||||||
|
Get-Job | Remove-Job -Force # удаляем задания
|
||||||
|
$ping_out
|
||||||
|
break # завершаем цикл
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start-PingJob -Network 192.168.3.0
|
||||||
|
# (Measure-Command {Start-PingJob -Network 192.168.3.0}).TotalSeconds # 60 Seconds
|
||||||
13
Scripts/Start-PingRSJob.psm1
Normal file
13
Scripts/Start-PingRSJob.psm1
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
function Start-PingRSJob ($Network) {
|
||||||
|
$RNetwork = $Network -replace "\.\d{1,3}$","."
|
||||||
|
foreach ($4 in 1..254) {
|
||||||
|
$ip = $RNetwork+$4
|
||||||
|
(Start-RSJob {"$using:ip : "+(ping -n 1 -w 50 $using:ip)[2]}) | Out-Null
|
||||||
|
}
|
||||||
|
$ping_out = Get-RSJob | Receive-RSJob
|
||||||
|
$ping_out
|
||||||
|
Get-RSJob | Remove-RSJob
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start-PingRSJob -Network 192.168.3.0
|
||||||
|
# (Measure-Command {Start-PingRSJob -Network 192.168.3.0}).TotalSeconds # 10 Seconds
|
||||||
19
Scripts/Start-PingThread.psm1
Normal file
19
Scripts/Start-PingThread.psm1
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
function Start-PingThread ($Network) {
|
||||||
|
$RNetwork = $Network -replace "\.\d{1,3}$","."
|
||||||
|
foreach ($4 in 1..254) {
|
||||||
|
$ip = $RNetwork+$4
|
||||||
|
# создаем задания, забираем 3-ю строку вывода и добавляем к выводу ip-адрес:
|
||||||
|
(Start-ThreadJob {"$using:ip : "+(ping -n 1 -w 50 $using:ip)[2]}) | Out-Null
|
||||||
|
}
|
||||||
|
while ($True){
|
||||||
|
$status_job = (Get-Job).State[-1] # забираем статус последнего задания
|
||||||
|
if ($status_job -like "Completed"){ # проверяем на выполнение (задания выполняются по очереди сверху вниз)
|
||||||
|
$ping_out = Get-Job | Receive-Job # если выполнен, забираем вывод всех заданий
|
||||||
|
Get-Job | Remove-Job -Force # удаляем задания
|
||||||
|
$ping_out
|
||||||
|
break # завершаем цикл
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start-PingThread -Network 192.168.3.0
|
||||||
|
# (Measure-Command {Start-PingThread -Network 192.168.3.0}).TotalSeconds # 24 Seconds
|
||||||
18
Scripts/Test-PingNetwork.psm1
Normal file
18
Scripts/Test-PingNetwork.psm1
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
function Test-PingNetwork {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory,ValueFromPipeline)][string[]]$Network,
|
||||||
|
[ValidateRange(100,10000)][int]$Timeout = 100
|
||||||
|
)
|
||||||
|
$ping = New-Object System.Net.NetworkInformation.Ping
|
||||||
|
$Network = $Network -replace "0$"
|
||||||
|
$net = @()
|
||||||
|
foreach ($r in @(1..254)) {
|
||||||
|
$net += "$network$r"
|
||||||
|
}
|
||||||
|
foreach ($n in $net) {
|
||||||
|
$ping.Send($n, $timeout) | select @{Name="Address"; Expression={$n -replace ".+\."}}, Status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test-PingNetwork -Network 192.168.3.0
|
||||||
|
# Test-PingNetwork -Network 192.168.3.0 -Timeout 1000
|
||||||
BIN
WinForms/NotifyIcon-ContextMenu.ps1
Normal file
BIN
WinForms/NotifyIcon-ContextMenu.ps1
Normal file
Binary file not shown.
106
posh.txt
106
posh.txt
|
|
@ -21,7 +21,10 @@ PowerShell Commands
|
||||||
# DHCP
|
# DHCP
|
||||||
# DFS
|
# DFS
|
||||||
# Package
|
# Package
|
||||||
|
# PS2EXE
|
||||||
|
# NSSM
|
||||||
# Jobs
|
# Jobs
|
||||||
|
# SMTP
|
||||||
# Hyper-V
|
# Hyper-V
|
||||||
# VMWare/PowerCLI
|
# VMWare/PowerCLI
|
||||||
# Exchange/EMShell
|
# Exchange/EMShell
|
||||||
|
|
@ -83,6 +86,8 @@ Invoke-Expression # iex принимает текст в виде команды
|
||||||
$PSVersionTable # версия PowerShell
|
$PSVersionTable # версия PowerShell
|
||||||
Set-ExecutionPolicy Unrestricted
|
Set-ExecutionPolicy Unrestricted
|
||||||
Get-ExecutionPolicy
|
Get-ExecutionPolicy
|
||||||
|
$Metadata = New-Object System.Management.Automation.CommandMetaData (Get-Command Get-Service) # получить информацию о командлете
|
||||||
|
[System.Management.Automation.ProxyCommand]::Create($Metadata) # исходный код функции
|
||||||
|
|
||||||
# Object
|
# Object
|
||||||
|
|
||||||
|
|
@ -1019,8 +1024,24 @@ Test-Connection -Count 1 $srv1, $srv2 # отправить icmp-пакет дв
|
||||||
Test-Connection $srv -ErrorAction SilentlyContinue # не выводить ошибок, если хост не отвечает
|
Test-Connection $srv -ErrorAction SilentlyContinue # не выводить ошибок, если хост не отвечает
|
||||||
Test-Connection -Source $srv1 -ComputerName $srv2 # пинг с удаленного компьютера
|
Test-Connection -Source $srv1 -ComputerName $srv2 # пинг с удаленного компьютера
|
||||||
|
|
||||||
$ping = New-Object System.Net.Networkinformation.Ping
|
function Test-PingNetwork {
|
||||||
1..254 | % {$ping.send("192.168.3.$_") | select address, status}
|
param (
|
||||||
|
[Parameter(Mandatory,ValueFromPipeline)][string[]]$Network,
|
||||||
|
[ValidateRange(100,10000)][int]$Timeout = 100
|
||||||
|
)
|
||||||
|
$ping = New-Object System.Net.NetworkInformation.Ping
|
||||||
|
$Network = $Network -replace "0$"
|
||||||
|
$net = @()
|
||||||
|
foreach ($r in @(1..254)) {
|
||||||
|
$net += "$network$r"
|
||||||
|
}
|
||||||
|
foreach ($n in $net) {
|
||||||
|
$ping.Send($n, $timeout) | select @{Name="Address"; Expression={$n -replace ".+\."}}, Status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Test-PingNetwork -Network 192.168.3.0
|
||||||
|
Test-PingNetwork -Network 192.168.3.0 -Timeout 1000
|
||||||
|
|
||||||
### port
|
### port
|
||||||
tnc $srv -p 5985
|
tnc $srv -p 5985
|
||||||
|
|
@ -1083,6 +1104,7 @@ hostname.exe
|
||||||
[System.Net.Dns]::GetHostName()
|
[System.Net.Dns]::GetHostName()
|
||||||
|
|
||||||
### arp
|
### arp
|
||||||
|
ipconfig /all | Select-String "физ" # grep
|
||||||
Get-NetNeighbor -AddressFamily IPv4
|
Get-NetNeighbor -AddressFamily IPv4
|
||||||
|
|
||||||
function Get-ARP {
|
function Get-ARP {
|
||||||
|
|
@ -1684,7 +1706,8 @@ Get-Command *Veeam*
|
||||||
Import-Module -Name VeeamLogParser # загрузить модуль
|
Import-Module -Name VeeamLogParser # загрузить модуль
|
||||||
Get-Module VeeamLogParser | select -ExpandProperty ExportedCommands # отобразить список функций
|
Get-Module VeeamLogParser | select -ExpandProperty ExportedCommands # отобразить список функций
|
||||||
|
|
||||||
### PS2EXE
|
# PS2EXE
|
||||||
|
|
||||||
Install-Module ps2exe -Repository PSGallery
|
Install-Module ps2exe -Repository PSGallery
|
||||||
Get-Module -ListAvailable # список всех модулей
|
Get-Module -ListAvailable # список всех модулей
|
||||||
-noConsole # использовать GUI, без окна консоли powershell
|
-noConsole # использовать GUI, без окна консоли powershell
|
||||||
|
|
@ -1694,7 +1717,8 @@ Get-Module -ListAvailable # список всех модулей
|
||||||
-credentialGUI # вывод диалогового окна для ввода учетных данных
|
-credentialGUI # вывод диалогового окна для ввода учетных данных
|
||||||
Invoke-ps2exe -inputFile "$home\Desktop\WinEvent-Viewer-1.1.ps1" -outputFile "$home\Desktop\WEV-1.1.exe" -iconFile "$home\Desktop\log_48px.ico" -title "WinEvent-Viewer" -noConsole -noOutput -noError
|
Invoke-ps2exe -inputFile "$home\Desktop\WinEvent-Viewer-1.1.ps1" -outputFile "$home\Desktop\WEV-1.1.exe" -iconFile "$home\Desktop\log_48px.ico" -title "WinEvent-Viewer" -noConsole -noOutput -noError
|
||||||
|
|
||||||
### NSSM
|
# NSSM
|
||||||
|
|
||||||
$powershell_Path = (Get-Command powershell).Source
|
$powershell_Path = (Get-Command powershell).Source
|
||||||
$NSSM_Path = (Get-Command "C:\WinPerf-Agent\NSSM-2.24.exe").Source
|
$NSSM_Path = (Get-Command "C:\WinPerf-Agent\NSSM-2.24.exe").Source
|
||||||
$Script_Path = "C:\WinPerf-Agent\WinPerf-Agent-1.1.ps1"
|
$Script_Path = "C:\WinPerf-Agent\WinPerf-Agent-1.1.ps1"
|
||||||
|
|
@ -1709,6 +1733,7 @@ $Service_Name | Stop-Service # остановить
|
||||||
& $NSSM_Path remove $Service_Name # удалить
|
& $NSSM_Path remove $Service_Name # удалить
|
||||||
|
|
||||||
# Jobs
|
# Jobs
|
||||||
|
|
||||||
Get-Job # получение списка задач
|
Get-Job # получение списка задач
|
||||||
Start-Job # запуск процесса
|
Start-Job # запуск процесса
|
||||||
Stop-Job # остановка процесса
|
Stop-Job # остановка процесса
|
||||||
|
|
@ -1718,7 +1743,7 @@ Wait-Job # ожидание вывода команды
|
||||||
Receive-Job # получение результатов выполненного процесса
|
Receive-Job # получение результатов выполненного процесса
|
||||||
Remove-Job # удалить задачу
|
Remove-Job # удалить задачу
|
||||||
|
|
||||||
function Start-MTPing ($Network){
|
function Start-PingJob ($Network) {
|
||||||
$RNetwork = $Network -replace "\.\d{1,3}$","."
|
$RNetwork = $Network -replace "\.\d{1,3}$","."
|
||||||
foreach ($4 in 1..254) {
|
foreach ($4 in 1..254) {
|
||||||
$ip = $RNetwork+$4
|
$ip = $RNetwork+$4
|
||||||
|
|
@ -1735,10 +1760,11 @@ break # завершаем цикл
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
Start-MTPing -Network 192.168.3.0
|
Start-PingJob -Network 192.168.3.0
|
||||||
(Measure-Command {Start-MTPing -Network 192.168.3.0}).TotalSeconds # 60 Seconds
|
(Measure-Command {Start-PingJob -Network 192.168.3.0}).TotalSeconds # 60 Seconds
|
||||||
|
|
||||||
### ThreadJob
|
### ThreadJob
|
||||||
|
|
||||||
Install-Module -Name ThreadJob
|
Install-Module -Name ThreadJob
|
||||||
Get-Module ThreadJob -list
|
Get-Module ThreadJob -list
|
||||||
Start-ThreadJob {ping ya.ru} | Out-Null # создать фоновую задачу
|
Start-ThreadJob {ping ya.ru} | Out-Null # создать фоновую задачу
|
||||||
|
|
@ -1746,7 +1772,7 @@ Get-Job | Receive-Job -Keep # отобразить и не удалять выв
|
||||||
(Get-Job).HasMoreData # если False, то вывод команы удален
|
(Get-Job).HasMoreData # если False, то вывод команы удален
|
||||||
(Get-Job)[-1].Output # отобразить вывод последней задачи
|
(Get-Job)[-1].Output # отобразить вывод последней задачи
|
||||||
|
|
||||||
function Start-MTPing ($Network){
|
function Start-PingThread ($Network) {
|
||||||
$RNetwork = $Network -replace "\.\d{1,3}$","."
|
$RNetwork = $Network -replace "\.\d{1,3}$","."
|
||||||
foreach ($4 in 1..254) {
|
foreach ($4 in 1..254) {
|
||||||
$ip = $RNetwork+$4
|
$ip = $RNetwork+$4
|
||||||
|
|
@ -1763,12 +1789,12 @@ break # завершаем цикл
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
Start-MTPing -Network 192.168.3.0
|
Start-PingThread -Network 192.168.3.0
|
||||||
(Measure-Command {Start-MTPing -Network 192.168.3.0}).TotalSeconds # 24 Seconds
|
(Measure-Command {Start-PingThread -Network 192.168.3.0}).TotalSeconds # 24 Seconds
|
||||||
|
|
||||||
### PoshRSJob
|
### PoshRSJob
|
||||||
|
|
||||||
function Start-MTPing ($Network){
|
function Start-PingRSJob ($Network) {
|
||||||
$RNetwork = $Network -replace "\.\d{1,3}$","."
|
$RNetwork = $Network -replace "\.\d{1,3}$","."
|
||||||
foreach ($4 in 1..254) {
|
foreach ($4 in 1..254) {
|
||||||
$ip = $RNetwork+$4
|
$ip = $RNetwork+$4
|
||||||
|
|
@ -1779,8 +1805,35 @@ $ping_out
|
||||||
Get-RSJob | Remove-RSJob
|
Get-RSJob | Remove-RSJob
|
||||||
}
|
}
|
||||||
|
|
||||||
Start-MTPing -Network 192.168.3.0
|
Start-PingRSJob -Network 192.168.3.0
|
||||||
(Measure-Command {Start-MTPing -Network 192.168.3.0}).TotalSeconds # 10 Seconds
|
(Measure-Command {Start-PingRSJob -Network 192.168.3.0}).TotalSeconds # 10 Seconds
|
||||||
|
|
||||||
|
# SMTP
|
||||||
|
|
||||||
|
function Send-SMTP {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $True)]$mess
|
||||||
|
)
|
||||||
|
$srv_smtp = "smtp.yandex.ru"
|
||||||
|
$port = "587"
|
||||||
|
$from = "login1@yandex.ru"
|
||||||
|
$to = "login2@yandex.ru"
|
||||||
|
$user = "login1"
|
||||||
|
$pass = "password"
|
||||||
|
$subject = "Service status on Host: $hostname"
|
||||||
|
$Message = New-Object System.Net.Mail.MailMessage
|
||||||
|
$Message.From = $from
|
||||||
|
$Message.To.Add($to)
|
||||||
|
$Message.Subject = $subject
|
||||||
|
$Message.IsBodyHTML = $true
|
||||||
|
$Message.Body = "<h1> $mess </h1>"
|
||||||
|
$smtp = New-Object Net.Mail.SmtpClient($srv_smtp, $port)
|
||||||
|
$smtp.EnableSSL = $true
|
||||||
|
$smtp.Credentials = New-Object System.Net.NetworkCredential($user, $pass);
|
||||||
|
$smtp.Send($Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
Send-SMTP $(Get-Service)
|
||||||
|
|
||||||
# Hyper-V
|
# Hyper-V
|
||||||
|
|
||||||
|
|
@ -2358,6 +2411,25 @@ $vjob = $vjob.Content | ConvertFrom-Json
|
||||||
$vjob = Invoke-RestMethod "https://veeam-11:9419/api/v1/jobs" -Method GET -Headers $Header -SkipCertificateCheck
|
$vjob = Invoke-RestMethod "https://veeam-11:9419/api/v1/jobs" -Method GET -Headers $Header -SkipCertificateCheck
|
||||||
$vjob.data.virtualMachines.includes.inventoryObject
|
$vjob.data.virtualMachines.includes.inventoryObject
|
||||||
|
|
||||||
|
### Telegram
|
||||||
|
|
||||||
|
function Send-Telegram {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $True)]$Text
|
||||||
|
)$token_bot = "5517149522:AAFop4_darMpTT7VgLpY2hjkDkkV1dzmGNM"
|
||||||
|
$id_chat = "-609779646"
|
||||||
|
$payload = @{
|
||||||
|
"chat_id" = $id_chat
|
||||||
|
"text" = $Text
|
||||||
|
"parse_mode" = "html"
|
||||||
|
}
|
||||||
|
Invoke-RestMethod -Uri ("https://api.telegram.org/bot{0}/sendMessage" -f $token_bot) -Method Post -ContentType "application/json;charset=utf-8" -Body (
|
||||||
|
ConvertTo-Json -Compress -InputObject $payload
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Send-Telegram -Text Test
|
||||||
|
|
||||||
# Selenium
|
# Selenium
|
||||||
|
|
||||||
.\nuget.exe install Selenium.WebDriver
|
.\nuget.exe install Selenium.WebDriver
|
||||||
|
|
@ -2469,6 +2541,14 @@ $wshell.SendKeys("{F1}")
|
||||||
$wshell.SendKeys("{F12}")
|
$wshell.SendKeys("{F12}")
|
||||||
$wshell.SendKeys("{+}{^}{%}{~}{(}{)}{[}{]}{{}{}}")
|
$wshell.SendKeys("{+}{^}{%}{~}{(}{)}{[}{]}{{}{}}")
|
||||||
|
|
||||||
|
function Get-AltTab {
|
||||||
|
$wshell = New-Object -ComObject wscript.shell
|
||||||
|
$wshell.SendKeys("%{Tab}") # ALT+TAB
|
||||||
|
sleep 120
|
||||||
|
Get-AltTab
|
||||||
|
}
|
||||||
|
Get-AltTab
|
||||||
|
|
||||||
### Wscript.Shell.Popup
|
### Wscript.Shell.Popup
|
||||||
$wshell = New-Object -ComObject Wscript.Shell
|
$wshell = New-Object -ComObject Wscript.Shell
|
||||||
$output = $wshell.Popup("Выберите действие?",0,"Заголовок",4)
|
$output = $wshell.Popup("Выберите действие?",0,"Заголовок",4)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue