Skip to content

Instantly share code, notes, and snippets.

@ScriptingPro
ScriptingPro / check-iis-version.ps1
Created October 27, 2016 20:19
Check IIS Version with Powershell
<#
one-liner to quickly determine IIS version information from a Powershell prompt
#>
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\InetStp' | select InstallPath, VersionString, @{n="ProductVersion";e={(Get-ItemProperty ($_.InstallPath + "\w3wp.exe")).VersionInfo.ProductVersion}}
@ScriptingPro
ScriptingPro / powershell-promote-domain-controller.ps1
Last active February 1, 2017 05:32
Install Domain Controller Windows Server 2012 R2 Powershell
<#
@scriptingpro
Using powershell to promote a new domain controller
This will Install a new RODC
Todo:
parameterize SafeModeAdministratorPassword (DSRM password)
#>
#First add the Active Directory Domain Services feature to your server
@ScriptingPro
ScriptingPro / powershell-set-terminal-services-profile-path.ps1
Last active September 27, 2021 12:33
PowerShell Set Terminal Services Profile Path
<#
Set Active Directory Users Terminal Services Profile Path Using PowerShell
There is no remote desktop services profile path attribute, because TerminalServicesProfilePath is saved in the Active Directory user object's UserParameters attribute as a binary blob
This snippet will find ADUsers that match $TSProfilePath_OLD and set their remote desktop services profile path to $TSProfilePath_NEW
#>
# Need Active Directory Cmdlets
Import-Module ActiveDirectory
# Change TerminalServicesProfilePath only on users that are currently pointing to:
@ScriptingPro
ScriptingPro / Determine .NET Framework Versions Installed.ps1
Last active June 19, 2018 23:33
Determine .NET Framework Versions Installed
# check dot net version
gci 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | gp -name Version,Release -EA 0 | ?{ $_.PSChildName -match '^(?!S)\p{L}'} | select PSChildName, Version, Release
# how to check net framework version installed
# where can i find net framework on my computer
# verify net framework version installed
# determine .net framework versions
# where to find net framework on computer
@ScriptingPro
ScriptingPro / System.DirectoryServices.ActiveDirectory.ps1
Last active February 16, 2024 00:42
Query Active Directory without ActiveDirectory Module
#get dnsroot
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().Name
#get domain distinguishedname
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().GetDirectoryEntry().Properties["distinguishedName"]
#list domain controllers
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().FindAllDomainControllers().Name
#get PDC
@ScriptingPro
ScriptingPro / find dupe files by hash.ps1
Created October 25, 2017 23:57
powershell find duplicate files
# powershell find duplicate files md5
# powershell get childitem filter duplicates
# script to find duplicate files windows
# powershell duplicate files md5
gci * -Recurse | get-filehash -Algorithm MD5 | Group-Object hash | ?{$_.count -gt 1} | select @{n='DupeCount';e={$_.Count}}, @{n='DupeFiles';e={$_.Group.Path -join [System.Environment]::NewLine}} | Out-GridView
@ScriptingPro
ScriptingPro / powershell get configurationNamingContext.ps1
Last active February 5, 2019 19:35
different ways to get configurationNamingContext
[ADSI]"LDAP://RootDSE" | fl *
([ADSI]"LDAP://RootDSE").configurationNamingContext
([ADSI]"LDAP://RootDSE").get("configurationNamingContext")
# Domain Distinguished Name
([ADSI]"LDAP://RootDSE").defaultNamingContext
@ScriptingPro
ScriptingPro / README-Template.md
Created October 26, 2017 00:35 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@ScriptingPro
ScriptingPro / LDAP-Request.ps1
Created November 22, 2017 18:06
LdapConnection AddRequest SendRequest
$AuthenticationType = [System.DirectoryServices.AuthenticationTypes]::Secure
$DirectoryConnection = New-Object -TypeName System.DirectoryServices.Protocols.LdapConnection -ArgumentList "ldapserver.domain.com:777,uid=newuser,ou=people,dc=company,dc=com", $password , $AuthenticationType
$DirectoryConnection.Bind()
$DirectoryRequest = New-Object -TypeName System.DirectoryServices.Protocols.AddRequest
$DirectoryRequest.DistinguishedName = "uid= xxxx, ou=user, o=company"
$DirectoryRequest.Attributes.Add((New-Object -TypeName System.DirectoryServices.Protocols.DirectoryAttribute -ArgumentList "objectclass",@("top","organizationalPerson","person","inetorgperson","inetuser","mailrecipient","pwmuser","posixAccount"))) | Out-Null
$DirectoryRequest.Attributes.Add((New-Object -TypeName System.DirectoryServices.Protocols.DirectoryAttribute -ArgumentList "cn",($FirstName+" "+$LastName))) | Out-Null
$DirectoryConnection.SendRequest($DirectoryRequest)
@ScriptingPro
ScriptingPro / AD Exchange Queries.ps1
Last active September 27, 2018 18:47
AD/ADSI/LDAP MSExchange related queries (without using Exchange Management Shell cmdlets)
#Get Exchange Servers
Get-ADObject -SearchBase $(Get-ADRootDSE).configurationNamingContext -Filter {objectCategory -eq "msExchExchangeServer"}
# Find well-known Exchange groups in Active Directory
Get-ADObject $(Get-ADRootDSE).configurationNamingContext -Filter {objectclass -eq "msExchConfigurationContainer"} -Properties otherwellKnownObjects | select -ExpandProperty otherwellKnownObjects | %{$_.Split(":")[-1]}