Skip to content

Instantly share code, notes, and snippets.

@Serat00l951
Serat00l951 / switch_net_adapter.ps1
Created August 20, 2019 05:27
Switch the network adapter status
$adapter_name="Ethernet"
if ((Get-NetAdapter $adapter_name).InterfaceOperationalStatus -eq $true) {Disable-NetAdapter -Name $adapter_name -Confirm:$false} else {Enable-NetAdapter -Name $adapter_name -Confirm:$false}
@Serat00l951
Serat00l951 / ps - no start with double click.cmd
Last active June 11, 2022 12:37
Disable starting powershell scripts with double click
rem Run this with admin rights!
rem Запускать от имени администратора!
powershell -command "& {Set-ExecutionPolicy -ExecutionPolicy Restricted -Force}"
ftype Microsoft.PowerShellScript.1="C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe" "%%1"
assoc .ps1=Microsoft.PowerShellScript.1
reg delete "HKCR\Microsoft.PowerShellScript.1\shell\runas" /f
@Serat00l951
Serat00l951 / ps - start with double click.cmd
Last active June 11, 2022 12:29
Start powershell scripts with double click
rem Run this with admin rights!
rem Запускать от имени администратора!
powershell -command "& {Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force}"
ftype Microsoft.PowerShellScript.1="C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe" "%%1"
assoc .ps1=Microsoft.PowerShellScript.1
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ps1" /f
reg add "HKCR\Microsoft.PowerShellScript.1\shell\runas" /f
reg add "HKCR\Microsoft.PowerShellScript.1\shell\runas" /v "HasLUAShield" /t REG_SZ /f
@Serat00l951
Serat00l951 / encoding-helpers.ps1
Created April 9, 2019 16:24 — forked from jpoehls/encoding-helpers.ps1
Convert-FileEncoding and Get-FileEncoding
<#
.SYNOPSIS
Converts files to the given encoding.
Matches the include pattern recursively under the given path.
.EXAMPLE
Convert-FileEncoding -Include *.js -Path scripts -Encoding UTF8
#>
function Convert-FileEncoding([string]$Include, [string]$Path, [string]$Encoding='UTF8') {
$count = 0