PowerShell 基础

获取命令帮助:

Get-Help Select-Object

查找命令:

Get-command *printer*

清空终端输出:

  • clear
  • cls
  • Ctrl + L

查看命令的别名原始内容:

Get-Alias gal

终端输出:

Write-Host "Hello world"
echo "Hello world"

格式化输出:

Get-ChildItem | Format-Wide
Get-ChildItem | Format-List *

控制输出:

Get-ChildItem | Out-String
Get-ChildItem | Out-Default
Get-ChildItem | Out-Null
Get-ChildItem | Out-File

处理元素:

Remove-Item
Copy-Item
Get-Content
New-Item
Move-Item

获取PW执行权限:

Get-ExecutionPolicy --list
Set-Executionpolicy RemoteSigned
```<style>
  .scroll-to-top {
    font-size: 2.5rem;
    width: 3.2rem;
    height: 3.2rem;
    display: none;
    align-items: center;
    justify-content: center;
    position: fixed;
    padding: 0.75rem;
    bottom: 4rem;
    right: calc(1.25rem + 90px + var(--page-padding));
    z-index: 999;
    cursor: pointer;
    border: none;
    color: var(--bg);
    background: var(--fg);
    border-radius: 50%;
  }
  .scroll-to-top.hidden {
    display: none;
  }
  .scroll-to-top i {
    transform: translateY(-2px);
  }
  @media (min-width: 1080px) {
    .scroll-to-top {
      display: flex;
    }
  }
</style>
<button type="button" aria-label="scroll-to-top" class="scroll-to-top hidden" onclick="scrollToTop()">
  <i class="fa fa-angle-up"></i>
</button>
<script>
  const scrollToTop = () => window.scroll({ top: 0, behavior: "smooth" });
  window.addEventListener("scroll", () => {
    const button = document.querySelector(".scroll-to-top");
    button.classList.toggle("hidden", window.scrollY < 200);
  });
</script>