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
# Define CoCreateInstance function and IInternetSecurityManager interface | |
Add-Type -TypeDefinition @" | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Runtime.InteropServices.ComTypes; | |
public class NativeMethods | |
{ | |
private const string CLSID_InternetSecurityManager = "7b8a2d94-0ac9-11d1-896c-00c04fb6bfc4"; |
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
REM read OS version x.y.z.p | |
for /f "usebackq tokens=*" %%n in (`WMIC.exe os get Version ^| findstr /v /r "^$"`) do ( | |
SET OSVersion=%%n ) | |
REM read Description : Ex: Windows 10 Professional N | |
for /f "usebackq tokens=*" %%n in (`WMIC.exe os get Caption ^| findstr /v /r "^$"`) do ( | |
SET OSName=%%n ) | |
REM read type... 1=> workstation, 2=> domain controller , 3=> server | |
for /f "usebackq tokens=*" %%n in (`WMIC.exe os get ProductType ^| findstr /v /r "^$"`) do ( |
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
# | |
# Typically the standard practice during HTTP communication requires you to encode, certain characters that are not allowed | |
# in the URI naming convention. System.Web.HttpUtility class has methods to help you conver these characters to the encoded | |
# format. Here's a helper function in powershell. | |
# | |
[Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null | |
function EncodeUrl( [string] $URL ) |
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
<# | |
.SYNOPSIS | |
<Overview of script> | |
.DESCRIPTION | |
<Brief description of script> | |
.PARAMETER <Parameter Names, zero or more> | |
<Brief description of parameter input required. Repeat this attribute if required> |
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
# | |
# Function to enable or disable Event channels in Windows | |
# | |
function ConfigureEventChannel | |
{ | |
param( | |
[string] $logName, | |
[switch] $Disable | |
) |
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
# | |
# If given GPO is linked to any OU, it deletes the links and then attempts to delete the GPO. | |
# | |
function Delete-GPOByName | |
{ | |
param( | |
[string]$GPOName, | |
[string]$DomainName | |
) | |
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
function TcpSendRecv() | |
{ | |
param( | |
[int] $Port = 5005, | |
$IP = "127.0.0.1" , | |
$Message = "TRUN ." + "A"*6000 +". " | |
) | |
$Address = [system.net.IPAddress]::Parse($IP) | |
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
# WinRM only works on Private and Domain networks, it is disabled on public networks. | |
# Detect and modify any networks which are set to Public, ensure that every network is private. | |
# First, set CategoryType to 1 under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles | |
# Then create an instance of {DCB00C01-570F-4A9B-8D69-199FDBA5723B}, get connections and set the category! | |
function Enable-WinRMOnWorkGroupMachine { | |
$Private:ConnectionProfiles = Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles' | |
foreach ($ConnProf in $Private:ConnectionProfiles) { |
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
#-- For full script, refer: https://github.com/VimalShekar/PowerShell/blob/master/GetCredmanCreds.ps1 | |
# This script uses CredEnum Windows API, to retrieve stored usernames and passwords from Windows credential manager. | |
# | |
# Function to compile C Sharp code into an assembly | |
# | |
function Compile-Csharp () | |
{ | |
param( |
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
# Adding as GIST, to make it easier to link to my blog. | |
# Visit: vimalshekar.ml for more interesting scripts. | |
# | |
# If given GPO is linked to any OU, it deletes the links and then attempts to delete the GPO. | |
# | |
function Delete-GPOByName | |
{ | |
param( |
NewerOlder