Skip to content

Instantly share code, notes, and snippets.

View e-sterling's full-sized avatar

e-sterling

View GitHub Profile
@e-sterling
e-sterling / gist:c009eb395b310964c0dccf94a15dc6b9
Created May 6, 2021 12:56
"Unable to download the list of available providers" when installing NuGet
This is an issue I've run into a few times, when running Install-Module -Scope CurrentUser <ModuleName> for the first time
you need to install NuGet, but when you try to install it, you get the error...
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
If you try to Invoke-WebRequest manually...
Invoke-WebRequest "https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409"
You get the error...
@e-sterling
e-sterling / Get-InsecureLDAPBinds.ps1
Created January 22, 2020 15:21
Scrape all DCs for 2889 events (DIRLOG_UNSIGNED_CLIENT_DETAILS), export to Excel
$ReplicaDirectoryServers = ((Get-ADDomain).ReplicaDirectoryServers|Sort-Object)
$CurrentDate = Get-Date
$ParsedOut = @()
$ReplicaDirectoryServers | %{
Write-Host "Processing $($_)" -ForegroundColor Green
$Events = Get-EventLog -ComputerName $_ -LogName "Directory Service" | where {$_.EventID -eq "2889"}
$EventsCount = ($Events|Measure).Count
Write-Host "Found $($EventsCount) events..."
if($EventsCount -gt 0) {
$Events | %{
@e-sterling
e-sterling / Approve-WSUS-Updates.ps1
Last active February 18, 2022 14:23
A script to mass-approve updates for a specific computer group in WSUS
<#
.Synopsis
Approved a list of updates by their KB Numbers for a specified computer group
.Description
Interacts with an on-premise WSUS Server to enable an administrator to mass
approve windows updates for a specific computer group. The script can be
supplied with a comma-separated list of KB numbers, or a text file containing
one KB number on each line.
.Parameter WsusServer
A string containing the FQDN of a WSUS server
@e-sterling
e-sterling / gist:05af6a76082112b50e91bc010501767a
Created August 29, 2019 08:55
Check logon date for a specific user across all domain controllers
(Get-ADForest).GlobalCatalogs |%{Get-ADUser ethan.sterling -Server $_ -Properties LastLogonDate,PasswordLastSet}|Select SAMAccountName,LastLogonDate,PasswordLastSet |ft
@e-sterling
e-sterling / Install-RSAT.ps1
Created August 29, 2019 08:54
Install all RSAT tools on Win10 1903
Get-WindowsCapability -online | Where-Object {$_.Name -like "*RSAT*"} | Add-WindowsCapability -Online
@e-sterling
e-sterling / Remove-O365License.ps1
Last active June 11, 2019 09:08
Remove all O365 licences and disable On-Prem AD account for a list of users
<#
Uncomment line 23 and 36 to enable functionality
#>
# Import list of users to remove
$users = Get-Content '.\Input\UsersToRemove.txt'
# Connect to MSOL
$UserCredential = Get-Credential
Write-Host "[~] " -ForegroundColor yellow -NoNewline; Write-Host "Connecting to MSOL services... "
@e-sterling
e-sterling / Start-MSOLShell.ps1
Last active March 7, 2021 13:40
Script to connect to Exchange Online, MSOL, and AzureAD in one Powershell prompt
Write-Host "[~] " -ForegroundColor Yellow -NoNewline; Write-Host "Checking MSOL Modules..."
if (-not(Get-Command "Get-MsolDomain" -errorAction SilentlyContinue))
{
Write-Host "[-] " -ForegroundColor red -NoNewline; Write-Host "MSOL module not found, installing..."
Install-Module MSOnline -Scope CurrentUser
}
if (-not(Get-Command "Get-AzureADDomain" -errorAction SilentlyContinue))
{
Write-Host "[-] " -ForegroundColor red -NoNewline; Write-Host "AzureAD module not found, installing..."
Install-Module AzureAD -Scope CurrentUser