| + | 読む |
cmd /c @powershell -NoProfile -ExecutionPolicy unrestricted -Command "Start-Process powershell.exe -Verb runas"
@echo off
echo Set obj = CreateObject("Shell.Application"):obj.ShellExecute "cmd.exe", "", "", "runas", 1 > %TEMP%\_acmd.vbs
cscript %TEMP%\_acmd.vbs
| Extension | Description |
| .ps1 | Script file |
| .psd1 | Module's manifest file; usually comes with a script module or binary module |
| .psm1 | Script module file |
| .ps1xml | Format and type definitions file |
| .psc1 | Console file |
| .pssc | Session configuration file |
| .psrc | Role Capability file |
| PowerShell (Cmdlet) | PowerShell (Alias) | Windows Command Prompt | Unix shell |
| Get-ChildItem | gci, dir, ls | dir | ls |
| Test-Connection | ping | ping | ping |
| Get-Content | gc, type, cat | type | cat |
| Get-Command | gcm | help, where | type, which, compgen |
| Get-Help | help, man | help | apropos, man |
| Clear-Host | cls, clear | cls | clear |
| Copy-Item | cpi, copy, cp | copy, xcopy, robocopy | cp |
| Move-Item | mi, move, mv | move | mv |
| Remove-Item | ri, del, erase, rmdir, rd, rm | del, erase, rmdir, rd | rm, rmdir |
| Rename-Item | rni, ren, mv | ren, rename | mv |
| Get-Location | gl, cd, pwd | cd | pwd |
| Pop-Location | popd | popd | popd |
| Push-Location | pushd | pushd | pushd |
| Set-Location | sl, cd, chdir | cd, chdir | cd |
| Tee-Object | tee | ? | tee |
| Write-Output | echo, write | echo | echo |
| Get-Process | gps, ps | tlist, tasklist | ps |
| Stop-Process | spps, kill | kill, taskkill | kill |
| Select-String | sls | find, findstr | grep |
| Set-Variable | sv, set | set | env, export, set, setenv |
| Invoke-WebRequest | iwr, curl, wget | curl | wget, curl |
| AliasCmd | Original | etc command | result |
| sal | Set-Alias | sal curl (Join-Path $env:ChocolateyInstall "bin\curl.exe") sal curl (Join-Path $env:ChocolateyInstall "bin\curl.exe") -O AllScope |
- |
| gal | Get-Alias | - | CommandType Name Version Source Alias curl -> curl.exe |
| なし | cd $env:環境変数値 | cd $env:NVM_HOME | NVM_HOMEの場所へcd |
| 概要 | コマンド | 備考 |
| 絶対パスでpsファイルを指定 | powershell -File D:\path\to\dir\filename.ps1 | - |
| 引数あり | powershell -File D:\path\to\dir\filename.ps1 10 "あいうえお" 123 | - |
| コマンド直接実行 | set Arg1=1234 set Arg2=あいうえお powershell -Command "Write-Host %Arg1%;Write-Host %Arg2%;" |
内部でコーテーション利用時はエスケープが必要 |
| + | 読む |
| PS D:\> $calc="1+2+3+4+5+6+7+8+9+10" PS D:\> $calc 1+2+3+4+5+6+7+8+9+10 PS D:\> $calc.GetType() PS D:\> Invoke-Expression $calc |
| PS D:\> $target="c:\" PS D:\> $cmd = "get-childitem $target" PS D:\> Invoke-Expression $cmd |
| PS C:\Users\takk> 1..5 -join "+" 1+2+3+4+5 |
| PS C:\Users\takk> 1..5 -join "+" | invoke-expression |