Last active
July 30, 2026 09:40
-
-
Save JohnRoos/293a5f093cd2927f5e07 to your computer and use it in GitHub Desktop.
Scripts
This file contains hidden or 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
| ### 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.