Skip to content

Instantly share code, notes, and snippets.

View SQLJana's full-sized avatar

Jana Sattainathan SQLJana

View GitHub Profile
@SQLJana
SQLJana / Get-ADGroupRecursive.ps1
Created September 2, 2020 16:57
Examples that show how to do recursion in PowerShell to find loops in a hierarchy, especially with Active Directory style Groups/Users and Nested Groups.
# Author: Jana Sattainathan - https://sqljana.wordpress.com - September 1, 2020
#Gets all the loops (ie., at some point members of groups are groups already traversed in hierarchy)
function Get-ADGroupLoops
{
param (
[Parameter()]
[object]$Identity,
@SQLJana
SQLJana / PowerShellHelper.cs
Created May 5, 2020 19:55
C# function to run PowerShell scripts and return results as a DataTable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Collections.ObjectModel; //Used for CollectionSystem.Collections.ObjectModel.Collection
using System.Management.Automation; //Used for all automation related functionality. Also has System.Management.Automation.PSObject.
using System.ComponentModel;
using System.Data;
using System.Linq;
@SQLJana
SQLJana / WPF_GUI_Example.xaml
Created May 5, 2020 18:39
XAML To Create A WPF GUI
<Window x:Class="SQLADHelper.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:VM="clr-namespace:SQLADHelper.ViewModel"
mc:Ignorable="d"
Title="SQL Server AD Helper"
Height="850"
Width="1200"
@SQLJana
SQLJana / Find-DbaDbIndex.ps1
Created March 13, 2020 18:52
Find-DbaDbIndex.ps1 - Finds SQL Server indexes using LIKE searches on Schema/Table/Index/Column names
#######################
<#
.SYNOPSIS
Helps locate indexes in non-heap tables based on SchemaName/TableName/IndexName/ColumnName and get the index details
.DESCRIPTION
Given a list of SQL Instances, searches all/specific databases in each instance using exact/like matching for
a matching Schema name (optional)
a matching Table name (optional)
@SQLJana
SQLJana / CloneUser.sql
Created March 1, 2018 19:51
Oracle PL/SQL script to clone user
DECLARE
v_Model_UserName VARCHAR2(30) := UPPER('&Model_UserName');
v_Cloned_UserName VARCHAR2(30) := UPPER('&Cloned_UserName');
v_Skip_If_Model_User_Missing VARCHAR2(1) := '&Skip_If_Model_User_Missing';
v_Remove_Cloned_User_If_Exists VARCHAR2(1) := '&Remove_Cloned_User_If_Exists';
v_Retain_Same_Password VARCHAR2(1) := '&Retain_Same_Password';
v_SQL VARCHAR2(32000);
v_Count NUMBER;