Skip to content

Instantly share code, notes, and snippets.

View techthoughts2's full-sized avatar
🕵️‍♂️
Investigating a better artifact workflow

Jake Morrison techthoughts2

🕵️‍♂️
Investigating a better artifact workflow
View GitHub Profile
@techthoughts2
techthoughts2 / suffixes.ps1
Last active January 6, 2017 21:59
DNS Suffixes
#set suffixes
$suffixes = "suffix1.int,suffix2.int,suffix3.int"
$command = @"
cmd.exe /C "wmic nicconfig call SetDNSSuffixSearchOrder ($domain,$suffixes)"
"@
Invoke-Expression -Command:$command -ErrorAction SilentlyContinue
#------------------------------------------------------------------------------
#reverse suffixes change
#Append Primary and connection specific DNS suffixes
#Append parent suffixes of the primary DNS suffix
@techthoughts2
techthoughts2 / Shares.ps1
Created January 23, 2017 21:40
Create a folder share
$Shares=[WMICLASS]”WIN32_Share”
$Shares.Create("C:\folder\provisioning","Everyone",0)
@techthoughts2
techthoughts2 / enable_HV_PS.ps1
Created January 30, 2017 23:38
Enable just Hyper-V PowerShell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell -All
@techthoughts2
techthoughts2 / Splat.ps1
Created March 24, 2017 21:34
Splatting
$paramHash = @{
ServiceName = "BITS"
ComputerName = "Localhost"
Outvariable = "results"
}
Get-Service @paramHash
@techthoughts2
techthoughts2 / set.ps1
Created April 29, 2017 01:52
Create a SET
New-VMSwitch -Name "TeamedvSwitch" -AllowManagementOS $true -NetAdapterName "Ethernet","Ethernet 3" -EnableEmbeddedTeaming $true
@techthoughts2
techthoughts2 / base_config.ps1
Last active April 30, 2017 02:21
Basic Configuration of a device. Assign IP to adapter, set DNS ip and gateway, rename, and join to a domain
$compname = "20161"
$ip = "10.0.2.4"
#find a way to get the interfaceindex
$index = Get-NetAdapter | Select-Object -ExpandProperty ifIndex
#now set the ip of that index adapter
New-NetIPAddress -InterfaceIndex $index -IPAddress $ip -PrefixLength 16 -DefaultGateway 10.0.0.1
#now set the DNS for that index adapter
Set-DnsClientServerAddress -InterfaceIndex $index -ServerAddresses 10.0.3.190
$cred = Get-Credential -UserName domain\user -Message "Enter domain creds"
@techthoughts2
techthoughts2 / TrustCerts.ps1
Created May 24, 2017 22:04
This code block can be used to permit Invoke-WebRequest to work with SSL addresses that don't have a trusted certificate authority
##############################################################
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
@techthoughts2
techthoughts2 / windowsUpdateVersion.ps1
Created May 31, 2017 19:27
Get the version of windows update with powershell
(Get-ItemProperty -Path 'C:\Windows\System32\wuaueng.dll').VersionInfo | ft -autosize
@techthoughts2
techthoughts2 / netAdapterBindings.ps1
Created June 8, 2017 22:05
Enable or disable network bindings (ie disable IPv4 or enable IPv6)
<#
disable/enable network binding
DisplayName ComponentID
----------- -----------
File and Printer Sharing for Microsoft Networks ms_server
Client for Microsoft Networks ms_msclient
Internet Protocol Version 4 (TCP/IPv4) ms_tcpip
Microsoft Network Adapter Multiplexor Protocol ms_implat
Internet Protocol Version 6 (TCP/IPv6) ms_tcpip6
Link-Layer Topology Discovery Responder ms_rspndr
@techthoughts2
techthoughts2 / secureCred.ps1
Created June 27, 2017 18:38
Create a secure credential object
$PASSWORD = 'password'
$user = "domain\user"
$secureString = ConvertTo-SecureString -AsPlainText -Force -String $PASSWORD
$credential = New-Object `
-TypeName System.Management.Automation.PSCredential `
-ArgumentList $user,$secureString