Skip to content

Instantly share code, notes, and snippets.


  • The Full Circle
Block or report user

Report or block AshFlaw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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}
AshFlaw / Remove-SSLNagScreenPRTG.ps1
Last active Oct 7, 2018
Remove the SSL reminder screen in PRTG. Useful for reverse proxy situations when the proxy is SSL but the internal termination is HTTP.
View Remove-SSLNagScreenPRTG.ps1
Write-Output "Stopping PRTG Core Service"
Get-Service -Name prtgcoreservice | Stop-Service
Write-Output "Disabling SSL nag message in UI"
Set-ItemProperty -path "HKLM:\SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Webserver" -Name "showsslnagscreen" -value 0
Write-Output "Starting PRTG Core Service"
Get-Service -Name prtgcoreservice | Start-Service
You can’t perform that action at this time.