-
Notifications
You must be signed in to change notification settings - Fork 8
/
Profile.ps1
58 lines (50 loc) · 2.31 KB
/
Profile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## vim
New-Alias -Name vi -Value 'C:\Program Files (x86)\vim\vim82\vim.exe'
New-Alias -Name vim -Value 'C:\Program Files (x86)\vim\vim82\vim.exe'
## readline
Set-PSReadLineOption -EditMode Emacs
Set-PSReadlineKeyHandler -Key Tab -Function Complete
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
## du function
Function du {
gci . | %{$f=$_; gci -r -file $_.FullName | measure-object -property length -sum | select @{Name="Name"; Expression={$f}}, @{Name="Sum (MB)"; Expression={"{0:N3}" -f ($_.sum / 1MB) }}, Sum } | sort Sum -desc |format-table -Property Name,"Sum (MB)", Sum -autosize
}
## Mute Function
Function Toggle-Mute(){$wshShell = new-object -com wscript.shell;$wshShell.SendKeys([char]173)}
## Admin test
Function Test-IsAdmin {
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
## Modify title if admin
Function Admin-Test {
## From https://serverfault.com/a/95464
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$IsAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if(-not ($IsAdmin))
{$Host.ui.RawUI.WindowTitle = "Regular User PowerShell"}
else {$Host.ui.RawUI.WindowTitle = "**ADMIN** User PowerShell!"}
}
Admin-Test
## func to read chrome history
## set $username manually?
function get-chromehistory {
$path = "$env:systemdrive\users\$username\appdata\local\google\chrome\user data\default\history"
if (-not (test-path -path $path)) {
write-verbose "[!] could not find chrome history for username: $username"
}
$regex = '(htt(p|s))://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)*?'
$value = get-content -path "$env:systemdrive\users\$username\appdata\local\google\chrome\user data\default\history"|select-string -allmatches $regex |% {($_.matches).value} |sort -unique
$value | foreach-object {
$key = $_
if ($key -match $search){
new-object -typename psobject -property @{
user = $username
browser = 'chrome'
datatype = 'history'
data = $_
}
}
}
}