Skip to content

PowerShell

执行策略

链接

允许脚本执行

ps1
Set-ExecutionPolicy RemoteSigned

关闭/开启 IPV6

注意

保存为脚本文件时, 如有中文需要修改编码保存 ANSI GB2312 GBK GB18030 以管理员身份运行

ps1
Get-NetAdapterBinding -ComponentID ms_tcpip6
ps1
Disable-NetAdapterBinding -Name "以太网" -ComponentID ms_tcpip6
ps1
Enable-NetAdapterBinding -Name "以太网" -ComponentID ms_tcpip6

更改网络类型 (专用/公用)

ps1
Get-NetConnectionProfile
ps1
Set-NetConnectionProfile -Name "网络" -NetworkCategory Private
ps1
Set-NetConnectionProfile -Name "网络" -NetworkCategory Public

剪切板保存到文件

ps1
Get-Clipboard > name.txt

关闭显示器

monitor-off.bat

bat
@echo off
echo turn off in 3
timeout /t 1 /nobreak >nul
echo             2
timeout /t 1 /nobreak >nul
echo             1
timeout /t 1 /nobreak >nul

powershell -command "Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;public class Sleep{[DllImport(\"user32.dll\")]public static extern int SendMessage(int hWnd,int hMsg,int wParam,int lParam);}' ; [Sleep]::SendMessage(-1,0x0112,0xF170,2)"
exit