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
# Create Basic Datatable | |
$datatable = New-Object System.Data.Datatable | |
[void]$datatable.Columns.Add("name") | |
[void]$datatable.Columns.Add("directory") | |
[void]$datatable.Columns.Add("bytes", [double]) | |
# Add data | |
[void]$datatable.Rows.Add("locate","C:",1.0) | |
[void]$datatable.Rows.Add("Backup","C:\locate",1.0) | |
[void]$datatable.Rows.Add("Invoke-Locate.ps1","C:\locate",39630.0) |
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
# From https://blog.netnerds.net/2015/01/quickly-find-duplicates-from-csv-using-powershell/ | |
# The Text OleDB driver is only available in PowerShell x86. Start x86 shell if using x64. | |
# This has to be the first check this script performs. | |
if ($env:Processor_Architecture -ne "x86") { | |
Write-Warning "Switching to x86 shell" | |
&"$env:windir\syswow64\windowspowershell\v1.0\powershell.exe" "$PSCommandPath $args"; return | |
} | |
# Change to your CSV file name, must end in .csv or .tsv | |
$csvfile = "C:\temp\million-commas.txt" |
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
Function Join-AdminUNC { | |
<# | |
.SYNOPSIS | |
Parses a path to make it an admin UNC. | |
.EXAMPLE | |
Join-AdminUNC sqlserver C:\windows\system32 | |
Output: \\sqlserver\c$\windows\system32 | |
.OUTPUTS |
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
# See PowerShell Magazine article at ..... | |
$jet = (New-Object System.Data.OleDb.OleDbEnumerator).GetElements() | Where-Object { $_.SOURCES_NAME -eq "Microsoft.Jet.OLEDB.4.0" } | |
if ($jet -eq $null) { | |
if ($env:Processor_Architecture -ne "x86") { | |
&"$env:windir\syswow64\windowspowershell\v1.0\powershell.exe" | |
} | |
} | |
$csv = "$env:TEMP\top-tracks.csv" | |
Invoke-WebRequest http://git.io/vvzxA | Set-Content -Path $csv | |
$firstRowColumnNames = "Yes" |
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
Function New-TextIcon { | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$true)] | |
[string]$Text, | |
[string]$Path, | |
[int]$Height = 16, | |
[int]$Width = 16, | |
[int]$FontSize = 9 |
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
Function Show-SystemColors { | |
<# | |
.SYNOPSIS | |
Shows a visual representation (grid with color block, name, and hex code)) of system colors. | |
.NOTES | |
Author : Chrissy LeMaire | |
Requires: PowerShell 3.0 | |
Version: 1.0 | |
DateUpdated: 2015-Sep-16 |
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
[xml]$xaml = '<Window | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
WindowStyle="None" ResizeMode="NoResize" ShowInTaskbar="False" | |
Height="0" Width="0" Background="Transparent"> | |
<Popup Name="popup" Placement="AbsolutePoint" StaysOpen="False"> | |
<Grid Name="grid" Height="400" Width="390" Background="DarkGray"> | |
<Label Name="label" Content="Double-click to close" Foreground="White" FontSize="18"/> | |
</Grid> | |
</Popup> |
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
# Load WPF Assemblies | |
Add-Type -AssemblyName PresentationFramework | |
# Get the info you need from SQL Server | |
$sqlserver = "sqlserver2014a" | |
$query = "select name from master.dbo.sysdatabases order by name" | |
$conn = New-Object System.Data.SqlClient.SqlConnection | |
$conn.ConnectionString = "Data Source=$sqlserver;Integrated Security=True;Connection Timeout=3" | |
$conn.Open() |
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
$sqlserver = "sqlserver2014a" | |
Function Get-SqlDatabases { | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$SqlServer, | |
[object]$Credential | |
) | |
$paramconn = New-Object System.Data.SqlClient.SqlConnection |
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
# Solution for http://powershell.com/cs/forums/t/23737.aspx | |
[void][Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | |
$server = New-Object Microsoft.SqlServer.Management.Smo.Server "sqlserver" | |
$servername = $server.netname | |
$sqlinstancename = $server.DomainInstanceName | |
$dbs = $server.databases | Where-Object { 'tempdb','Pubs','Northwind','model' -notcontains $_.Name } | |
$loginreport = @() | |
foreach ($db in $dbs) { | |
$users = $db.users | Where-Object { 'guest','sys','INFORMATION_SCHEMA'-notcontains $_.Name -and $_.Name -notlike '*##*' -and $_.Name -notlike '*$*' -and $_.Name -ne $null } |