This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#the property "DriverODBCVer" is which version of *ODBC* it supports. We have to get the file info. | |
#https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/how-to-correctly-check-file-versions-with-powershell/ba-p/257642 | |
$odbc= get-odbcdriver|where {$_.name -match "sql server"} | |
$flat = foreach ($odbclist in $odbc){ | |
foreach($Property in ($odbclist.attribute)){ | |
$driverfilename = $property.driver -replace "%WINDIR%", "C:\windows\" | |
$driverversion = ((get-item $driverfilename).VersionInfo |select -expand Fileversion) | |
[pscustomobject]@{ | |
name = ($odbclist.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Who: Michael Bourgon 2024 | |
#What: save out all your messages/chats/meetings from Teams to HTML pages for later searching | |
#future fixes: change the filedate to be the time of the last message. Doubt it matters, though, since you'll be scanning this and see that it's archived. | |
# Requires the microsoft graph powershell module 1.27 or better. | |
$RequiredScopes = @("Chat.ReadBasic", "Chat.ReadWrite") | |
Connect-MgGraph -Scopes $RequiredScopes | |
$startdate = (get-date).AddDays(-3000) #because for oneOnOnes, I want a lot, and it searches for changes, not meetings with active messages - doesn't appear to be a way | |
$meetingchanged = (get-date).AddDays(-210) #lookback for meeting changes, only include meetings with changes more recent than this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--1.1, 20191210 first version I know of | |
--1.2, 20230223 major changes to speed it up, after dealing with a particular server, added Azure SQL DB details. | |
--1.21 20230403 adding event_sequence | |
--1.22 20230427 adding CPID Client PID. Find app with posh: gwmi win32_process -cn theclientnamehere -filter "ProcessId=2900" | |
--thebakingdba.blogspot.com | |
/* | |
CREATE EVENT SESSION | |
severity_10plus_errors_XE_memory | |
ON server --use "on database" for Azure SQL DB | |
ADD EVENT sqlserver.error_reported |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#2022/10/17 mdb - the goal is to be able to run this on-prem and send emails from azure. | |
# This needs to be replaced with a function at some point, but I need email functionality right now. | |
# Tries to support as many of the standard parameters as possible. | |
#2023/01/06 mdb - adding maxcharlength at 200k to handle larger emails | |
#2023/01/17 mdb - handling double quotes in the query - can't use replace on a null, trying REPLACE in the initial query_to_run didn't work, wound up moving it after the null check for query block | |
#2023/01/19 mdb - what happens if the query is empty? No file created, so it fails. Fixed. | |
$ErrorActionPreference="Stop" | |
#First, get what's in the table to perform/mail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#What is this? Uses the microsoft tool & API & SQL Server to figure out ALL your actual datasources. | |
#As per the stackoverflow below, you CANNOT just use the RDLs - they don't get updated if you do it through the GUI. | |
#The Microsoft tool works great, but does them one at a time. So by combining the two, hopefully you get the best of both worlds. | |
#Note - there are two prerequisites. | |
#1 - invoke-sqlcmd2. Invoke/Import yourself; not doing it in here. Find on github. You might be able to use invoke-sqlcmd, but I never use it. | |
#2 - Microsoft's ReportingServicesTools, available on Github | |
#to install #2 (as of 2022): Invoke-Expression (Invoke-WebRequest https://raw.githubusercontent.com/Microsoft/ReportingServicesTools/master/Install.ps1) | |
$SSRS_Servername = "yourservernamehere" #assumes ReportServer for name. Aka when you go to the website, you should be able to http://yourservernamehere/ReportServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#you can't use ACTUAL adapter cards, but you can use HTML, albeit just BODY.#> | |
<#Thebakingdba.blogspot.com 2019#> | |
. C:\Powershell_Scripts\invoke-sqlcmd2.ps1 | |
$query = @" | |
DECLARE @tableHTML NVARCHAR(MAX) | |
, @MailSubject VARCHAR(200) | |
SELECT @tableHTML = '<table>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE mycrappydatabase | |
GO | |
CREATE PARTITION FUNCTION pf(INT) AS RANGE LEFT FOR VALUES (5,10,15); | |
GO | |
CREATE PARTITION SCHEME ps AS PARTITION pf ALL TO ([PRIMARY]); | |
GO | |
CREATE TABLE partitionexample(id INT PRIMARY KEY) ON ps(id); | |
GO | |
INSERT dbo.partitionexample | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Remove-Variable -Name * -ErrorAction SilentlyContinue | |
import-module awspowershell | |
$myaccesskey = "youraccesskey" | |
$mysecretkey = "yoursecretkey" | |
$myregion = "yourregion" | |
$myemail = "youremailaddress" | |
$mysmtp = "smtp.yourcompany.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import-module awspowershell | |
# removing variables. Note that this will wipe out default region, credentials, etc, if before this line. | |
Remove-Variable -Name * -ErrorAction SilentlyContinue | |
Set-DefaultAWSRegion -Region us-west-1 | |
$now = get-date | |
# For conversion from Unix Epoch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################### | |
## Reading error logs for Aurora with Powershell ## | |
################################################### | |
# 1.01 - MDB 2018/05/30 Better trapping of time; there's a lot of rows that have no datetime that I want. Also added HTML email. | |
# 1.02 - mdb 2018/05/30 also dealing better with the regex filter. Recommend you convert it to a NOTMATCH; too many different error types | |
clear | |
Remove-Variable -Name * -ErrorAction SilentlyContinue | |
$myemail="[email protected]" |
NewerOlder