This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
Param( | |
$PRTGURL = "https://{your PRTG URL}/api", | |
$Auth = "username={your username}&passhash={your password hash}", | |
$SensorType = "ping" | |
) | |
$Sensors = "" | |
$Sensors = (invoke-restmethod "$PRTGURL/table.json?content=sensors&output=json&columns=objid,probe,group,device,sensor,status&count=10000&filter_type=$SensorType&$Auth").sensors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
Param( | |
$PRTGURL = "https://{your prtg URL}/api", | |
$Auth = "username={your prtg user}&passhash={your prtg password hash}" | |
) | |
$Sensors = "" | |
$Sensors = (invoke-restmethod "$PRTGURL/table.json?content=sensors&output=json&columns=objid,probe,group,device,sensor,status&count=10000&filter_type=httptransaction&$Auth").sensors | |
$i = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -version 2.0 | |
[CmdletBinding()] | |
param ( | |
[ValidateSet("London","Berlin","Tokyo","")][string]$location | |
) | |
Write-Host ("`n" * 5) | |
Import-Module ActiveDirectory -Cmdlet get-adcomputer | |
$Servers = get-adcomputer -filter {Enabled -eq $true -and OperatingSystem -Like "Windows*"} -property Enabled,OperatingSystem | ?{$_.DistinguishedName.contains($location)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Do{ | |
Write-Progress -Activity "$((get-date).hour) hours" -PercentComplete (((get-date).hour /23) * 100) -Status "$(24 - (get-date).hour) hours remaining" | |
Do{ | |
Write-Progress -Id 1 -Activity "$((get-date).minute) minutes" -PercentComplete (((get-date).minute / 59) * 100) -Status "$(60 - (get-date).minute) minutes remaining" | |
Do{ | |
Write-Progress -Id 2 -Activity "$((get-date).second) seconds" -PercentComplete (((get-date).second / 59) * 100) -Status "$(60 - (get-date).second) seconds remaining" | |
Do{ | |
$Second = (Get-Date).second | |
Write-Progress -Id 3 -Activity "$((get-date).millisecond) milliseconds" -Status "The time is $(get-date -f "HH:mm:ss")" -PercentComplete (((get-date).millisecond / 1000) * 100) -SecondsRemaining (86400 - (((get-date).hour * 60 * 60) + ((get-date).Minute * 60) + ((get-date).Second))) | |
# start-sleep -Milliseconds 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Servers = @("SERVER01","SERVER02","SERVER03") | |
$FolderPaths = $Servers | foreach { | |
Get-ChildItem "\\$_\DFSShare$" | |
} | Sort Path | |
$FolderPaths | Export-Csv "FolderPaths-$(Get-Date -format yyyy-MM-dd).csv" -NoTypeInformation | |
$TestPaths = (($FolderPaths).FullName | Sort-Object).Trimend('\') | |
$DFSPaths = ((Import-CSV "DFS-$(Get-Date -format yyyy-MM-dd).csv").TargetPath | Where-Object {($_ -ilike "*SERVER*") | Sort-Object).Trimend('\') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -version 2.0 | |
[CmdletBinding()] | |
param ( | |
[ValidateSet("Dublin","London”,"Tokyo","Sydney","")][string]$location | |
) | |
Import-Module ActiveDirectory -Cmdlet get-adcomputer | |
$servers = get-adcomputer -filter {Enabled -eq $true -and OperatingSystem -Like "Windows*"} -property Enabled,OperatingSystem | ?{$_.DistinguishedName.contains($location)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( @(53,88,135,389,636,3268) | Sort-Object | Out-String | ForEach-Object{$_ -replace '\n', ','} ).TrimEnd(',') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
Param( | |
$Computers = (Import-csv ".\servers.csv"), #Must include "adaccountname" column | |
$Patch = "KB2468871" | |
) | |
$i = 1 | |
ForEach ($Server in $Computers) { | |
Write-Progress -Activity "Checking $Server for hotfix $Patch" -Status "$i of $($Computers.Count)" -PercentComplete (($i / $Computers.Count)*100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This regex matches anything that's like an IP address (even invalid ones) | |
$regexIPAddress = '\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b' | |
#This regex matches anything like an IP address that starts 10, 172 or 192 | |
$regexIPSpace = '(10|172|192).\d{1,3}\.\d{1,3}\.\d{1,3}\b' | |
#Returns the first IP address in each line of the log file/s then sorts and removes duplicates. | |
Select-String -Path *.log -Pattern $regexIPAddress | ForEach-Object { $_.Matches } | % { $_.Value } | Sort-Object -Unique | Out-File 'UniqueIPs.txt' | |
#Returns from a selection of Log files any lines which match a certain string pattern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact='High')] | |
Param( | |
$PRTGURL = "https://{your PRTG URL}/api", | |
$Auth = "username={your PRTG user}&passhash={your PRTG password hash}", | |
$Name = "", | |
$Message = "", | |
[int]$DaysPaused = 7 #Use -1 to filter for where date is unknown and 0 to return all | |
) | |
$Devices = $null |
OlderNewer