]> apps.delaporte.us Git - dotfiles.git/blob - Microsoft.PowerShell_profile.ps1
Tweaks
[dotfiles.git] / Microsoft.PowerShell_profile.ps1
1
2
3 ## Setup reminder:
4 # code $profile
5 # Set-ExecutionPolicy RemoteSigned
6 # . C:\src\dotfiles\Microsoft.PowerShell_profile.ps1
7
8
9 Import-Module posh-git
10 # Courtesty of MKletz
11 # Get-ChildItem -Path 'C:\Repos' -Filter "*.psd1" -Recurse | ForEach-Object -Process {
12 # $Path = Split-Path -Path $_.Directory -Parent
13 # $env:PSModulePath = $env:PSModulePath + ";$($Path)"
14 #}
15 $env:PSModulePath = $env:PSModulePath.Replace("\\ad.uillinois.edu\techsvc\home\$($ENV:USERNAME)\Documents\PowerShell\Modules;",'')
16
17 # Kali linux env
18 $ENV:PATH +=":/home/delaport/development/flutter/bin" # Flutter in Kali under WSL
19
20 # Some Paths that are annoying to find/restore if the installer fails
21 $ENV:PATH+=";C:\Program Files\Microsoft VS Code\bin" # One Editor to rule them all
22 $ENV:PATH+=";C:\Program Files\Python38\Scripts\;C:\Program Files\Python38\" # Python latest as of 2019 December
23 $ENV:PATH+=";C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin" # Docker for R Studio and Jupyter
24 $ENV:PATH+=";C:\Program Files (x86)\Common Files\Oracle\Java\javapath" # Don't remember why I still care about Java.
25 $ENV:PATH+=";C:\Program Files\Git\cmd" # Version control is nice.
26 $ENV:PATH+=";C:\ProgramData\chocolatey\bin" # Package management is nice.
27 $ENV:PATH+=";C:\Program Files\nodejs" # KataKoda wants to add tools via npm
28 $ENV:PATH+=";C:\PENGUIN" # Flag to ensure my profile kicked in.
29
30
31 function Find-LargeFiles() {
32 Get-ChildItem c:\ -r| sort -descending -property length | select -first 10 name, Length, FullName
33 }
34
35 function List-DriveSpace() {
36 Get-PSDrive C | Select-Object Used,Free
37 }
38
39
40 function Start-Vault() {
41 consul agent -dev # Run in Dev Mode
42 vault sever -config c:\src\dotfiles\vaultconfig.hcl -address=http://127.0.0.1:8200 # Use local dev Consul as storage
43 }
44
45 function New-DockerRStudio() {
46 docker run --name=rpython -Pit -p 8888:8888 -p 8787:8787 -p 8022:22 -p 6006:6006 -v c:\src\data:/mnt/data datascienceschool/rpython
47 }
48 function Start-DockerRStudio() {
49 docker start rpython
50 jupyter notebook list
51 Write-Host "R Studio is running at http://localhost:8787/"
52 Write-Host "Jupyter is running at http://localhost:8888/"
53 }
54
55 function Start-DockerOWASPZap() {
56 Param(
57 [string]$URL
58 )
59 # https://github.com/zaproxy/zaproxy/wiki/Docker
60 docker run owasp/zap2docker-stable
61 docker run -i owasp/zap2docker-stable zap-cli quick-scan --self-contained --start-options '-config api.disablekey=true' $URL
62 Write-Host "https://github.com/zaproxy/zaproxy/wiki/Docker"
63 }
64
65
66 function Start-DockerWebGoat() {
67 docker pull webgoat/webgoat-8.0
68 docker run -p 8080:8080 -t webgoat/webgoat-8.0
69 Write-Host "Vulnerable Webgoat running on 8080"
70 }
71
72 function Start-DockerJuiceShop() {
73 docker pull bkimminich/juice-shop
74 docker run --rm -p 3000:3000 bkimminich/juice-shop
75 Write-Host "Vulnerable Juice Shop running on 3000"
76 }
77
78 function Start-DockerGrafana() {
79 docker run --rm -d --name=grafana -p 3001:3001 -user $ID --volume "C:\src\data:/var/lib/grafana" grafana/grafana
80 Write-Host "Grafana running on 3001"
81 }
82
83 # Import some home grown PowerShell modules, if they are installed.
84 $modPaths = @("C:\src\dotfiles\ToyBox\toybox.psm1")
85 $modPaths | ForEach-Object {
86 $_ | Format-Table
87 if(Test-Path -Path $_) {
88 Import-Module $_
89 Write-Host "Loaded $_"
90 }
91 }
92
93 function Start-DockerPython3Bash {
94 docker run -it python /bin/bash
95 }
96
97 function Start-DockerPython2Bash {
98 docker run -it python:2-buster /bin/bash
99 }
100
101 function Stop-Docker {
102 docker stop $(docker ps -a -q)
103 }
104
105 function New-DockerAirflow {
106 docker run -v ./:/etc/myscripts apache/airflow /bin/bash /etc/myscripts/airflow.sh
107
108 }
109
110 function Start-DockerAirflow {
111 docker run airflow -f webserver
112 }
113
114 function Start-DockerFindSecrets {
115 # docker run -v "$((Get-Item .).FullName)":/etc/src dxa4481/trufflehog /bin/bash
116 # Write-Host "Current folder mounted as /etc/src"
117 docker run -v /c/src:/etc/src dxa4481/trufflehog /etc/src/SecOps-Tools
118 }
119
120
121 #requires -version 5.1
122 #ConvertTo-ASCIIArt.ps1
123
124 <#
125 font list at https://artii.herokuapp.com/fonts_list
126 font names are case-sensitive
127
128 invoke-restmethod https://artii.herokuapp.com/fonts_list
129
130 #>
131
132 <#
133 .SYNOPSIS
134 Output strings as ASCII art fonts.
135
136 .EXAMPLE
137 cart "Testing"-Font cursive
138
139 .NOTES
140 From https://jdhitsolutions.com/blog/powershell/7278/friday-fun-powershell-ascii-art/
141 #>
142 Function ConvertTo-ASCIIArt {
143 [cmdletbinding()]
144 [alias("cart")]
145 [outputtype([System.String])]
146 Param(
147 [Parameter(Position = 0, Mandatory, HelpMessage = "Enter a short string of text to convert", ValueFromPipeline)]
148 [ValidateNotNullOrEmpty()]
149 [string]$Text,
150 [Parameter(Position = 1,HelpMessage = "Specify a font from https://artii.herokuapp.com/fonts_list. Font names are case-sensitive")]
151 [ValidateNotNullOrEmpty()]
152 [string]$Font = "big"
153 )
154
155 Begin {
156 Write-Verbose "[$((Get-Date).TimeofDay) BEGIN] Starting $($myinvocation.mycommand)"
157 } #begin
158
159 Process {
160 Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Processing $text with font $Font"
161 $testEncode = [uri]::EscapeDataString($Text)
162 $url = "http://artii.herokuapp.com/make?text=$testEncode&font=$Font"
163 Try {
164 Invoke-Restmethod -Uri $url -DisableKeepAlive -ErrorAction Stop
165 }
166 Catch {
167 Throw $_
168 }
169 } #process
170 End {
171 Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($myinvocation.mycommand)"
172 } #end
173 }
174
175
176 #### User Configuraable Variables ####
177 ## https://github.com/techservicesillinois/Powershell-SupportApp
178
179 # Customize the title bar of your console.
180 [string]$SA_title="PowerShell Support App for U of I"
181 # Path to a text editor
182 [string]$SA_TextEditor="C:\Program Files (x86)\Notepad++\notepad++.exe"
183 $SA_Config_base=$true
184 import-module .\PowerShellSupportAppV2\PowerShellSupportAppV2.psm1