-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathShell-Function.ps1
More file actions
138 lines (102 loc) · 3.34 KB
/
Shell-Function.ps1
File metadata and controls
138 lines (102 loc) · 3.34 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<#PSScriptInfo
.VERSION 1.0
.GUID 27c80b64-2c07-43ee-ae20-4d94965295eb
.AUTHOR Dmitry.Stadub
.COMPANYNAME
.COPYRIGHT
.TAGS uninstall msiexec
.LICENSEURI
.PROJECTURI https://github.com/stadub/PowershellScripts
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
#>
<#
.SYNOPSIS
Uninstall Application
.DESCRIPTION
Allows to Uninstall Application from system
.EXAMPLE
Uninstall-Application "Microsoft*4.5*"
.PARAMETER SoftwareName
Application name(Or application name format)
#>
filter Get-SearchAndPrint() {
Param ([string]$filterStr = $null)
$_ | select-string -pattern $filterStr
}
filter Split-String() {
Param ([string]$separator = $null)
$_.Split | select-string -pattern $separator
}
function Get-Batchfile ($file) {
$cmd = "`"$file`" & set"
cmd /c $cmd | Foreach-Object {
$p, $v = $_.split('=')
Set-Item -path env:$p -value $v
}
}
function Initialize-VisualStudioEnvieronment($version = "10.0") {
$key = "HKLM:SOFTWARE\Microsoft\VisualStudio\" + $version
$VsKey = get-ItemProperty $key
$VsInstallPath = [System.IO.Path]::GetDirectoryName($VsKey.InstallDir)
$VsToolsDir = [System.IO.Path]::GetDirectoryName($VsInstallPath)
$VsToolsDir = [System.IO.Path]::Combine($VsToolsDir, "Tools")
$BatchFile = [System.IO.Path]::Combine($VsToolsDir, "vsvars32.bat")
Get-Batchfile $BatchFile
[System.Console]::Title = "Visual Studio " + $version + " Windows Powershell"
#add a call to set-consoleicon as seen below...hm...!
}
function Get-CmdletAlias ($cmdletname) {
get-alias | Where-Object { $_.definition -like "*$cmdletname*" } | Format-Table Definition, Name -auto
}
#function Color-Console
# {
# $host.ui.rawui.backgroundcolor = "white"
# $host.ui.rawui.foregroundcolor = "black"
# $hosttime = (dir $pshome\PowerShell.exe).creationtime
# $Host.UI.RawUI.WindowTitle = "Windows PowerShell $hostversion ($hosttime)"
# clear-host
# }
# Color-console
enum LinkType {
Symbolic
Hard
Junction
}
function New-FileSystemLink {
[cmdletbinding(DefaultParameterSetName = 'Positional' )]
param(
[Parameter(Position = 0, ParameterSetName = 'Positional', ValueFromPipeline = $True, Mandatory = $true)]
[Alias("-s", "-Source")]
[string]$source,
[Parameter(Position = 1, ParameterSetName = 'Positional')]
[Alias("-dest", "-Destanation")]
[string]$destanation = $((Get-Location).Path),
[Parameter(Position = 2, ParameterSetName = 'Positional', Mandatory = $true)]
[ServerType]$type = [LinkType]::Symbolic
)
New-Item -Path $destanation -ItemType $type -Value $source
}
function Propmpt {
param (
[Parameter(Position = 0, ParameterSetName = 'Positional', ValueFromPipeline = $True, Mandatory = $true)]
[Alias("Question", "-Description")]
[string]$text
)
$reply = Read-Host -Prompt "$text`
[Y] Yes [N] No [S] Suspend(default is ""Yes""):"
if ( $reply -match "[yY]" -and $null -ne $reply ) {
return $true
}
if ( $reply -match "[Ss]" ) { throw "Execution aborted" }
return $false
}
Set-Alias grep Get-SearchAndPrint
Set-Alias cut Split-String
Set-Alias VsVars32 Initialize-VisualStudioEnvieronment
Set-Alias ga Get-CmdletAlias
Set-Alias fl New-FileSystemLink
Set-Alias pb Export-Module