This file contains hidden or 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
| function Get-ServerOS{ | |
| [CmdletBinding()] | |
| param( | |
| [Parameter(Mandatory=$true)] | |
| [string]$Server | |
| ) | |
| Get-ADComputer -Filter {Name -eq $Server} -Properties Name,OperatingSystem,Enabled -ResultSetSize 1000000 | | |
| Where-Object {$_.OperatingSystem -like "Windows Server*"} | Select-Object Name,Enabled,OperatingSystem | |
This file contains hidden or 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
| function Get-ServersOS { | |
| Write-Output "Enabled Computer Accounts Only" | |
| $Servers = Get-ADComputer -Filter * -Properties Name,OperatingSystem,Enabled -ResultSetSize 1000000 | | |
| Where-Object {$_.OperatingSystem -like "Windows Server*"} | Select-Object Name,Enabled,OperatingSystem | Sort-Object Name | |
| ( $Servers | Where {($_.Enabled -eq $true)} ).OperatingSystem | Sort-Object | Get-Unique -AsString | |
| } |
This file contains hidden or 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
| function Get-Uptime { | |
| $OS = (Get-WmiObject Win32_OperatingSystem) | |
| $UpTime = (Get-Date) - ($OS.ConvertToDateTime($OS.LastBootUpTime)) | |
| $Display = "" + $Uptime.Days + "days / " + $Uptime.Hours + "hours / " + $Uptime.Minutes + "minutes" | |
| Write-Output $Display | |
| } |
This file contains hidden or 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
| function OS-Info { | |
| [CmdletBinding()] | |
| $OSInfo = Get-CimInstance Win32_OperatingSystem | Select-Object -property @{Name = "OS"; Expression = {$_.Caption} },Version,ServicePackMajorVersion,OSArchitecture, ` | |
| @{Name = "Hostname"; Expression = {$_.CSName} },WindowsDirectory | |
| $OSName = ($OSInfo | Select-Object OS).OS # So we can use $OS | |
| $OSBuild = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' �Name CurrentBuild).CurrentBuild | |
| $BuildNum = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' �Name UBR).UBR | |
| $OSVersion = $OSBuild + "." + $BuildNum |
This file contains hidden or 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
| function Is-Admin { | |
| ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") | |
| # Use Like this: | |
| If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") ) { | |
| Write-Output "This script needs to be run as Admin" | |
| Break | |
| } |
This file contains hidden or 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
| function Syn { | |
| Write-Host -Foregroundcolor Green "What is being blocked by a FW, Routing or other network issue etc...?" | |
| cmd /c netstat -ano | findstr /i "syn" | |
| } | |
| function List { | |
| Write-Host -Foregroundcolor Green "Am I Listening on a Port?" | |
| cmd /c netstat -ano | findstr /i "List" | |
| } |
This file contains hidden or 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
| function Port-Status { | |
| [CmdletBinding()] | |
| param( | |
| [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)] | |
| [ValidateNotNullOrEmpty()] | |
| [string]$Port | |
| ) | |
| Get-NetTCPConnection -LocalPort $Port |
This file contains hidden or 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
| function Get-AllLAPSPw{ | |
| [CmdletBinding()] | |
| param( | |
| [Parameter(Mandatory=$true)] | |
| [string]$ComputerName | |
| ) | |
| Write-Host "if you can do this as a User you have security issues see here `r`n | |
| https://techcommunity.microsoft.com/t5/itops-talk-blog/step-by-step-guide-how-to-configure-microsoft-local/ba-p/2806185 `r`n |
This file contains hidden or 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
| function Get-LAPSPw{ | |
| [CmdletBinding()] | |
| param( | |
| [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,HelpMessage="Server or PC Name?")] | |
| [ValidateNotNullOrEmpty()] | |
| [string]$Device | |
| ) | |
| Write-Host "if you can do this as a User you have security issues see here `r`n |
This file contains hidden or 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
| function Get-UsersOnAllServers{ | |
| $Servers = (Get-ADComputer -Filter * -Properties Name,OperatingSystem,Enabled -ResultSetSize 1000000 | | |
| Where-Object {$_.OperatingSystem -like "Windows Server*"} | Sort-Object Name).Name | |
| foreach ($Item in $Servers) | |
| { | |
| Write-Host "################" | |
| $Item # Server Name | |
| qwinsta /server:$Item |