Difference between revisions of "Zabbix scripts"
Jump to navigation
Jump to search
(Created page with "powershell.exe -NoProfile -NoLogo -ExecutionPolicy Bypass -c "restart-service \"My Service\""") |
|||
Line 1: | Line 1: | ||
+ | ``` | ||
powershell.exe -NoProfile -NoLogo -ExecutionPolicy Bypass -c "restart-service \"My Service\"" | powershell.exe -NoProfile -NoLogo -ExecutionPolicy Bypass -c "restart-service \"My Service\"" | ||
+ | ``` | ||
+ | |||
+ | |||
+ | ``` | ||
+ | powershell.exe -NonInteractive -NoProfile -Command "$keySet = @{};:loop while ($true){$adapters = Get-NetAdapter -Physical | Get-NetAdapterStatistics;foreach ($adapter in $adapters){if (-not $keySet.ContainsKey($adapter.Name)) {$null = $keySet.Add($adapter.Name,$adapter.ReceivedBytes)};if ($adapter.ReceivedBytes -ne $keySet[$adapter.Name]) {$myip = Get-NetIPAddress -InterfaceAlias $adapter.Name -AddressFamily ipv4;Write-Output -InputObject $myip.IpAddress;Break loop;}}}" | ||
+ | ``` | ||
+ | |||
+ | ``` | ||
+ | $ints=$((Get-NetAdapter -Physical | Get-NetAdapterStatistics).Name) | ||
+ | foreach ($int in $ints){ (Get-NetIPAddress | Where-Object {$_.InterfaceAlias -eq "$int"}).IPAddress } | ||
+ | ``` | ||
+ | |||
+ | ``` | ||
+ | $keySet = @{}; | ||
+ | loop while ($true){$adapters = Get-NetAdapter -Physical | Get-NetAdapterStatistics;foreach ($adapter in $adapters){if (-not $keySet.ContainsKey($adapter.Name)) {$null = $keySet.Add($adapter.Name,$adapter.ReceivedBytes)};if ($adapter.ReceivedBytes -ne $keySet[$adapter.Name]) {$myip = Get-NetIPAddress -InterfaceAlias $adapter.Name -AddressFamily ipv4;Write-Output -InputObject $myip.IpAddress;Break loop;}} | ||
+ | ``` |
Revision as of 22:44, 23 May 2023
powershell.exe -NoProfile -NoLogo -ExecutionPolicy Bypass -c "restart-service \"My Service\""
powershell.exe -NonInteractive -NoProfile -Command "$keySet = @{};:loop while ($true){$adapters = Get-NetAdapter -Physical | Get-NetAdapterStatistics;foreach ($adapter in $adapters){if (-not $keySet.ContainsKey($adapter.Name)) {$null = $keySet.Add($adapter.Name,$adapter.ReceivedBytes)};if ($adapter.ReceivedBytes -ne $keySet[$adapter.Name]) {$myip = Get-NetIPAddress -InterfaceAlias $adapter.Name -AddressFamily ipv4;Write-Output -InputObject $myip.IpAddress;Break loop;}}}"
$ints=$((Get-NetAdapter -Physical | Get-NetAdapterStatistics).Name) foreach ($int in $ints){ (Get-NetIPAddress | Where-Object {$_.InterfaceAlias -eq "$int"}).IPAddress }
$keySet = @{}; loop while ($true){$adapters = Get-NetAdapter -Physical | Get-NetAdapterStatistics;foreach ($adapter in $adapters){if (-not $keySet.ContainsKey($adapter.Name)) {$null = $keySet.Add($adapter.Name,$adapter.ReceivedBytes)};if ($adapter.ReceivedBytes -ne $keySet[$adapter.Name]) {$myip = Get-NetIPAddress -InterfaceAlias $adapter.Name -AddressFamily ipv4;Write-Output -InputObject $myip.IpAddress;Break loop;}}