Skip to content

Instantly share code, notes, and snippets.

@Dalstroem
Last active June 12, 2019 19:30
Show Gist options
  • Save Dalstroem/e85a5d8d46f72ebc52cfcf32055c0e5d to your computer and use it in GitHub Desktop.
Save Dalstroem/e85a5d8d46f72ebc52cfcf32055c0e5d to your computer and use it in GitHub Desktop.
PowerShell scripts and functions
function New-Password ($Length=60) {
$characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
$random = 1..$Length | ForEach-Object { Get-Random -Maximum $characters.Length }
$characters[$random] -join ''
}
function Open-VisualStudioSolution ($Directory) {
$solutions = Get-ChildItem -Recurse -Path "$Directory*.sln"
if ($solutions.Count -eq 1) {
Invoke-Item $solutions.FullName
}
elseif ($solutions.Count -eq 0) {
Write-Host "Couldn't find any solution files here." -ForegroundColor Red
}
elseif ($solutions.Count -gt 1) {
Write-Host "Which one do you want to open?" -ForegroundColor Magenta
$root = (Get-Location).Path
$solutions | ForEach-Object {
$path = $_.FullName.Replace($root, '').TrimStart("\\")
Write-Host " - $path"
}
}
}
Set-Alias vs Open-VisualStudioSolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment