Better Powershell integration
This commit is contained in:
parent
6c1dd033b6
commit
e149d95a25
@ -59,11 +59,11 @@ function Get-Elevated {
|
|||||||
#>
|
#>
|
||||||
function New-Link {
|
function New-Link {
|
||||||
param (
|
param (
|
||||||
[Parameter(Position=0, Mandatory=$true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
[string[]]
|
[string[]]
|
||||||
$Source,
|
$Source,
|
||||||
|
|
||||||
[Parameter(Position=1, Mandatory=$true)]
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
[string[]]
|
[string[]]
|
||||||
$Destination
|
$Destination
|
||||||
)
|
)
|
||||||
@ -72,7 +72,8 @@ function New-Link {
|
|||||||
# to do symbolic links without administrator privileges
|
# to do symbolic links without administrator privileges
|
||||||
if (Get-Elevated) {
|
if (Get-Elevated) {
|
||||||
New-Item -ItemType SymbolicLink -Path $Destination -Target $Source
|
New-Item -ItemType SymbolicLink -Path $Destination -Target $Source
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
# Elevate our permissions for this first.
|
# Elevate our permissions for this first.
|
||||||
Invoke-Elevated {
|
Invoke-Elevated {
|
||||||
New-Item -ItemType SymbolicLink -Path $Destination -Target $Source
|
New-Item -ItemType SymbolicLink -Path $Destination -Target $Source
|
||||||
@ -80,6 +81,52 @@ function New-Link {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Get Powershell Version and optionally the host version.
|
||||||
|
|
||||||
|
.Parameter Full
|
||||||
|
Show all the version information not just the version
|
||||||
|
number and edition.
|
||||||
|
|
||||||
|
.Parameter WithHost
|
||||||
|
Show the Host version as well.
|
||||||
|
#>
|
||||||
|
function Get-PSVersion {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[Switch] $Full,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[Switch] $WithHost
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($Full) {
|
||||||
|
$PSVersionTable |
|
||||||
|
if ($WithHost) {
|
||||||
|
Get-Host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
@{ PSVersion = $PSVersionTable.PSVersion; PSEdition = $PSVersionTable.PSEdition }
|
||||||
|
if ($WithHost) {
|
||||||
|
$HostInfo = Get-Host
|
||||||
|
@{HostName = $HostInfo.Name; HostVersion = $HostInfo.Version }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $output
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-Base64-Decoded {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter()]
|
||||||
|
[string[]]
|
||||||
|
$encoded
|
||||||
|
)
|
||||||
|
[Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($encoded))
|
||||||
|
}
|
||||||
|
|
||||||
function grep {
|
function grep {
|
||||||
$input | out-string -stream | select-string $args
|
$input | out-string -stream | select-string $args
|
||||||
}
|
}
|
||||||
@ -90,4 +137,5 @@ Set-Alias -Name ln -Value New-Link
|
|||||||
Set-Alias -name which -Value Get-Command
|
Set-Alias -name which -Value Get-Command
|
||||||
|
|
||||||
# Add make to our powershell path
|
# Add make to our powershell path
|
||||||
$env:PATH="$env:PATH;C:\Program Files (x86)\GnuWin32\bin;C:\Users\jerem\AppData\Local\Julia-1.3.0\bin"
|
$env:PATH = "$env:PATH;C:\Program Files (x86)\GnuWin32\bin;C:\Users\jerem\AppData\Local\Julia-1.3.0\bin;C:\Users\jerem\AppData\Roaming\nvm;C:\Users\jerem\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin"
|
||||||
|
$env:NVM_HOME = "C:\Users\jerem\AppData\Roaming\nvm"
|
@ -1,15 +1,15 @@
|
|||||||
#Powershell based windows 10 bootstrap script
|
#Powershell based windows 10 bootstrap script
|
||||||
|
|
||||||
# First we source in our powershell profile so we can have some useful utilities
|
# First we source in our powershell profile so we can have some useful utilities
|
||||||
source "./PowerShellProfile.ps1"
|
. "./PowerShellProfile.ps1"
|
||||||
|
|
||||||
# First step is to overwrite our current profile with a symlink to the correct one.
|
# First step is to overwrite our current profile with a symlink to the correct one.
|
||||||
Remove-Item -Force -Path $profile
|
Remove-Item -Force -Path $profile
|
||||||
Make-Link -Source "./PowerShellProfile.ps1" -Destination $profile
|
New-Item -ItemType SymbolicLink -Target "./PowerShellProfile.ps1" -Path $profile
|
||||||
|
|
||||||
# Now ensure our dnsservers are properly set up
|
# Now ensure our dnsservers are properly set up
|
||||||
Invoke-Elevated {
|
Invoke-Elevated {
|
||||||
Get-NetAdapter | ForEach-Object {
|
Get-NetAdapter | ForEach-Object {
|
||||||
Set-DnsClientServerAddress -InterfaceIndex $_.ifIndex -ServerAddresses 1.1.1.1,1.0.0.1,2606:4700:4700::1111,2606:4700:4700::1001
|
Set-DnsClientServerAddress -InterfaceIndex $_.ifIndex -ServerAddresses 1.1.1.1, 1.0.0.1, 2606:4700:4700::1111, 2606:4700:4700::1001
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user