Skip to content

Instantly share code, notes, and snippets.

View laymanstake's full-sized avatar
🎯
Focusing

Nitish Kumar laymanstake

🎯
Focusing
View GitHub Profile
@laymanstake
laymanstake / PrometheusGrafanaSetup.ps1
Last active October 24, 2022 16:40
PowerShell script, which can download almost all the latest packages (except nssm, which is not github hosted) and then proceed to configure them on the same machine. Functions to download and create services are created in a way that select set of package can be downloaded or installed as putting everything on the same server may not be good idea.
#Requires -RunAsAdministrator
#Requires -Version 3.0
#Requires -Modules BitsTransfer
# Author : Nitish Kumar
# Download and Install Prometheus, Grafana and Windows Exporter
# version 1.0 | 19/10/2022 Initial version
# version 1.1 | 21/10/2022 Cleaned up the script to supress error messages, added override switch
# version 1.2 | 21/10/2022 Added a crude way to update Prometheus configuration for adding nodes at mass scale
# version 1.3 | 22/10/2022 Added remove services option. Sorted nssm output encoding issue to find install path
# version 1.4 | 23/10/2022 Ready for mass deployment, sample code parts added
@laymanstake
laymanstake / EmailAlert.ps1
Last active October 26, 2022 04:14
PowerShell Script, for sending Email alerts
# Author : Nitish Kumar
# Email Alert Function
# version 1.0 | 19/10/2022
# Function to send email
function EmailAlert () {
[CmdletBinding()]
param(
[parameter(mandatory=$true)]$RecipientAddressTo,
[parameter(mandatory=$true)]$SenderAddress,
@laymanstake
laymanstake / PrometheusGrafanaSetup.sh
Last active October 30, 2022 16:41
Bash script, which can download almost all the latest packages for Prometheus, Grafana and node Exporter and then proceed to configure them
#!/bin/bash
# Author : Nitish Kumar
# Download and Install Prometheus, Grafana and Node Exporter
# version 1.0 | 24/10/2022 Initial version
# version 1.1 | 25/10/2022 Removed sudo from inside the script, added remove-services function
PROMETHEUS_VERSION=$(curl -s https://raw.githubusercontent.com/prometheus/prometheus/master/VERSION)
NODE_VERSION=$(curl -s https://raw.githubusercontent.com/prometheus/node_exporter/master/VERSION)
@laymanstake
laymanstake / PowerShellGUI.ps1
Last active November 26, 2022 15:20
Collection of PS functions for UI Elements
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Windows.Forms.DataVisualization
function New-SplashFromImage{
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline = $true,mandatory=$true)][String]$imageFilePath
)
Add-Type -AssemblyName System.Windows.Forms
@laymanstake
laymanstake / Start-ADAssessment.ps1
Last active April 12, 2024 21:57
The script to perform AD assessment including ADFS, ADSync checks
#Requires -Version 3.0
#Requires -Modules ActiveDirectory, GroupPolicy, DnsServer
<#
Author : Nitish Kumar
Performs Active Directory Forest Assessment
version 1.0 | 06/06/2023 Initial version
version 1.1 | 15/06/2023 Covered most areas though error proofing and dependency over wsman still remains
version 1.2 | 16/06/2023 Number of small fixes included wrong calulations on empty groups
version 1.3 | 21/06/2023 PowerShell jobs for AD health checks and Domain Summary details, Also chosing least latency DC
@laymanstake
laymanstake / install-remotepatch.Ps1
Last active July 21, 2023 07:49
To patch a server remotely, if you have admin access and PS remoting on, then all it needs the machine name
#Requires -Version 3.0
<#
Author : Nitish Kumar
Performs Remote patching
version 1.0 | 25/06/2023 Initial version
The script is kept as much modular as possible so that functions can be modified or added without altering the entire script
Disclaimer: This script is designed for illustration purposes only and the author do not claim to be responsible for any issues if caused by the script in production usages. Do due dilligence before running in the production environment
@laymanstake
laymanstake / Get-DFSInventory.ps1
Last active March 8, 2024 16:54
This function creates DFS inventory for the given domain. It uses PS jobs to process multiple DFS shares in parallel so report should be available within mins
Import-module ActiveDirectory
if ((Get-Module -ListAvailable -Name DFSN) -AND (Get-Module -ListAvailable -Name DFSR)) {
Import-Module DFSN
Import-Module DFSR
}
else {
Exit
Write-Output "Either of DFSN or DFSR is not available"
}
@laymanstake
laymanstake / Get-DHCPInventory.ps1
Last active July 25, 2023 07:54
The function to get DHCP Inventory along with reservations. It uses PS jobs so even if you have many DHCP servers in org or many scopes, it should be done within mins
$logpath = "c:\temp\logfile.txt"
function Write-Log {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline = $true, mandatory = $true)]$logtext,
[Parameter(ValueFromPipeline = $true, mandatory = $true)]$logpath
)
$Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
@laymanstake
laymanstake / Test-ADHealth.ps1
Last active July 15, 2023 14:43
Function to test AD health. It utilizes dcdiag and produces tabular output
function Test-ADHealth {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline = $true, mandatory = $true)]$DomainName,
[Parameter(ValueFromPipeline = $true, mandatory = $true)][pscredential]$Credential
)
$Report = @()
$dcs = Get-ADDomainController -Filter * -Server $DomainName -Credential $Credential
@laymanstake
laymanstake / Start-ADAssessment-nocred.ps1
Last active September 10, 2023 11:09
AD Assessment script for CyberArk like cases without asking cred
#Requires -Version 3.0
#Requires -Modules ActiveDirectory, GroupPolicy, DnsServer
<#
Author : Nitish Kumar
Performs Active Directory Forest Assessment
version 1.0 | 06/06/2023 Initial version
version 1.1 | 15/06/2023 Covered most areas though error proofing and dependency over wsman still remains
version 1.2 | 16/06/2023 Number of small fixes included wrong calulations on empty groups
version 1.3 | 21/06/2023 PowerShell jobs for AD health checks and Domain Summary details, Also chosing least latency DC