Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
PowerShell
(edit)
Revision as of 07:18, 9 January 2018
38 bytes added
,
07:18, 9 January 2018
→Modify Routing Table
Line 2:
Line 2:
<source lang="PowerShell">param([switch]$Elevated)
<source lang="PowerShell">param([switch]$Elevated)
function Check-Admin {
function Check-Admin {
−
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
+
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
−
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
+
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
}
if ((Check-Admin) -eq $false) {
if ((Check-Admin) -eq $false) {
−
if ($elevated)
+
if ($elevated)
−
{
+
{
−
# could not elevate, quit
+
# could not elevate, quit
−
}
+
}
else {
else {
−
+
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
−
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
+
}
−
}
+
exit
−
exit
}
}
#eliminar ruta por defecto al haber 2 y a;ade ruta a vsphere
#eliminar ruta por defecto al haber 2 y a;ade ruta a vsphere
−
route delete 0.0.0.0 mask 0.0.0.0 15.17.160.1
route delete 0.0.0.0 mask 0.0.0.0 15.17.160.1
−
route add 20.1.40.0 mask 255.255.255.0 15.17.160.1
route add 20.1.40.0 mask 255.255.255.0 15.17.160.1
−
Start-Sleep -s 2
Start-Sleep -s 2
−
exit</source>
exit</source>
Rafahsolis
Bureaucrats
,
Administrators
2,306
edits
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version