Today, I received a request to find the manager for a whole bunch of users. This was a list of names (not UserId's) in a Excel worksheet. It is not actually that complex to do it Locate the AD user based on the name Check the Manager property Lookup AD again for Manager to get … Continue reading PowerShell & Active Directory: Quickly Find The Manager For A Bunch Of Users
Tag: Output
PowerShell: Find & Replace SQL Server Stored Procedure/View/UDF/Trigger Code En Masse Based On Custom Criteria
Update April 19, 2019: Thanks to Tim (in comments), the updated script can also do find/replace in not just stored procedures but also views, UDF's and triggers. Today, a need came-up where a bunch of stored procedures had to be altered based on certain criteria. Easy way: Obviously, the easiest way would be to script … Continue reading PowerShell: Find & Replace SQL Server Stored Procedure/View/UDF/Trigger Code En Masse Based On Custom Criteria
PowerShell: Export-QueryToSQLTable – Export All Of Glenn Berry’s DMV’s, sp_WhoIsActive, sp_Blitz & Any Of Your Own Queries To SQL Server Tables
There are native PowerShell cmdlets to export to CSVĀ or text but I have not seen one that can easily export any SQL query output to a SQL Server table in bulk (Write-DbaDataTable function of dbatools does it for one table which I use in my solution below). I probably did not look too hard … Continue reading PowerShell: Export-QueryToSQLTable – Export All Of Glenn Berry’s DMV’s, sp_WhoIsActive, sp_Blitz & Any Of Your Own Queries To SQL Server Tables
Thoughts On When To Use – Write-Host, Write-Output, Write-Debug, Write-Warning, Write-Verbose & Write-Error/Throw
PowerShell has matured as the automation tool of choice on the Microsoft platform, be it on Windows or Azure. However, there is no official guidance on best-practices and standards around someĀ things. At times, bloggers do things incorrectly in their examples thereby reinforcing bad practices.Ā Hopefully, this small post will help connect some dots for you! Please … Continue reading Thoughts On When To Use – Write-Host, Write-Output, Write-Debug, Write-Warning, Write-Verbose & Write-Error/Throw
SQL Server: MERGE (AKA UPSERT) =(INSERT / UPDATE / DELETE) – All In One
MERGE statement doesĀ INSERT/UPDATE/DELETE For the longest time Oracle and SQL Server users have written code like this (pseudo code) This is great but this is such a common construct that everyone has also been long craving for built in support in the database for what people commonly call UPSERT (UPDATE if key exists else INSERT). … Continue reading SQL Server: MERGE (AKA UPSERT) =(INSERT / UPDATE / DELETE) – All In One