Skip to content

Instantly share code, notes, and snippets.

@JohnRoos
Last active July 30, 2026 09:40
Show Gist options
  • Select an option

  • Save JohnRoos/293a5f093cd2927f5e07 to your computer and use it in GitHub Desktop.

Select an option

Save JohnRoos/293a5f093cd2927f5e07 to your computer and use it in GitHub Desktop.
Scripts
### Which AD groups do I manage?
get-adgroup -LD "(ManagedBy=$((Get-ADUser -id $env:username).distinguishedname))" | select name
### Edit the ISE profile
if (Test-Path -Path $profile){
psedit $profile
}else{
New-Item -Path $profile -ItemType file -Force -Value
psedit $profile
}
### Change ISE tab to "Untitled1.ps1*"
$psISE.CurrentPowerShellTab.Files.SetSelectedFile( ($psISE.CurrentPowerShellTab.Files | Where-Object {$_.DisplayName -eq "Untitled1.ps1*"}) )
### Database connection (SQL Server)
$Server = 'localhost\sqlexpress'
$Database = 'MyDB'
$query = 'select * from table'
$connection = New-Object -TypeName System.Data.SqlClient.SqlConnection
$connection.ConnectionString = "Server=$Server;Database=$Database;Trusted_Connection=True;"
$connection.Open()
$command = $connection.CreateCommand()
$command.CommandText = $query
$adapter = New-Object -TypeName System.Data.SqlClient.SqlDataAdapter $command
$dataset = New-Object -TypeName System.Data.DataSet
$rowCount = $adapter.Fill($dataset)
$connection.Close()
$result = $dataset.Tables
Return $result.rows
@leo7422g

Copy link
Copy Markdown

Scripts are sets of written instructions that tell a computer or application how to perform specific tasks automatically. They are widely used in software development, web design https://deltascript.dev/grow-a-garden-script/, game development, and system administration to save time, reduce manual work, and improve efficiency. Popular scripting languages such as JavaScript, Python, Bash, and PowerShell allow developers to automate repetitive processes, create interactive features, manage files, and customize applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment