Skip to content

Instantly share code, notes, and snippets.



  • The Full Circle
View GitHub Profile
AshFlaw / Set-StrongCryptoDotNet4.ps1
Created Jul 6, 2020
Permanently set .NET and PowerShell to use TLS1.2
View Set-StrongCryptoDotNet4.ps1
# set strong cryptography on 64 bit .Net Framework (version 4 and above)
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
# set strong cryptography on 32 bit .Net Framework (version 4 and above)
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
View Get-FolderSize.ps1
Function Get-FolderSize {
[Parameter(Mandatory = $false)]
$BasePath = 'C:\',
[Parameter(Mandatory = $false)]
AshFlaw / Set-SQLMSXEncryptionChannelOff.ps1
Created Mar 5, 2019
Function to disable SQL Agent MSX Encryption
View Set-SQLMSXEncryptionChannelOff.ps1
Function Set-SQLMSXEncryptionChannelOff
$Path = "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL13.SE\SQLServerAgent"
$Name = "MsxEncryptChannelOptions"
$DefaultValue = "2"
$NewValue = "0"
$ComputerName = $Env:COMPUTERNAME
$Item = (Get-ItemProperty $Path -Name $Name).$Name
if($Item -eq $DefaultValue)
AshFlaw / Register-WSUSOnlineAndInstallUpdates.ps1
Created Feb 24, 2019
Register MS Online updates provider to WU and install updates.
View Register-WSUSOnlineAndInstallUpdates.ps1
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d
Get-WUInstall –MicrosoftUpdate –AcceptAll –AutoReboot
AshFlaw / Install-dbatools.ps1
Created Jan 21, 2019
Function to install dbatools PowerShell Module
View Install-dbatools.ps1
function Install-dbatools {
Import-Module dbatools -ErrorAction SilentlyContinue
if((Get-Module | Where-Object {$_.Name -eq "dbatools"}) -eq $null) {
Write-Output "dbatools module installing"
Install-Module dbatools -force
else {
Write-Output "dbatools module already installed"
AshFlaw / Create-DbaTools-WatchDbLogins-SQL-Table.sql
Created Jan 10, 2019
Create table for function WatchDbLogins to log to
View Create-DbaTools-WatchDbLogins-SQL-Table.sql
USE [DatabaseLogins]
CREATE TABLE [dbo].[DbaTools-WatchDbLogins](
[ComputerName] [nvarchar](max) NULL,
[InstanceName] [nvarchar](max) NULL,
[SqlInstance] [nvarchar](max) NULL,
[LoginTime] [datetime2](7) NULL,
[Login] [nvarchar](max) NULL,
[Host] [nvarchar](max) NULL,
[Program] [nvarchar](max) NULL,
AshFlaw / Add-SQLDBUserToRole.ps1
Last active Jan 9, 2019
Add an existing SQL user to a role for a specific database
View Add-SQLDBUserToRole.ps1
Write-Output "Loaded Add-SQLDBUserToRole function"
Function Add-SQLDBUserToRole {
Param (
[string] $server,
[String] $Database ,
$Svr = New-Object ('Microsoft.SqlServer.Management.Smo.Server') $server
$db = $svr.Databases[$Database]
AshFlaw / Monitor-IISAppPoolState.ps1
Created Dec 29, 2018
Use PowerShell to Monitor IIS Websites and Application Pools
View Monitor-IISAppPoolState.ps1
$Servers = ''
Invoke-Command -ComputerName $Servers {
Import-Module -Name WebAdministration
$Websites = Get-Website
foreach ($Website in $Websites)
$AppPool = $Website.applicationPool
If ((Get-WebAppPoolState -Name $AppPool).Value -eq 'Stopped') {Start-WebAppPool -Name $AppPool}
$SiteState = $Website.State
AshFlaw / Get-TempDB-FileGroupInfo.sql
Created Dec 29, 2018
Get TempDB file group information
View Get-TempDB-FileGroupInfo.sql
SELECT DB_NAME(mf.database_id) database_name, logical_name,
(CONVERT(DECIMAL, size)/128)) as [file_size_MB],
CASE mf.is_percent_growth
THEN 'Yes'
AshFlaw / Set-WindowsFirewallPortsShazamDiscovery.ps1
Created Nov 16, 2018
Configure windows firewall to allow Shazam probe discovery
View Set-WindowsFirewallPortsShazamDiscovery.ps1
$Servers = Get-ADComputer -Filter 'ObjectClass -eq "Computer"' | Select-Object -Expand DNSHostName
Foreach ($Server in $Servers)
invoke-command -ComputerName $Server -ScriptBlock {Set-NetFirewallRule -DisplayGroup 'Remote Event Log Management' -Enabled True -PassThru -EdgeTraversalPolicy Allow | Select-Object DisplayName, Enabled}
invoke-command -ComputerName $Server -ScriptBlock {Set-NetFirewallRule -DisplayGroup "Windows Management Instrumentation (WMI)" -Enabled True -PassThru -EdgeTraversalPolicy Allow -ErrorAction SilentlyContinue | Select-Object DisplayName, Enabled}
You can’t perform that action at this time.