随笔分类 -  Power Shell

摘要:compose multiple variables into a command line, then execute it. ```ps1 $dest="a:\des" $source="b:\src" $cmdlink="cmd" $cmdPart1="/c", "mklink", "/j" 阅读全文
posted @ 2023-06-22 08:17 fndefbwefsowpvqfx
摘要:```pwsh $config="a:/etc/data.xml" $fromString='' $toString = ' false ' (Get-Content $config).replace($fromString, $toString) | Set-Content $config ``` 阅读全文
posted @ 2023-06-22 08:12 fndefbwefsowpvqfx
摘要:New-NetFirewallRule Remove-NetFirewallRule Disable-NetFirewallRule Enable-NetFirewallRule Get-NetFirewallRule Show-NetFirewallRule Rename-NetFirewallR 阅读全文
posted @ 2023-05-19 14:10 fndefbwefsowpvqfx
摘要:Win+R and typing taskschd.msc schtasks.exe /Create Add a new scheduled task /tn Name of task /sc schedule frequency (MINUTE, HOURLY, DAILY and so on) 阅读全文
posted @ 2023-05-12 17:37 fndefbwefsowpvqfx
摘要:check if is admin (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.Wi 阅读全文
posted @ 2023-05-11 14:58 fndefbwefsowpvqfx
摘要:1. handle usage: handle [[-a [-l]] [-v|-vt] [-u] | [-c <handle> [-y]] | [-s]] [-p <process>|<pid>] [name] [-nobanner] -a Dump all handle information. 阅读全文
posted @ 2023-05-10 13:13 fndefbwefsowpvqfx
摘要:by name bat taskkill /IM SystemInformer.exe taskkill /F /IM chrome.exe pwsh Get-Process "chrome" | Stop-Process 阅读全文
posted @ 2023-05-10 13:02 fndefbwefsowpvqfx
摘要:$delPath="x:\y\z\" If (Test-Path $delPath){ Remove-Item $delPath -Recurse -Force } $tpath = "u:\v\w" If(!(test-path -PathType container $tpath)) { New 阅读全文
posted @ 2023-05-06 18:15 fndefbwefsowpvqfx
摘要:list Get-Service | Format-List Get-Service -Name DNS*,DHCP* stop Stop-Service -name Dnscache -force disable Set-Service -name Dnscache -startupType di 阅读全文
posted @ 2023-04-15 11:57 fndefbwefsowpvqfx
摘要:# 1. powershell 用安装包安装,它会配置些环境变量 # 2. include 多文件 ```ps1 $ownSscriptRoot = 'abs:\path\to\PowerShell\' $workPS = $ownSscriptRoot + "work.ps1" ``` # 3. 阅读全文
posted @ 2023-04-03 13:59 fndefbwefsowpvqfx
摘要:https://github.com/ThePoShWolf/Utilities/blob/master/Misc/Set-PathVariable.ps1 <# .SYNOPSIS Modify the PATH environment variable. .DESCRIPTION Set-Pat 阅读全文
posted @ 2023-04-03 13:18 fndefbwefsowpvqfx
摘要:Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*' # Install the OpenSSH Client Add-WindowsCapability -Online -Name OpenSSH.Client~~~~ 阅读全文
posted @ 2023-03-07 14:52 fndefbwefsowpvqfx
摘要:$ownSscriptRoot = 'C:\abs\path\Documents\PowerShell\' $workPS = $ownSscriptRoot + "work.ps1" Import-Module $workPS 在本文中可使用work.ps1中定义的函数 阅读全文
posted @ 2023-03-07 14:24 fndefbwefsowpvqfx
摘要:choko https://chocolatey.org/install https://github.com/dahlbyk/posh-git/ choco install poshgit choco install oh-my-posh path vscode, termial 都有配置 C:\ 阅读全文
posted @ 2022-07-20 15:02 fndefbwefsowpvqfx
摘要:命令异常退出返回非0. 重复执行命令,直到返回0. 注意,如果一直失败,会一直重试,导致CPU使用率飙升。 TODO: 重试前sleep do { yourcmd -o '%(playlist)s/%(playlist_index)s_%(title)s.%(ext)s' -f 'bestvideo 阅读全文
posted @ 2022-04-26 18:50 fndefbwefsowpvqfx
摘要:%APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt 阅读全文
posted @ 2022-03-02 08:13 fndefbwefsowpvqfx
摘要:# link https://github.com/microsoft/terminal/releases extracted win64 exe https://files.cnblogs.com/files/Searchor/CascadiaPackage_1.6.10412.0_x64.7z 阅读全文
posted @ 2021-03-01 09:35 fndefbwefsowpvqfx
摘要:禁止对@进行特殊处理,当做splat 操作 就是加上引号 curl --request POST -H "@cheader.txt" --form "pushfile=@path/to/data.zip" 127.0.0.1:3000/uploadfile 获取指定网卡的IPV4地址 使用ipcon 阅读全文
posted @ 2020-09-16 15:44 fndefbwefsowpvqfx
摘要:https://github.com/microsoft/winget-cli Chocolatey Install: First, ensure that you are using an administrative shell - you can also install as a non-a 阅读全文
posted @ 2020-09-02 11:41 fndefbwefsowpvqfx
摘要:which <--> Get-Command 阅读全文
posted @ 2020-08-13 16:20 fndefbwefsowpvqfx