Skip to content

Instantly share code, notes, and snippets.

View wsmelton's full-sized avatar
🦆
Little bit of this, little bit of that

Shawn Melton wsmelton

🦆
Little bit of this, little bit of that
View GitHub Profile
@jstangroome
jstangroome / gist:3087453
Created July 11, 2012 01:58
Change your own Active Directory password from PowerShell without any special permissions
([adsi]'WinNT://domain/username,user').ChangePassword('oldpassword','newpassword')
@NickCraver
NickCraver / Windows10-Setup.ps1
Last active April 1, 2024 10:52
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
#region setup
$WorkingDir = $psISE.CurrentFile.FullPath | Split-Path
Set-Location $WorkingDir
Add-AzureRmAccount
$AAAcct = Get-AzureRmAutomationAccount -Name DSCDemo01 -ResourceGroupName DSCDemo01
#endregion
#region list local VMs
Get-VM | Where-Object -FilterScript {$_.State -eq 'Running'}
#endregion
#region setup
$WorkingDir = $psISE.CurrentFile.FullPath | Split-Path
Set-Location $WorkingDir
#Add-AzureRmAccount
$AAAcct = Get-AzureRmAutomationAccount -Name DSCDemo01 -ResourceGroupName DSCDemo01
function Wait-AADSCCompileJob {
param (
[parameter(Mandatory,ValueFromPipeline)]
[Microsoft.Azure.Commands.Automation.Model.CompilationJob] $CompileJob,
<#
.SYNOPSIS
Get-SqlErrorLog is designed to quickly retrieve data from SQL Server error logs, negating the slowness of SSMS and awkwardness of manually crawling files.
.DESCRIPTION
Get-SqlErrorLog is designed to quickly retrieve data from SQL Server error logs, negating the slowness of SSMS and awkwardness of manually crawling files.
It is designed to be quite light in it's process, and should be quick (loading SQLPLS being the exception.
@Badabum
Badabum / Merge-Json.ps1
Created August 8, 2017 14:40
Merge two .json objects using PowerShell
function Join-Objects($source, $extend){
if($source.GetType().Name -eq "PSCustomObject" -and $extend.GetType().Name -eq "PSCustomObject"){
foreach($Property in $source | Get-Member -type NoteProperty, Property){
if($extend.$($Property.Name) -eq $null){
continue;
}
$source.$($Property.Name) = Join-Objects $source.$($Property.Name) $extend.$($Property.Name)
}
}else{
$source = $extend;
@ThePSAdmin
ThePSAdmin / powershell.json
Created January 12, 2018 13:14
VSCode snippets for powershell
{
"Write Verbose": {
"prefix": "wv",
"body": [
"Write-Verbose \"[${TM_FILENAME/(.*)\\..+$/$1/}] $0\""
],
"description": "Write-Verbose with base name of filename."
},
@digitalohm
digitalohm / gist:048058c8b1a9a61bbeb9b49808b603a7
Created April 25, 2018 19:10
multi threaded restore dbatools
# Get credentials and store them securely in an encrypted xml file
if (-NOT (Test-Path "${env:\userprofile}\DBA001.Cred")){
$Credential = Get-Credential
$Credential | Export-CliXml -Path "${env:\userprofile}\DBA001.Cred"
}
#Load the credentials
$SqlCredential = Import-CliXml -Path "${env:\userprofile}\DBA001.Cred"
# Create a CSV of all the databases that are in the availability group. This updates each time to be complete
@wsmelton
wsmelton / SSMS_ProductInformation.ps1
Last active January 14, 2021 21:42
Listing of ProductID and Product Name for SSMS install with PowerShell DSC
<#
Listing of the required information to install SQL Server Management Studio via the Package resource with PowerShell DSC.
# Example config:
Configuration InstallSSMS {
Package InstallSsms {
Ensure = "Present"
ProductID = <GUID value>
Name = Full SSMS Name that displays in Program Features
Path = SSMS-Setup-ENU.exe
@SteveL-MSFT
SteveL-MSFT / profile.ps1
Last active March 11, 2024 01:21
PowerShell Prompt
#Requires -Version 7
# Version 1.2.13
# check if newer version
$gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e"
$latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version')
$versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)"
if ([System.IO.File]::Exists($latestVersionFile)) {